Class BinaryWire.Reader
java.lang.Object
io.fluxzero.common.api.internal.BinaryWire.Reader
- Enclosing class:
BinaryWire
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the number of unread bytes within this reader's limit.byte[]bytes()Returns the backing array without copying it; the reader's position and limit delimit the readable region.intposition()Returns the current absolute offset in the backing array.booleanReads a boolean encoded as zero or one; other values and truncated input causeIOException.bytereadByte()Reads one signed byte and advances, throwingEOFExceptionif no byte remains.byte[]Reads a length-prefixed byte array, accepting -1 as null and enforcing the configured maximum value size.Reads and validates a length-prefixed message envelope and returns a message backed by the input array.intreadInt()Reads a big-endian 32-bit integer, throwingEOFExceptionon truncated input.longreadLong()Reads a big-endian 64-bit integer, throwingEOFExceptionon truncated input.long[]readLongs(int maximumElements) Reads a nullable array of big-endian 64-bit values, enforcingmaximumElementsbefore allocation.Reads a presence flag and, when present, a big-endian 32-bit integer; returns null for an absent value.Reads a presence flag and, when present, a big-endian 64-bit integer; returns null for an absent value.intReads a non-negative size no greater thanmaximum; invalid values causeIOExceptionwith the supplied label.Reads a length-prefixed UTF-8 string, accepting -1 as null and enforcing the configured maximum value size.intReads one byte as an unsigned integer from 0 through 255.voidrequire(int length) Checks that the specified number of bytes is available without advancing; negative lengths and insufficient input causeEOFException.voidskip(int length) Advances by the specified number of bytes, throwingEOFExceptionfor a negative length or truncated input.
-
Constructor Details
-
Reader
public Reader(byte[] bytes, int maximumValueSize)
-
-
Method Details
-
available
public int available()Returns the number of unread bytes within this reader's limit. -
position
public int position()Returns the current absolute offset in the backing array. -
bytes
public byte[] bytes()Returns the backing array without copying it; the reader's position and limit delimit the readable region. -
readByte
Reads one signed byte and advances, throwingEOFExceptionif no byte remains.- Throws:
EOFException
-
readUnsignedByte
Reads one byte as an unsigned integer from 0 through 255.- Throws:
EOFException
-
readBoolean
Reads a boolean encoded as zero or one; other values and truncated input causeIOException.- Throws:
IOException
-
readInt
Reads a big-endian 32-bit integer, throwingEOFExceptionon truncated input.- Throws:
EOFException
-
readLong
Reads a big-endian 64-bit integer, throwingEOFExceptionon truncated input.- Throws:
EOFException
-
readNullableInt
Reads a presence flag and, when present, a big-endian 32-bit integer; returns null for an absent value.- Throws:
IOException
-
readNullableLong
Reads a presence flag and, when present, a big-endian 64-bit integer; returns null for an absent value.- Throws:
IOException
-
readString
Reads a length-prefixed UTF-8 string, accepting -1 as null and enforcing the configured maximum value size.- Throws:
IOException
-
readBytes
Reads a length-prefixed byte array, accepting -1 as null and enforcing the configured maximum value size.- Throws:
IOException
-
readLongs
Reads a nullable array of big-endian 64-bit values, enforcingmaximumElementsbefore allocation.- Throws:
IOException
-
readEnvelope
Reads and validates a length-prefixed message envelope and returns a message backed by the input array. Invalid envelope sizes, components, or truncated input causeIOException.- Throws:
IOException
-
readSize
Reads a non-negative size no greater thanmaximum; invalid values causeIOExceptionwith the supplied label.- Throws:
IOException
-
skip
Advances by the specified number of bytes, throwingEOFExceptionfor a negative length or truncated input.- Throws:
EOFException
-
require
Checks that the specified number of bytes is available without advancing; negative lengths and insufficient input causeEOFException.- Throws:
EOFException
-