Interface BinaryWriter
- All Known Implementing Classes:
SegmentBinaryWriter
public interface BinaryWriter
An interface for writing binary data sequentially to an underlying sink. This provides a
high-level, fluent abstraction for zero-copy encoding operations.
-
Method Summary
Modifier and TypeMethodDescriptionlongposition()Gets the current write offset in bytes.voidposition(long newPosition) Sets the current write offset in bytes.longGets the number of remaining writable bytes.skip(long bytesToSkip) Advances the writer's position by the given number of bytes.writeBoolean(boolean value) writeByte(byte value) writeBytes(byte[] value) writeDoubleBE(double value) writeDoubleLE(double value) writeFloatBE(float value) writeFloatLE(float value) writeIntBE(int value) writeIntLE(int value) writeLongBE(long value) writeLongLE(long value) writeNullableBoolean(Boolean value) writeNullableByte(Byte value) writeNullableBytes(byte[] value) writeNullableDoubleBE(Double value) writeNullableDoubleLE(Double value) writeNullableFloatBE(Float value) writeNullableFloatLE(Float value) writeNullableIntBE(Integer value) writeNullableIntLE(Integer value) writeNullableLongBE(Long value) writeNullableLongLE(Long value) writeNullableShortBE(Short value) writeNullableString(String value, MemorySegment scratchBuffer) writeSegment(MemorySegment source) Writes all bytes from the source MemorySegment to this writer's underlying sink.writeSegmentRaw(MemorySegment source, long offset, long length) Writes raw bytes from the source MemorySegment without a length prefix.writeShortBE(short value) writeShortLE(short value) writeString(String value, MemorySegment scratchBuffer) writeVarInt(int value) Writes a 32-bit integer in a variable-length format.writeVarLong(long value) Writes a 64-bit integer in a variable-length format.
-
Method Details
-
position
long position()Gets the current write offset in bytes. -
position
void position(long newPosition) Sets the current write offset in bytes. -
remaining
long remaining()Gets the number of remaining writable bytes. -
writeByte
-
writeShortBE
-
writeIntBE
-
writeLongBE
-
writeFloatBE
-
writeDoubleBE
-
writeBoolean
-
writeShortLE
-
writeIntLE
-
writeLongLE
-
writeFloatLE
-
writeDoubleLE
-
writeVarInt
Writes a 32-bit integer in a variable-length format. -
writeVarLong
Writes a 64-bit integer in a variable-length format. -
writeString
-
writeBytes
-
writeNullableByte
-
writeNullableShortBE
-
writeNullableIntBE
-
writeNullableIntLE
-
writeNullableFloatBE
-
writeNullableFloatLE
-
writeNullableDoubleBE
-
writeNullableDoubleLE
-
writeNullableBoolean
-
writeNullableLongLE
-
writeNullableLongBE
-
writeNullableString
-
writeNullableBytes
-
writeSegment
Writes all bytes from the source MemorySegment to this writer's underlying sink.- Parameters:
source- The MemorySegment to read from.- Returns:
- This writer instance for chaining.
-
writeSegmentRaw
Writes raw bytes from the source MemorySegment without a length prefix. This is useful when the length is already known or stored elsewhere.- Parameters:
source- The MemorySegment to copy from.offset- Starting offset in the source segment.length- Number of bytes to copy.- Returns:
- This writer instance for chaining.
-
skip
Advances the writer's position by the given number of bytes.- Parameters:
bytesToSkip- The number of bytes to skip.- Returns:
- This writer instance, for chaining.
-