Class MessagePackIO.Reader

java.lang.Object
io.fluxzero.common.serialization.MessagePackIO.Reader
All Implemented Interfaces:
AutoCloseable
Enclosing class:
MessagePackIO

public static final class MessagePackIO.Reader extends Object implements AutoCloseable
A reusable, zero-copy reader of one heap-array range. Closing releases the referenced array.
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    void
     
    boolean
    Indicates whether this range still contains bytes.
    int
    Returns the absolute offset of the next unread byte in the input array.
    byte[]
    readPayload(int length)
    Copies exactly length unframed bytes, checking the input range before allocating.
    reset(byte[] bytes, int offset, int length)
    Replaces the input without copying or retaining the previous array.
    boolean
    Consumes nil when present, otherwise leaves the input unchanged.
    int
    Reads an array header, rejecting counts outside the Java collection size range.
    int
    Reads a binary or string header, matching historical MessagePack reader defaults.
    boolean
    Reads a boolean.
    byte
    Reads an integer, rejecting values outside the Java byte range.
    int
    Reads an integer, rejecting values outside the Java int range.
    long
    Reads any MessagePack integer representable as a Java long.
    Reads UTF-8, retaining the previous reader's malformed-input replacement and binary acceptance.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Reader

      public Reader(byte[] bytes)
    • Reader

      public Reader(byte[] bytes, int offset, int length)
  • Method Details

    • reset

      public MessagePackIO.Reader reset(byte[] bytes, int offset, int length)
      Replaces the input without copying or retaining the previous array.
    • position

      public int position()
      Returns the absolute offset of the next unread byte in the input array.
    • hasNext

      public boolean hasNext()
      Indicates whether this range still contains bytes.
    • tryUnpackNil

      public boolean tryUnpackNil() throws IOException
      Consumes nil when present, otherwise leaves the input unchanged.
      Throws:
      IOException
    • unpackLong

      public long unpackLong() throws IOException
      Reads any MessagePack integer representable as a Java long.
      Throws:
      IOException
    • unpackInt

      public int unpackInt() throws IOException
      Reads an integer, rejecting values outside the Java int range.
      Throws:
      IOException
    • unpackByte

      public byte unpackByte() throws IOException
      Reads an integer, rejecting values outside the Java byte range.
      Throws:
      IOException
    • unpackBoolean

      public boolean unpackBoolean() throws IOException
      Reads a boolean.
      Throws:
      IOException
    • unpackString

      public String unpackString() throws IOException
      Reads UTF-8, retaining the previous reader's malformed-input replacement and binary acceptance.
      Throws:
      IOException
    • unpackArrayHeader

      public int unpackArrayHeader() throws IOException
      Reads an array header, rejecting counts outside the Java collection size range.
      Throws:
      IOException
    • unpackBinaryHeader

      public int unpackBinaryHeader() throws IOException
      Reads a binary or string header, matching historical MessagePack reader defaults.
      Throws:
      IOException
    • readPayload

      public byte[] readPayload(int length) throws IOException
      Copies exactly length unframed bytes, checking the input range before allocating.
      Throws:
      IOException
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable