Package io.protostuff

Class WriteSession

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      WriteSession clear()
      The buffer will be cleared (tail will point to the head) and the size will be reset to zero.
      protected int flush​(byte[] buf, int offset, int len)  
      protected int flush​(byte[] buf, int offset, int len, byte[] next, int nextoffset, int nextlen)  
      protected int flush​(LinkedBuffer lb, byte[] buf, int offset, int len)  
      int getSize()
      Returns the amount of bytes written in this session.
      void reset()
      Resets this session for re-use.
      byte[] toByteArray()
      Returns a single byte array containg all the contents written to the buffer(s).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • head

        public final LinkedBuffer head
        The main/root/head buffer of this write session.
      • 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 java.io.OutputStream out
        The sink of this buffer.
      • sink

        public final WriteSink sink
        The sink of this write session.
    • Method Detail

      • 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 java.io.IOException
        Throws:
        java.io.IOException
      • flush

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

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