public class WriteSession
extends java.lang.Object
Output for easier serialization
code for streaming or full buffering.
This is used when objects need to be serialzied/written into a LinkedBuffer.| Modifier and Type | Class and Description |
|---|---|
static interface |
WriteSession.FlushHandler |
| Modifier and Type | Field and Description |
|---|---|
WriteSession.FlushHandler |
flushHandler |
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 and Description |
|---|
WriteSession(LinkedBuffer head) |
WriteSession(LinkedBuffer head,
int nextBufferSize) |
WriteSession(LinkedBuffer head,
java.io.OutputStream out) |
WriteSession(LinkedBuffer head,
java.io.OutputStream out,
WriteSession.FlushHandler flushHandler,
int nextBufferSize) |
| Modifier and Type | Method and 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).
|
public final LinkedBuffer head
protected LinkedBuffer tail
protected int size
public final int nextBufferSize
public final java.io.OutputStream out
public final WriteSession.FlushHandler flushHandler
public final WriteSink sink
public WriteSession(LinkedBuffer head)
public WriteSession(LinkedBuffer head, int nextBufferSize)
public WriteSession(LinkedBuffer head, java.io.OutputStream out, WriteSession.FlushHandler flushHandler, int nextBufferSize)
public WriteSession(LinkedBuffer head, java.io.OutputStream out)
public void reset()
public WriteSession clear()
public final int getSize()
public final byte[] toByteArray()
protected int flush(byte[] buf,
int offset,
int len)
throws java.io.IOException
java.io.IOExceptionprotected int flush(byte[] buf,
int offset,
int len,
byte[] next,
int nextoffset,
int nextlen)
throws java.io.IOException
java.io.IOExceptionprotected int flush(LinkedBuffer lb, byte[] buf, int offset, int len) throws java.io.IOException
java.io.IOExceptionCopyright © 2009-2017. All Rights Reserved.