Package net.dona.doip.client.transport

## Class DoipClientResponse

- java.lang.Object
- - net.dona.doip.client.transport.DoipClientResponse

- All Implemented Interfaces:
    `java.lang.AutoCloseable`

      public class DoipClientResponse
      extends java.lang.Object
      implements java.lang.AutoCloseable

  A response from a server to the client.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DoipClientResponse​(DoipResponseHeaders initialSegment, InDoipMessage in)` | Constructs the response with the given initial segment, and further segments to be read from the supplied `InDoipMessage`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `close()` | Closes the response "output" and runs a callback if one was specified using `setOnClose(Runnable)`.
    `com.google.gson.JsonElement` | `getAttribute​(java.lang.String key)` | Returns a specified attribute from the initial segment of the response.
    `java.lang.String` | `getAttributeAsString​(java.lang.String key)` | Returns a specified attribute from the initial segment of the response, as a String.
    `com.google.gson.JsonObject` | `getAttributes()` | Returns the attributes from the initial segment of the response.
    `InDoipMessage` | `getOutput()` | Returns the "output" of the response as an `InDoipMessage` for the client to read from.
    `java.lang.String` | `getStatus()` | Returns the status code from the initial segment of the response.
    `void` | `setOnClose​(java.lang.Runnable onClose)` | Sets a callback which will be run after closing the response.

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

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

- - ### Constructor Detail

    - #### DoipClientResponse

          public DoipClientResponse​(DoipResponseHeaders initialSegment,
                                    InDoipMessage in)

      Constructs the response with the given initial segment, and further segments to be read from the supplied `InDoipMessage`.
      Parameters:
        `initialSegment` - the contents of the initial segment of the response
        `in` - further segments fo the response

  - ### Method Detail

    - #### setOnClose

          public void setOnClose​(java.lang.Runnable onClose)

      Sets a callback which will be run after closing the response.
      Parameters:
        `onClose` - the callback to be run after closing the response

    - #### getStatus

          public java.lang.String getStatus()

      Returns the status code from the initial segment of the response.
      Returns:
        the status code from the initial segment of the response

    - #### getAttributes

          public com.google.gson.JsonObject getAttributes()

      Returns the attributes from the initial segment of the response.
      Returns:
        the attributes from the initial segment of the response

    - #### getAttribute

          public com.google.gson.JsonElement getAttribute​(java.lang.String key)

      Returns a specified attribute from the initial segment of the response.
      Parameters:
        `key` - the property name of the attribute to retrieve
      Returns:
        the value of the specified attribute

    - #### getAttributeAsString

          public java.lang.String getAttributeAsString​(java.lang.String key)

      Returns a specified attribute from the initial segment of the response, as a String.
      Parameters:
        `key` - the property name of the attribute to retrieve
      Returns:
        the value as a String of the specified attribute

    - #### getOutput

          public InDoipMessage getOutput()

      Returns the "output" of the response as an `InDoipMessage` for the client to read from. This can either be a single JSON segment, in the case of a "compact" response fully contained in the initial segment, or in general it can be all segments following the initial segment.
      Returns:

    - #### close

          public void close()
                     throws java.lang.Exception

      Closes the response "output" and runs a callback if one was specified using `setOnClose(Runnable)`.
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Throws:
        `java.lang.Exception`