Class BinaryWire.Writer

java.lang.Object
io.fluxzero.common.api.internal.BinaryWire.Writer
Enclosing class:
BinaryWire

public static final class BinaryWire.Writer extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
    Writer(int initialSize, int maximumSize)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Returns exactly the written bytes, reusing the backing array when it is completely filled and copying otherwise.
    byte[]
    Returns the backing array only if it has been filled exactly; otherwise throws IllegalStateException for a size mismatch.
    void
    writeBoolean(boolean value)
    Appends a boolean as one byte: zero for false and one for true.
    void
    writeByte(int value)
    Appends the low eight bits of the value to the output.
    void
    writeBytes(byte[] value)
    Appends a byte array prefixed by its length, using a length of -1 for null.
    void
    writeBytes(byte[] value, int offset, int length)
    Appends the selected byte region prefixed by its length.
    void
    Appends a binary message envelope prefixed by its encoded byte length.
    void
    writeInt(int value)
    Appends a big-endian 32-bit integer.
    void
    writeLong(long value)
    Appends a big-endian 64-bit integer.
    void
    writeLongs(long[] values)
    Appends an element count followed by big-endian 64-bit values, using a count of -1 for null.
    void
    Appends a presence flag followed by a 32-bit integer when the value is non-null.
    void
    Appends a presence flag followed by a 64-bit integer when the value is non-null.
    void
    writeRaw(byte[] value)
    Appends the entire byte array without a length prefix.
    void
    writeRaw(byte[] value, int offset, int length)
    Appends the selected byte region without a length prefix.
    void
    Appends a UTF-8 string prefixed by its byte length, using a length of -1 for null.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Writer

      public Writer(int initialSize, int maximumSize)
  • Method Details

    • writeByte

      public void writeByte(int value)
      Appends the low eight bits of the value to the output.
    • writeBoolean

      public void writeBoolean(boolean value)
      Appends a boolean as one byte: zero for false and one for true.
    • writeInt

      public void writeInt(int value)
      Appends a big-endian 32-bit integer.
    • writeLong

      public void writeLong(long value)
      Appends a big-endian 64-bit integer.
    • writeNullableInt

      public void writeNullableInt(Integer value)
      Appends a presence flag followed by a 32-bit integer when the value is non-null.
    • writeNullableLong

      public void writeNullableLong(Long value)
      Appends a presence flag followed by a 64-bit integer when the value is non-null.
    • writeString

      public void writeString(String value)
      Appends a UTF-8 string prefixed by its byte length, using a length of -1 for null.
    • writeBytes

      public void writeBytes(byte[] value)
      Appends a byte array prefixed by its length, using a length of -1 for null.
    • writeBytes

      public void writeBytes(byte[] value, int offset, int length)
      Appends the selected byte region prefixed by its length.
    • writeRaw

      public void writeRaw(byte[] value)
      Appends the entire byte array without a length prefix.
    • writeRaw

      public void writeRaw(byte[] value, int offset, int length)
      Appends the selected byte region without a length prefix.
    • writeLongs

      public void writeLongs(long[] values)
      Appends an element count followed by big-endian 64-bit values, using a count of -1 for null.
    • writeEnvelope

      public void writeEnvelope(SerializedMessage message)
      Appends a binary message envelope prefixed by its encoded byte length.
    • toByteArray

      public byte[] toByteArray()
      Returns exactly the written bytes, reusing the backing array when it is completely filled and copying otherwise.
    • toExactByteArray

      public byte[] toExactByteArray()
      Returns the backing array only if it has been filled exactly; otherwise throws IllegalStateException for a size mismatch.