Package net.dona.doip.server

# Interface DoipServerResponse

All Known Implementing Classes:
  `DoipServerResponseImpl`

public interface DoipServerResponse
Interface for an outgoing DOIP response to be populated by a `DoipProcessor`. The initial segment of the response is a JSON segment with a status code and attributes. The `DoipProcessor` can set those until the initial segment is "committed", that is, sent to the client. The initial segment can be committed manually with a call to `commit()`, and will be committed automatically when either `writeCompactOutput(JsonElement)` or `getOutput()` is called.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `commit()`
  Ensure that the initial segment has been sent to the client.
  `com.google.gson.JsonObject`
  `getAttributes()`
  Returns the entire collection of attributes in the initial segment of the DOIP response.
  `OutDoipMessage`
  `getOutput()`
  Get an `OutDoipMessage` for writing output segments to the client.
  `String`
  `getStatus()`
  Returns the status code in the initial segment of the DOIP response.
  `void`
  `setAttribute(String key, com.google.gson.JsonElement value)`
  Set a single attribute in the initial segment of the response.
  `void`
  `setAttribute(String key, String value)`
  Set (as a String) a single attribute in the initial segment of the response.
  `void`
  `setAttributes(com.google.gson.JsonObject attributes)`
  Set the entire collection of attributes in the initial segment of the response.
  `void`
  `setStatus(String status)`
  Sets the status code in the initial segment of the response.
  `void`
  `writeCompactOutput(com.google.gson.JsonElement output)`
  Write a "compact" single-segment output.

- ## Method Details

  - ### setStatus

    void setStatus(String status)
    Sets the status code in the initial segment of the response.
    Parameters:
      `status` - the status code

  - ### getStatus

    String getStatus()
    Returns the status code in the initial segment of the DOIP response.
    Returns:
      the status code in the initial segment of the DOIP response

  - ### setAttribute

    void setAttribute(String key, com.google.gson.JsonElement value)
    Set a single attribute in the initial segment of the response.
    Parameters:
      `key` - the attribute to set
      `value` - the value of the attribute to be set

  - ### setAttribute

    void setAttribute(String key, String value)
    Set (as a String) a single attribute in the initial segment of the response.
    Parameters:
      `key` - the attribute to set
      `value` - the value of the attribute to be set

  - ### setAttributes

    void setAttributes(com.google.gson.JsonObject attributes)
    Set the entire collection of attributes in the initial segment of the response.
    Parameters:
      `attributes` - the new value of the entire attributes collection

  - ### getAttributes

    com.google.gson.JsonObject getAttributes()
    Returns the entire collection of attributes in the initial segment of the DOIP response.
    Returns:
      the entire collection of attributes in the initial segment of the DOIP response

  - ### commit

    void commit() throws IOException
    Ensure that the initial segment has been sent to the client.
    Throws:
      `IOException`

  - ### writeCompactOutput

    void writeCompactOutput(com.google.gson.JsonElement output) throws IOException
    Write a "compact" single-segment output. The output is supplied as an "output" property in the JSON of the single segment sent to the client.
    Parameters:
      `output` - the output JSON
    Throws:
      `IOException`

  - ### getOutput

    OutDoipMessage getOutput() throws IOException
    Get an `OutDoipMessage` for writing output segments to the client. This is used for a non-compact output containing multiple segments. This will commit the initial segment, so it will no longer be possible to change the status code or attributes.
    Returns:
      an OutDoipMessage for writing output segments.
    Throws:
      `IOException`