public abstract class AbstractProtocolCodec extends java.lang.Object implements ProtocolCodec
| Modifier and Type | Class and Description |
|---|---|
static interface |
AbstractProtocolCodec.Action |
ProtocolCodec.BufferState| Modifier and Type | Field and Description |
|---|---|
protected BufferPools |
bufferPools |
protected java.nio.ByteBuffer |
directReadBuffer |
protected int |
lastReadIoSize |
protected long |
lastWriteIoSize |
protected AbstractProtocolCodec.Action |
nextDecodeAction |
protected org.fusesource.hawtbuf.DataByteArrayOutputStream |
nextWriteBuffer |
protected java.nio.ByteBuffer |
readBuffer |
protected BufferPool |
readBufferPool |
protected int |
readBufferSize |
protected java.nio.channels.ReadableByteChannel |
readChannel |
protected long |
readCounter |
protected int |
readEnd |
protected int |
readStart |
protected java.util.LinkedList<java.nio.ByteBuffer> |
writeBuffer |
protected BufferPool |
writeBufferPool |
private long |
writeBufferRemaining |
protected int |
writeBufferSize |
protected java.nio.channels.GatheringByteChannel |
writeChannel |
protected long |
writeCounter |
| Constructor and Description |
|---|
AbstractProtocolCodec() |
| Modifier and Type | Method and Description |
|---|---|
private org.fusesource.hawtbuf.DataByteArrayOutputStream |
allocateNextWriteBuffer() |
protected abstract void |
encode(java.lang.Object value) |
ProtocolCodec.BufferState |
flush()
Attempts to complete the previous write which did not complete.
|
protected void |
flushNextWriteBuffer() |
boolean |
full()
Is the codec's buffer full?
|
BufferPools |
getBufferPools() |
long |
getLastReadSize() |
long |
getLastWriteSize() |
int |
getReadBufferSize() |
long |
getReadCounter() |
int |
getWriteBufferSize() |
long |
getWriteCounter() |
protected abstract AbstractProtocolCodec.Action |
initialDecodeAction() |
boolean |
isEmpty() |
protected void |
onBufferFlushed(java.nio.ByteBuffer byteBuffer)
Called when a buffer is flushed out.
|
protected org.fusesource.hawtbuf.Buffer |
peekBytes(int length) |
java.lang.Object |
read()
Non-blocking channel based decoding.
|
protected org.fusesource.hawtbuf.Buffer |
readBytes(int length) |
protected java.lang.Boolean |
readDirect(java.nio.ByteBuffer buffer) |
protected org.fusesource.hawtbuf.Buffer |
readUntil(java.lang.Byte octet) |
protected org.fusesource.hawtbuf.Buffer |
readUntil(java.lang.Byte octet,
int max) |
protected org.fusesource.hawtbuf.Buffer |
readUntil(java.lang.Byte octet,
int max,
java.lang.String msg) |
void |
setBufferPools(BufferPools bufferPools) |
void |
setTransport(Transport transport) |
void |
unread(byte[] buffer)
Pushes back a buffer as being unread.
|
ProtocolCodec.BufferState |
write(java.lang.Object value)
Non-blocking channel based encoding.
|
protected void |
writeDirect(java.nio.ByteBuffer value) |
protected BufferPools bufferPools
protected BufferPool writeBufferPool
protected BufferPool readBufferPool
protected int writeBufferSize
protected long writeCounter
protected java.nio.channels.GatheringByteChannel writeChannel
protected org.fusesource.hawtbuf.DataByteArrayOutputStream nextWriteBuffer
protected long lastWriteIoSize
protected java.util.LinkedList<java.nio.ByteBuffer> writeBuffer
private long writeBufferRemaining
protected long readCounter
protected int readBufferSize
protected java.nio.channels.ReadableByteChannel readChannel
protected java.nio.ByteBuffer readBuffer
protected java.nio.ByteBuffer directReadBuffer
protected int readEnd
protected int readStart
protected int lastReadIoSize
protected AbstractProtocolCodec.Action nextDecodeAction
public void setTransport(Transport transport)
setTransport in interface ProtocolCodecpublic int getReadBufferSize()
getReadBufferSize in interface ProtocolCodecpublic int getWriteBufferSize()
getWriteBufferSize in interface ProtocolCodecpublic boolean full()
ProtocolCodecfull in interface ProtocolCodecpublic boolean isEmpty()
public long getWriteCounter()
getWriteCounter in interface ProtocolCodecpublic long getLastWriteSize()
getLastWriteSize in interface ProtocolCodecprotected abstract void encode(java.lang.Object value)
throws java.io.IOException
java.io.IOExceptionpublic ProtocolCodec.BufferState write(java.lang.Object value) throws java.io.IOException
ProtocolCodecwrite in interface ProtocolCodecjava.io.IOExceptionprivate org.fusesource.hawtbuf.DataByteArrayOutputStream allocateNextWriteBuffer()
protected void writeDirect(java.nio.ByteBuffer value)
throws java.io.IOException
java.io.IOExceptionprotected void flushNextWriteBuffer()
public ProtocolCodec.BufferState flush() throws java.io.IOException
ProtocolCodecflush in interface ProtocolCodecjava.io.IOExceptionprotected void onBufferFlushed(java.nio.ByteBuffer byteBuffer)
byteBuffer - protected abstract AbstractProtocolCodec.Action initialDecodeAction()
public void unread(byte[] buffer)
ProtocolCodecunread in interface ProtocolCodecpublic long getReadCounter()
getReadCounter in interface ProtocolCodecpublic long getLastReadSize()
getLastReadSize in interface ProtocolCodecpublic java.lang.Object read()
throws java.io.IOException
ProtocolCodecread in interface ProtocolCodecjava.io.IOExceptionprotected org.fusesource.hawtbuf.Buffer readUntil(java.lang.Byte octet)
throws java.net.ProtocolException
java.net.ProtocolExceptionprotected org.fusesource.hawtbuf.Buffer readUntil(java.lang.Byte octet,
int max)
throws java.net.ProtocolException
java.net.ProtocolExceptionprotected org.fusesource.hawtbuf.Buffer readUntil(java.lang.Byte octet,
int max,
java.lang.String msg)
throws java.net.ProtocolException
java.net.ProtocolExceptionprotected org.fusesource.hawtbuf.Buffer readBytes(int length)
protected org.fusesource.hawtbuf.Buffer peekBytes(int length)
protected java.lang.Boolean readDirect(java.nio.ByteBuffer buffer)
public BufferPools getBufferPools()
public void setBufferPools(BufferPools bufferPools)