Class BinaryWire.Cursor
java.lang.Object
io.fluxzero.common.api.internal.BinaryWire.Cursor
- Enclosing class:
BinaryWire
Unchecked cursor for validated embedded values whose public API does not expose I/O failures.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]bytes()Returns the backing array without copying it; the cursor's position and limit determine the readable region.intposition()Returns the current absolute offset in the backing array.intreadInt()Reads a big-endian 32-bit integer and advances the cursor, rejecting truncated input.intReads a non-negative size bounded bymaximum; invalid values throwIllegalArgumentExceptionwith the supplied label.readString(int maximum) Reads a length-prefixed UTF-8 string bounded bymaximumbytes.booleanreadStringEquals(String value, int maximum) Consumes a bounded, length-prefixed string and compares its encoded bytes with the supplied value without decoding a new string.intreadStringLength(int maximum) Reads and validates a non-negative string byte length and verifies that its bytes are available, without consuming the string bytes.intReturns the number of bytes remaining before the cursor's limit.voidRequires the cursor to be at its limit; trailing bytes causeIllegalArgumentException.voidskip(int length) Advances by the specified number of bytes, rejecting negative lengths or truncated input.voidskipString(int maximum) Skips a length-prefixed string after validating its byte length againstmaximumand the available input.
-
Constructor Details
-
Cursor
public Cursor(byte[] bytes, int offset, int length, int maximumSize)
-
-
Method Details
-
bytes
public byte[] bytes()Returns the backing array without copying it; the cursor's position and limit determine the readable region. -
position
public int position()Returns the current absolute offset in the backing array. -
remaining
public int remaining()Returns the number of bytes remaining before the cursor's limit. -
readInt
public int readInt()Reads a big-endian 32-bit integer and advances the cursor, rejecting truncated input. -
readSize
Reads a non-negative size bounded bymaximum; invalid values throwIllegalArgumentExceptionwith the supplied label. -
readStringLength
public int readStringLength(int maximum) Reads and validates a non-negative string byte length and verifies that its bytes are available, without consuming the string bytes. -
readString
Reads a length-prefixed UTF-8 string bounded bymaximumbytes. Negative lengths and truncated input are rejected. -
readStringEquals
Consumes a bounded, length-prefixed string and compares its encoded bytes with the supplied value without decoding a new string. -
skipString
public void skipString(int maximum) Skips a length-prefixed string after validating its byte length againstmaximumand the available input. -
skip
public void skip(int length) Advances by the specified number of bytes, rejecting negative lengths or truncated input. -
requireComplete
public void requireComplete()Requires the cursor to be at its limit; trailing bytes causeIllegalArgumentException.
-