Class MessagePackIO.Reader
java.lang.Object
io.fluxzero.common.serialization.MessagePackIO.Reader
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
MessagePackIO
A reusable, zero-copy reader of one heap-array range. Closing releases the referenced array.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanhasNext()Indicates whether this range still contains bytes.intposition()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.booleanConsumes nil when present, otherwise leaves the input unchanged.intReads an array header, rejecting counts outside the Java collection size range.intReads a binary or string header, matching historical MessagePack reader defaults.booleanReads a boolean.byteReads an integer, rejecting values outside the Java byte range.intReads an integer, rejecting values outside the Java int range.longReads any MessagePack integer representable as a Java long.Reads UTF-8, retaining the previous reader's malformed-input replacement and binary acceptance.
-
Constructor Details
-
Reader
public Reader(byte[] bytes) -
Reader
public Reader(byte[] bytes, int offset, int length)
-
-
Method Details
-
reset
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
Consumes nil when present, otherwise leaves the input unchanged.- Throws:
IOException
-
unpackLong
Reads any MessagePack integer representable as a Java long.- Throws:
IOException
-
unpackInt
Reads an integer, rejecting values outside the Java int range.- Throws:
IOException
-
unpackByte
Reads an integer, rejecting values outside the Java byte range.- Throws:
IOException
-
unpackBoolean
-
unpackString
Reads UTF-8, retaining the previous reader's malformed-input replacement and binary acceptance.- Throws:
IOException
-
unpackArrayHeader
Reads an array header, rejecting counts outside the Java collection size range.- Throws:
IOException
-
unpackBinaryHeader
Reads a binary or string header, matching historical MessagePack reader defaults.- Throws:
IOException
-
readPayload
Copies exactly length unframed bytes, checking the input range before allocating.- Throws:
IOException
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-