Package org.symbol.sdk.utils
Class Writer
java.lang.Object
org.symbol.sdk.utils.Writer
- Writer
- Position-tracking writer over a little-endian
ByteBuffer; the underlying byte array is exposed viastorage()for callers that need to hand off the raw buffer.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintoffset()Returns the current write offset (number of bytes written so far); derived from the buffer position, so it can never drift.byte[]storage()Returns the underlying storage.voidwrite(byte[] data) Writes array into buffer.voidwriteInt(long value, int size) Writes a little-endian integer into the buffer.
-
Constructor Details
-
Writer
public Writer(int size) Creates a writer with specified size.- Parameters:
size- Allocated buffer size.
-
-
Method Details
-
storage
public byte[] storage()- Writer.storage
- Returns the underlying storage. This is the live backing array (the same one the
ByteBufferwrites into), not a defensive copy, so callers must not mutate it while the writer is in use — it is exposed to hand off the raw buffer without copying.
- Returns:
- Backing byte array (aliased, not copied).
-
offset
public int offset()- Writer.offset
- Returns the current write offset (number of bytes written so far); derived from the buffer position, so it can never drift.
- Returns:
- Current write offset.
-
write
public void write(byte[] data) - Writer.write
- Writes array into buffer.
- Parameters:
data- Data to write.
-
writeInt
public void writeInt(long value, int size) - Writer.writeInt
- Writes a little-endian integer into the buffer.
- Parameters:
value- Value to write.size- Byte width (1, 2, 4 or 8).
-