Interface DataWriter

All Known Implementing Classes:
OctetDataWriter

public interface DataWriter
Output interface for creating binary messages out of data objects.

Top-level, only objects must be written. Therefore, the first call to a DataWriter must be beginObject().

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    beginArray(DataType type, int lenght)
    Starts writing an array value with entries of the given type.
    void
    Starts writing an object.
    void
    Stops writing the array started with the last call to beginObject().
    void
    Finishes writing the fields of the object started with the last call to beginObject().
    void
    name(int id)
    Writes an identifier of a field fo the currently written object.
    default void
    value(boolean value)
    Writes a boolean value.
    void
    value(byte[] value)
    Writes a binary string value.
    void
    value(double value)
    Writes a double value.
    void
    value(float value)
    Writes a float value.
    void
    value(int value)
    Writes an unsigned int value.
    void
    value(long value)
    Writes an unsigned long value.
    void
    value(String value)
    Writes a String value in utf-8 encoding.
    Starts writing a binary value of arbitrary length in chunked mode.
    void
    valueFixed(int value)
    Writes a fixed size 32 bit int value.
    void
    valueFixed(long value)
    Writes a fixed size 64 bit long value.
    void
    valueSigned(int value)
    Writes a signed int value.
    void
    valueSigned(long value)
    Writes a signed long value.
  • Method Details

    • beginObject

      void beginObject() throws IOException
      Starts writing an object.

      A sequence of interleaving calls to name(int) and a value encoding method such as value(int) is expected followed by a final endObject() call.

      Throws:
      IOException - If writing fails.
    • endObject

      void endObject() throws IOException
      Finishes writing the fields of the object started with the last call to beginObject().
      Throws:
      IOException - If writing fails.
    • name

      void name(int id) throws IOException
      Writes an identifier of a field fo the currently written object.
      Throws:
      IOException - If writing fails.
    • value

      default void value(boolean value) throws IOException
      Writes a boolean value.
      Throws:
      IOException - If writing fails.
    • value

      void value(int value) throws IOException
      Writes an unsigned int value.
      Throws:
      IOException - If writing fails.
    • valueSigned

      void valueSigned(int value) throws IOException
      Writes a signed int value.
      Throws:
      IOException - If writing fails.
    • valueFixed

      void valueFixed(int value) throws IOException
      Writes a fixed size 32 bit int value.
      Throws:
      IOException - If writing fails.
    • value

      void value(long value) throws IOException
      Writes an unsigned long value.
      Throws:
      IOException - If writing fails.
    • valueSigned

      void valueSigned(long value) throws IOException
      Writes a signed long value.
      Throws:
      IOException - If writing fails.
    • valueFixed

      void valueFixed(long value) throws IOException
      Writes a fixed size 64 bit long value.
      Throws:
      IOException - If writing fails.
    • value

      void value(float value) throws IOException
      Writes a float value.
      Throws:
      IOException - If writing fails.
    • value

      void value(double value) throws IOException
      Writes a double value.
      Throws:
      IOException - If writing fails.
    • value

      void value(String value) throws IOException
      Writes a String value in utf-8 encoding.
      Throws:
      IOException - If writing fails.
    • value

      void value(byte[] value) throws IOException
      Writes a binary string value.
      Throws:
      IOException - If writing fails.
    • valueBinaryStream

      OutputStream valueBinaryStream() throws IOException
      Starts writing a binary value of arbitrary length in chunked mode.

      The binary contents must be written the the resulting OutputStream. No other methods of this DataWriter must be called before the resulting OutputStream has been closed.

      Throws:
      IOException - If writing fails.
    • beginArray

      void beginArray(DataType type, int lenght) throws IOException
      Starts writing an array value with entries of the given type.
      Parameters:
      type - The type of the array elements.
      lenght - The number of elements that follow.
      Throws:
      IOException - If writing fails.
    • endArray

      void endArray() throws IOException
      Stops writing the array started with the last call to beginObject().
      Throws:
      IOException - If writing fails.