Class Writer

java.lang.Object
org.symbol.sdk.utils.Writer

public final class Writer extends Object
Writer

Position-tracking writer over a little-endian ByteBuffer; the underlying byte array is exposed via storage() for callers that need to hand off the raw buffer.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Writer(int size)
    Creates a writer with specified size.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the current write offset (number of bytes written so far); derived from the buffer position, so it can never drift.
    byte[]
    Returns the underlying storage.
    void
    write(byte[] data)
    Writes array into buffer.
    void
    writeInt(long value, int size)
    Writes a little-endian integer into the buffer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 ByteBuffer writes 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).