Package io.protostuff

Class WriteSession

java.lang.Object
io.protostuff.WriteSession
Direct Known Subclasses:
JsonXOutput, KvpOutput, ProtobufOutput, ProtostuffOutput, XmlXOutput, YamlOutput

public class WriteSession extends Object
Designed to be subclassed by implementations of Output for easier serialization code for streaming or full buffering. This is used when objects need to be serialzied/written into a LinkedBuffer.
  • Field Details

    • tail

      protected LinkedBuffer tail
      The last buffer of this write session (This points to head if growing not needed).
    • size

      protected int size
      The actual number of bytes written to the buffer.
    • nextBufferSize

      public final int nextBufferSize
      The next buffer size used when growing the buffer.
    • out

      public final OutputStream out
      The sink of this buffer.
    • flushHandler

      public final WriteSession.FlushHandler flushHandler
    • sink

      public final WriteSink sink
      The sink of this write session.
  • Constructor Details

  • Method Details

    • reset

      public void reset()
      Resets this session for re-use. Meant to be overridden by subclasses that have other state to reset.
    • clear

      public WriteSession clear()
      The buffer will be cleared (tail will point to the head) and the size will be reset to zero.
    • getSize

      public final int getSize()
      Returns the amount of bytes written in this session.
    • toByteArray

      public final byte[] toByteArray()
      Returns a single byte array containg all the contents written to the buffer(s).
    • flush

      protected int flush(byte[] buf, int offset, int len) throws IOException
      Throws:
      IOException
    • flush

      protected int flush(byte[] buf, int offset, int len, byte[] next, int nextoffset, int nextlen) throws IOException
      Throws:
      IOException
    • flush

      protected int flush(LinkedBuffer lb, byte[] buf, int offset, int len) throws IOException
      Throws:
      IOException