public class LzfEncoder extends MessageToByteEncoder<ByteBuf>
ByteBuf
using the LZF format.
See original LZF package and LZF format for full description.
ChannelHandler.Sharable
构造器和说明 |
---|
LzfEncoder()
Creates a new LZF encoder with the most optimal available methods for underlying data access.
|
LzfEncoder(boolean safeInstance)
Creates a new LZF encoder with specified encoding instance.
|
LzfEncoder(boolean safeInstance,
int totalLength)
Creates a new LZF encoder with specified encoding instance and compressThreshold.
|
LzfEncoder(boolean safeInstance,
int totalLength,
int compressThreshold)
Creates a new LZF encoder with specified settings.
|
LzfEncoder(int totalLength)
Creates a new LZF encoder with specified total length of encoded chunk.
|
限定符和类型 | 方法和说明 |
---|---|
protected void |
encode(ChannelHandlerContext ctx,
ByteBuf in,
ByteBuf out)
Encode a message into a
ByteBuf . |
void |
handlerRemoved(ChannelHandlerContext ctx)
Do nothing by default, sub-classes may override this method.
|
acceptOutboundMessage, allocateBuffer, isPreferDirect, write
bind, close, connect, deregister, disconnect, flush, read
ensureNotSharable, exceptionCaught, handlerAdded, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
exceptionCaught, handlerAdded
public LzfEncoder()
LzfEncoder(boolean)
with true
param.public LzfEncoder(boolean safeInstance)
safeInstance
- If true
encoder will use ChunkEncoder
that only uses
standard JDK access methods, and should work on all Java platforms and JVMs.
Otherwise encoder will try to use highly optimized ChunkEncoder
implementation that uses Sun JDK's Unsafe
class (which may be included by other JDK's as well).public LzfEncoder(boolean safeInstance, int totalLength)
safeInstance
- If true
encoder will use ChunkEncoder
that only uses standard
JDK access methods, and should work on all Java platforms and JVMs.
Otherwise encoder will try to use highly optimized ChunkEncoder
implementation that uses Sun JDK's Unsafe
class (which may be included by other JDK's as well).totalLength
- Expected total length of content to compress; only matters for outgoing messages
that is smaller than maximum chunk size (64k), to optimize encoding hash tables.public LzfEncoder(int totalLength)
totalLength
- Expected total length of content to compress;
only matters for outgoing messages that is smaller than maximum chunk size (64k),
to optimize encoding hash tables.public LzfEncoder(boolean safeInstance, int totalLength, int compressThreshold)
safeInstance
- If true
encoder will use ChunkEncoder
that only uses standard JDK
access methods, and should work on all Java platforms and JVMs.
Otherwise encoder will try to use highly optimized ChunkEncoder
implementation that uses Sun JDK's Unsafe
class (which may be included by other JDK's as well).totalLength
- Expected total length of content to compress; only matters for outgoing messages
that is smaller than maximum chunk size (64k), to optimize encoding hash tables.compressThreshold
- Compress threshold for LZF format. When the amount of input data is less than
compressThreshold, we will construct an uncompressed output according
to the LZF format.protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws java.lang.Exception
MessageToByteEncoder
ByteBuf
. This method will be called for each written message that can be handled
by this encoder.encode
在类中 MessageToByteEncoder<ByteBuf>
ctx
- the ChannelHandlerContext
which this MessageToByteEncoder
belongs toin
- the message to encodeout
- the ByteBuf
into which the encoded message will be writtenjava.lang.Exception
- is thrown if an error occurspublic void handlerRemoved(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelHandlerAdapter
handlerRemoved
在接口中 ChannelHandler
handlerRemoved
在类中 ChannelHandlerAdapter
java.lang.Exception