Class BinaryWire.Writer
java.lang.Object
io.fluxzero.common.api.internal.BinaryWire.Writer
- Enclosing class:
BinaryWire
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]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 throwsIllegalStateExceptionfor a size mismatch.voidwriteBoolean(boolean value) Appends a boolean as one byte: zero for false and one for true.voidwriteByte(int value) Appends the low eight bits of the value to the output.voidwriteBytes(byte[] value) Appends a byte array prefixed by its length, using a length of -1 for null.voidwriteBytes(byte[] value, int offset, int length) Appends the selected byte region prefixed by its length.voidwriteEnvelope(SerializedMessage message) Appends a binary message envelope prefixed by its encoded byte length.voidwriteInt(int value) Appends a big-endian 32-bit integer.voidwriteLong(long value) Appends a big-endian 64-bit integer.voidwriteLongs(long[] values) Appends an element count followed by big-endian 64-bit values, using a count of -1 for null.voidwriteNullableInt(Integer value) Appends a presence flag followed by a 32-bit integer when the value is non-null.voidwriteNullableLong(Long value) Appends a presence flag followed by a 64-bit integer when the value is non-null.voidwriteRaw(byte[] value) Appends the entire byte array without a length prefix.voidwriteRaw(byte[] value, int offset, int length) Appends the selected byte region without a length prefix.voidwriteString(String value) Appends a UTF-8 string prefixed by its byte length, using a length of -1 for null.
-
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
Appends a presence flag followed by a 32-bit integer when the value is non-null. -
writeNullableLong
Appends a presence flag followed by a 64-bit integer when the value is non-null. -
writeString
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
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 throwsIllegalStateExceptionfor a size mismatch.
-