Class WriteSession
java.lang.Object
io.protostuff.WriteSession
- Direct Known Subclasses:
JsonXOutput, KvpOutput, ProtobufOutput, ProtostuffOutput, XmlXOutput, YamlOutput
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal LinkedBufferThe main/root/head buffer of this write session.final intThe next buffer size used when growing the buffer.final OutputStreamThe sink of this buffer.final WriteSinkThe sink of this write session.protected intThe actual number of bytes written to the buffer.protected LinkedBufferThe last buffer of this write session (This points to head if growing not needed). -
Constructor Summary
ConstructorsConstructorDescriptionWriteSession(LinkedBuffer head) WriteSession(LinkedBuffer head, int nextBufferSize) WriteSession(LinkedBuffer head, OutputStream out) WriteSession(LinkedBuffer head, OutputStream out, WriteSession.FlushHandler flushHandler, int nextBufferSize) -
Method Summary
Modifier and TypeMethodDescriptionclear()The buffer will be cleared (tail will point to the head) and the size will be reset to zero.protected intflush(byte[] buf, int offset, int len) protected intflush(byte[] buf, int offset, int len, byte[] next, int nextoffset, int nextlen) protected intflush(LinkedBuffer lb, byte[] buf, int offset, int len) final intgetSize()Returns the amount of bytes written in this session.voidreset()Resets this session for re-use.final byte[]Returns a single byte array containg all the contents written to the buffer(s).
-
Field Details
-
head
The main/root/head buffer of this write session. -
tail
The last buffer of this write session (This points to head if growing not needed). -
size
protected int sizeThe actual number of bytes written to the buffer. -
nextBufferSize
public final int nextBufferSizeThe next buffer size used when growing the buffer. -
out
The sink of this buffer. -
flushHandler
-
sink
The sink of this write session.
-
-
Constructor Details
-
WriteSession
-
WriteSession
-
WriteSession
public WriteSession(LinkedBuffer head, OutputStream out, WriteSession.FlushHandler flushHandler, int nextBufferSize) -
WriteSession
-
-
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
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
- Throws:
IOException
-
flush
protected int flush(byte[] buf, int offset, int len, byte[] next, int nextoffset, int nextlen) throws IOException - Throws:
IOException
-
flush
- Throws:
IOException
-