Class BinaryWire.Reader

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

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

    Constructors
    Constructor
    Description
    Reader(byte[] bytes, int maximumValueSize)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the number of unread bytes within this reader's limit.
    byte[]
    Returns the backing array without copying it; the reader's position and limit delimit the readable region.
    int
    Returns the current absolute offset in the backing array.
    boolean
    Reads a boolean encoded as zero or one; other values and truncated input cause IOException.
    byte
    Reads one signed byte and advances, throwing EOFException if 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.
    int
    Reads a big-endian 32-bit integer, throwing EOFException on truncated input.
    long
    Reads a big-endian 64-bit integer, throwing EOFException on truncated input.
    long[]
    readLongs(int maximumElements)
    Reads a nullable array of big-endian 64-bit values, enforcing maximumElements before 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.
    int
    readSize(int maximum, String label)
    Reads a non-negative size no greater than maximum; invalid values cause IOException with the supplied label.
    Reads a length-prefixed UTF-8 string, accepting -1 as null and enforcing the configured maximum value size.
    int
    Reads one byte as an unsigned integer from 0 through 255.
    void
    require(int length)
    Checks that the specified number of bytes is available without advancing; negative lengths and insufficient input cause EOFException.
    void
    skip(int length)
    Advances by the specified number of bytes, throwing EOFException for a negative length or truncated input.

    Methods inherited from class Object

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

      public byte readByte() throws EOFException
      Reads one signed byte and advances, throwing EOFException if no byte remains.
      Throws:
      EOFException
    • readUnsignedByte

      public int readUnsignedByte() throws EOFException
      Reads one byte as an unsigned integer from 0 through 255.
      Throws:
      EOFException
    • readBoolean

      public boolean readBoolean() throws IOException
      Reads a boolean encoded as zero or one; other values and truncated input cause IOException.
      Throws:
      IOException
    • readInt

      public int readInt() throws EOFException
      Reads a big-endian 32-bit integer, throwing EOFException on truncated input.
      Throws:
      EOFException
    • readLong

      public long readLong() throws EOFException
      Reads a big-endian 64-bit integer, throwing EOFException on truncated input.
      Throws:
      EOFException
    • readNullableInt

      public Integer readNullableInt() throws IOException
      Reads a presence flag and, when present, a big-endian 32-bit integer; returns null for an absent value.
      Throws:
      IOException
    • readNullableLong

      public Long readNullableLong() throws IOException
      Reads a presence flag and, when present, a big-endian 64-bit integer; returns null for an absent value.
      Throws:
      IOException
    • readString

      public String readString() throws IOException
      Reads a length-prefixed UTF-8 string, accepting -1 as null and enforcing the configured maximum value size.
      Throws:
      IOException
    • readBytes

      public byte[] readBytes() throws IOException
      Reads a length-prefixed byte array, accepting -1 as null and enforcing the configured maximum value size.
      Throws:
      IOException
    • readLongs

      public long[] readLongs(int maximumElements) throws IOException
      Reads a nullable array of big-endian 64-bit values, enforcing maximumElements before allocation.
      Throws:
      IOException
    • readEnvelope

      public SerializedMessage readEnvelope() throws IOException
      Reads and validates a length-prefixed message envelope and returns a message backed by the input array. Invalid envelope sizes, components, or truncated input cause IOException.
      Throws:
      IOException
    • readSize

      public int readSize(int maximum, String label) throws IOException
      Reads a non-negative size no greater than maximum; invalid values cause IOException with the supplied label.
      Throws:
      IOException
    • skip

      public void skip(int length) throws EOFException
      Advances by the specified number of bytes, throwing EOFException for a negative length or truncated input.
      Throws:
      EOFException
    • require

      public void require(int length) throws EOFException
      Checks that the specified number of bytes is available without advancing; negative lengths and insufficient input cause EOFException.
      Throws:
      EOFException