Package net.dona.doip

# Class OutDoipMessageImpl

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

All Implemented Interfaces:
  `AutoCloseable`, `OutDoipMessage`

public class OutDoipMessageImpl extends Object implements OutDoipMessage
An implementation of `OutDoipMessage` which writes a serialized DOIP message into an `OutputStream`.

- ## Constructor Summary

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

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  `void`
  `closeSegmentOutput()`
  Closes the particular segment currently being written, if any
  `OutputStream`
  `getBytesOutputStream()`
  Returns an `OutputStream` that can be used to write to a bytes segment.
  `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(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(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 Details

  - ### OutDoipMessageImpl

    public OutDoipMessageImpl(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 Details

  - ### writeJson

    public void writeJson(com.google.gson.JsonElement json) throws 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:
      `IOException`

  - ### writeJson

    public void writeJson(String json) throws 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:
      `IOException`

  - ### writeJson

    public void writeJson(byte[] json) throws 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:
      `IOException`

  - ### getJsonWriter

    public 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

  - ### writeBytes

    public void writeBytes(byte[] bytes) throws 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:
      `IOException`

  - ### writeBytes

    public void writeBytes(InputStream in) throws 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:
      `IOException`

  - ### getBytesOutputStream

    public OutputStream getBytesOutputStream() throws 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:
      `IOException`

  - ### closeSegmentOutput

    public void closeSegmentOutput() throws IOException
    Closes the particular segment currently being written, if any
    Throws:
      `IOException`

  - ### close

    public void close() throws IOException
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `OutDoipMessage`
    Throws:
      `IOException`