Package net.dona.doip.server

# Class DoipServerResponseImpl

java.lang.Object
net.dona.doip.server.DoipServerResponseImpl

All Implemented Interfaces:
  `DoipServerResponse`

public class DoipServerResponseImpl extends Object implements DoipServerResponse
An implementation of `DoipServerResponse` used internally by `DoipServer`.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DoipServerResponseImpl(String requestId, OutDoipMessage outDoipMessage)`

- ## 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`
  `getRequestId()`
  `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.
  `protected void`
  `writeInitialSegment(com.google.gson.JsonElement output)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### DoipServerResponseImpl

    public DoipServerResponseImpl(String requestId, OutDoipMessage outDoipMessage)

- ## Method Details

  - ### setStatus

    public void setStatus(String status)
    Description copied from interface: `DoipServerResponse`
    Sets the status code in the initial segment of the response.
    Specified by:
      `setStatus` in interface `DoipServerResponse`
    Parameters:
      `status` - the status code

  - ### getStatus

    public String getStatus()
    Description copied from interface: `DoipServerResponse`
    Returns the status code in the initial segment of the DOIP response.
    Specified by:
      `getStatus` in interface `DoipServerResponse`
    Returns:
      the status code in the initial segment of the DOIP response

  - ### getRequestId

    public String getRequestId()

  - ### setAttribute

    public void setAttribute(String key, com.google.gson.JsonElement value)
    Description copied from interface: `DoipServerResponse`
    Set a single attribute in the initial segment of the response.
    Specified by:
      `setAttribute` in interface `DoipServerResponse`
    Parameters:
      `key` - the attribute to set
      `value` - the value of the attribute to be set

  - ### setAttribute

    public void setAttribute(String key, String value)
    Description copied from interface: `DoipServerResponse`
    Set (as a String) a single attribute in the initial segment of the response.
    Specified by:
      `setAttribute` in interface `DoipServerResponse`
    Parameters:
      `key` - the attribute to set
      `value` - the value of the attribute to be set

  - ### setAttributes

    public void setAttributes(com.google.gson.JsonObject attributes)
    Description copied from interface: `DoipServerResponse`
    Set the entire collection of attributes in the initial segment of the response.
    Specified by:
      `setAttributes` in interface `DoipServerResponse`
    Parameters:
      `attributes` - the new value of the entire attributes collection

  - ### getAttributes

    public com.google.gson.JsonObject getAttributes()
    Description copied from interface: `DoipServerResponse`
    Returns the entire collection of attributes in the initial segment of the DOIP response.
    Specified by:
      `getAttributes` in interface `DoipServerResponse`
    Returns:
      the entire collection of attributes in the initial segment of the DOIP response

  - ### commit

    public void commit() throws IOException
    Description copied from interface: `DoipServerResponse`
    Ensure that the initial segment has been sent to the client.
    Specified by:
      `commit` in interface `DoipServerResponse`
    Throws:
      `IOException`

  - ### writeInitialSegment

    protected void writeInitialSegment(com.google.gson.JsonElement output) throws IOException
    Throws:
      `IOException`

  - ### writeCompactOutput

    public void writeCompactOutput(com.google.gson.JsonElement output) throws IOException
    Description copied from interface: `DoipServerResponse`
    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.
    Specified by:
      `writeCompactOutput` in interface `DoipServerResponse`
    Parameters:
      `output` - the output JSON
    Throws:
      `IOException`

  - ### getOutput

    public OutDoipMessage getOutput() throws IOException
    Description copied from interface: `DoipServerResponse`
    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.
    Specified by:
      `getOutput` in interface `DoipServerResponse`
    Returns:
      an OutDoipMessage for writing output segments.
    Throws:
      `IOException`