Package net.dona.doip

## Class OutDoipMessageImpl

- java.lang.Object
- - net.dona.doip.OutDoipMessageImpl

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

      public class OutDoipMessageImpl
      extends java.lang.Object
      implements OutDoipMessage

  An implementation of `OutDoipMessage` which writes a serialized DOIP message into an `OutputStream`.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `OutDoipMessageImpl​(java.io.OutputStream out)` | Constructs an `OutDoipMessage` which will write a serialized DOIP message into the supplied `OutputStream`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `close()` |
    `void` | `closeSegmentOutput()` | Closes the particular segment currently being written, if any
    `java.io.OutputStream` | `getBytesOutputStream()` | Returns an `OutputStream` that can be used to write to a bytes segment.
    `java.io.Writer` | `getJsonWriter()` | Returns a `Writer` that can be used to write to a JSON segment.
    `void` | `writeBytes​(byte[] bytes)` | Writes a bytes segment into the outgoing message.
    `void` | `writeBytes​(java.io.InputStream in)` | Writes a bytes segment into the outgoing message.
    `void` | `writeJson​(byte[] json)` | Writes a JSON segment into the outgoing message.
    `void` | `writeJson​(com.google.gson.JsonElement json)` | Writes a JSON segment into the outgoing message.
    `void` | `writeJson​(java.lang.String json)` | Writes a JSON segment into the outgoing message.

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

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

- - ### Constructor Detail

    - #### OutDoipMessageImpl

          public OutDoipMessageImpl​(java.io.OutputStream out)

      Constructs an `OutDoipMessage` which will write a serialized DOIP message into the supplied `OutputStream`.
      Parameters:
        `out` - the stream into which to write the serialized DOIP message

  - ### Method Detail

    - #### writeJson

          public void writeJson​(com.google.gson.JsonElement json)
                         throws java.io.IOException

      Description copied from interface: `OutDoipMessage`
      Writes a JSON segment into the outgoing message.
      Specified by:
        `writeJson` in interface `OutDoipMessage`
      Parameters:
        `json` - the json to be written
      Throws:
        `java.io.IOException`

    - #### writeJson

          public void writeJson​(java.lang.String json)
                         throws java.io.IOException

      Description copied from interface: `OutDoipMessage`
      Writes a JSON segment into the outgoing message.
      Specified by:
        `writeJson` in interface `OutDoipMessage`
      Parameters:
        `json` - the json to be written
      Throws:
        `java.io.IOException`

    - #### writeJson

          public void writeJson​(byte[] json)
                         throws java.io.IOException

      Description copied from interface: `OutDoipMessage`
      Writes a JSON segment into the outgoing message.
      Specified by:
        `writeJson` in interface `OutDoipMessage`
      Parameters:
        `json` - the json to be written
      Throws:
        `java.io.IOException`

    - #### getJsonWriter

          public java.io.Writer getJsonWriter()

      Description copied from interface: `OutDoipMessage`
      Returns a `Writer` that can be used to write to a JSON segment.
      Specified by:
        `getJsonWriter` in interface `OutDoipMessage`
      Returns:
        a `Writer` that can be used to write to a JSON segment

    - #### writeBytes

          public void writeBytes​(byte[] bytes)
                          throws java.io.IOException

      Description copied from interface: `OutDoipMessage`
      Writes a bytes segment into the outgoing message.
      Specified by:
        `writeBytes` in interface `OutDoipMessage`
      Parameters:
        `bytes` - the bytes the be written
      Throws:
        `java.io.IOException`

    - #### writeBytes

          public void writeBytes​(java.io.InputStream in)
                          throws java.io.IOException

      Description copied from interface: `OutDoipMessage`
      Writes a bytes segment into the outgoing message.
      Specified by:
        `writeBytes` in interface `OutDoipMessage`
      Parameters:
        `in` - an input stream from which bytes will be read and written to the outgoing bytes segment
      Throws:
        `java.io.IOException`

    - #### getBytesOutputStream

          public java.io.OutputStream getBytesOutputStream()
                                                    throws java.io.IOException

      Description copied from interface: `OutDoipMessage`
      Returns an `OutputStream` that can be used to write to a bytes segment.
      Specified by:
        `getBytesOutputStream` in interface `OutDoipMessage`
      Returns:
        an `OutputStream` that can be used to write to a bytes segment
      Throws:
        `java.io.IOException`

    - #### closeSegmentOutput

          public void closeSegmentOutput()
                                  throws java.io.IOException

      Closes the particular segment currently being written, if any
      Throws:
        `java.io.IOException`

    - #### close

          public void close()
                     throws java.io.IOException

      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Specified by:
        `close` in interface `OutDoipMessage`
      Throws:
        `java.io.IOException`