Class MessagePackIO.Writer
java.lang.Object
io.fluxzero.common.serialization.MessagePackIO.Writer
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
MessagePackIO
A reusable heap-array writer. Returned byte arrays are independent snapshots.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddPayload(byte[] bytes) Appends unframed bytes, retaining large arrays until clear/close.voidclear()Resets the writer and releases completed chunks, retaining only its current small buffer.voidclose()intReturns written bytes, for bounding writer pools after serialization.packArrayHeader(int size) Writes an array header; callers write its elements separately.packBinaryHeader(int size) Writes a binary header; callers write its payload separately.packBoolean(boolean value) Writes a boolean.packByte(byte value) Writes a Java byte in its smallest MessagePack representation.packInt(int value) Writes a Java integer in its smallest MessagePack representation.packLong(long value) Writes the smallest signed or unsigned integer representation of a Java long.packNil()Writes nil.packString(String value) Writes UTF-8, replacing malformed UTF-16 with '?'byte[]Returns an independent copy of all bytes written since the last clear.writePayload(byte[] bytes) Copies unframed payload bytes into this writer.
-
Constructor Details
-
Writer
public Writer()
-
-
Method Details
-
packLong
Writes the smallest signed or unsigned integer representation of a Java long. -
packInt
Writes a Java integer in its smallest MessagePack representation. -
packByte
Writes a Java byte in its smallest MessagePack representation. -
packNil
Writes nil. -
packBoolean
Writes a boolean. -
packString
Writes UTF-8, replacing malformed UTF-16 with '?' like the previous writer. -
packArrayHeader
Writes an array header; callers write its elements separately. -
packBinaryHeader
Writes a binary header; callers write its payload separately. -
writePayload
Copies unframed payload bytes into this writer. -
addPayload
Appends unframed bytes, retaining large arrays until clear/close. Callers must not mutate the array before taking the output snapshot. This preserves the historical large-payload copy boundary. -
toByteArray
public byte[] toByteArray()Returns an independent copy of all bytes written since the last clear. -
getBufferSize
public int getBufferSize()Returns written bytes, for bounding writer pools after serialization. -
clear
public void clear()Resets the writer and releases completed chunks, retaining only its current small buffer. -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-