com.dyuproject.protostuff
Class WriteSession

java.lang.Object
  extended by com.dyuproject.protostuff.WriteSession

public class WriteSession
extends java.lang.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.

Author:
David Yu
Date created:
Sep 20, 2010

Field Summary
 LinkedBuffer head
          The main/root/head buffer of this write session.
 int nextBufferSize
          The next buffer size used when growing the buffer.
 java.io.OutputStream out
          The sink of this buffer.
 WriteSink sink
          The sink of this write session.
protected  int size
          The actual number of bytes written to the buffer.
protected  LinkedBuffer tail
          The last buffer of this write session (This points to head if growing not needed).
 
Constructor Summary
WriteSession(LinkedBuffer head)
           
WriteSession(LinkedBuffer head, int nextBufferSize)
           
WriteSession(LinkedBuffer head, java.io.OutputStream out)
           
 
Method Summary
 WriteSession clear()
          The buffer will be cleared (tail will point to the head) and the size will be reset to zero.
 int getSize()
          Returns the amount of bytes written in this session.
 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.

Constructor Detail

WriteSession

public WriteSession(LinkedBuffer head)

WriteSession

public WriteSession(LinkedBuffer head,
                    int nextBufferSize)

WriteSession

public WriteSession(LinkedBuffer head,
                    java.io.OutputStream out)
Method Detail

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).



Copyright © 2009-2014. All Rights Reserved.