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

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `commit()` | Ensure that the initial segment has been sent to the client.
    `OutDoipMessage` | `getOutput()` | Get an `OutDoipMessage` for writing output segments to the client.
    `void` | `setAttribute​(java.lang.String key, com.google.gson.JsonElement value)` | Set a single attribute in the initial segment of the response.
    `void` | `setAttribute​(java.lang.String key, java.lang.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​(java.lang.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 Detail

    - #### setStatus

          void setStatus​(java.lang.String status)

      Sets the status code in the initial segment of the response.
      Parameters:
        `status` - the status code

    - #### setAttribute

          void setAttribute​(java.lang.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​(java.lang.String key,
                            java.lang.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

    - #### commit

          void commit()
               throws java.io.IOException

      Ensure that the initial segment has been sent to the client.
      Throws:
        `java.io.IOException`

    - #### writeCompactOutput

          void writeCompactOutput​(com.google.gson.JsonElement output)
                           throws java.io.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:
        `java.io.IOException`

    - #### getOutput

          OutDoipMessage getOutput()
                            throws java.io.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:
        `java.io.IOException`