Class BinaryWire.Cursor

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

public static final class BinaryWire.Cursor extends Object
Unchecked cursor for validated embedded values whose public API does not expose I/O failures.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Cursor(byte[] bytes, int offset, int length, int maximumSize)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Returns the backing array without copying it; the cursor's position and limit determine the readable region.
    int
    Returns the current absolute offset in the backing array.
    int
    Reads a big-endian 32-bit integer and advances the cursor, rejecting truncated input.
    int
    readSize(int maximum, String label)
    Reads a non-negative size bounded by maximum; invalid values throw IllegalArgumentException with the supplied label.
    readString(int maximum)
    Reads a length-prefixed UTF-8 string bounded by maximum bytes.
    boolean
    readStringEquals(String value, int maximum)
    Consumes a bounded, length-prefixed string and compares its encoded bytes with the supplied value without decoding a new string.
    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.
    int
    Returns the number of bytes remaining before the cursor's limit.
    void
    Requires the cursor to be at its limit; trailing bytes cause IllegalArgumentException.
    void
    skip(int length)
    Advances by the specified number of bytes, rejecting negative lengths or truncated input.
    void
    skipString(int maximum)
    Skips a length-prefixed string after validating its byte length against maximum and the available input.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public int readSize(int maximum, String label)
      Reads a non-negative size bounded by maximum; invalid values throw IllegalArgumentException with 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

      public String readString(int maximum)
      Reads a length-prefixed UTF-8 string bounded by maximum bytes. Negative lengths and truncated input are rejected.
    • readStringEquals

      public boolean readStringEquals(String value, int maximum)
      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 against maximum and 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 cause IllegalArgumentException.