Class LzmaFrameEncoder
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelOutboundHandlerAdapter
io.netty.handler.codec.MessageToByteEncoder<ByteBuf>
io.netty.handler.codec.compression.LzmaFrameEncoder
- All Implemented Interfaces:
ChannelHandler, ChannelOutboundHandler
Compresses a
ByteBuf using the LZMA algorithm.
See LZMA
and LZMA format
or documents in LZMA SDK archive.-
Nested Class Summary
Nested classes/interfaces inherited from interface ChannelHandler
ChannelHandler.Sharable -
Constructor Summary
ConstructorsConstructorDescriptionCreates LZMA encoder with default settings.LzmaFrameEncoder(int dictionarySize) Creates LZMA encoder with specified dictionary size and default values oflc= 3,lp= 0,pb= 2.LzmaFrameEncoder(int lc, int lp, int pb) Creates LZMA encoder with specifiedlc,lp,pbvalues and the medium dictionary size of 65536.LzmaFrameEncoder(int lc, int lp, int pb, int dictionarySize) Creates LZMA encoder with specifiedlc,lp,pbvalues and custom dictionary size.LzmaFrameEncoder(int lc, int lp, int pb, int dictionarySize, boolean endMarkerMode, int numFastBytes) Creates LZMA encoder with specified settings. -
Method Summary
Modifier and TypeMethodDescriptionprotected ByteBufallocateBuffer(ChannelHandlerContext ctx, ByteBuf in, boolean preferDirect) Allocate aByteBufwhich will be used as argument ofMessageToByteEncoder.encode(ChannelHandlerContext, I, ByteBuf).protected voidencode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) Encode a message into aByteBuf.Methods inherited from class MessageToByteEncoder
acceptOutboundMessage, isPreferDirect, writeMethods inherited from class ChannelOutboundHandlerAdapter
bind, close, connect, deregister, disconnect, flush, readMethods inherited from class ChannelHandlerAdapter
ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharableMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ChannelHandler
exceptionCaught, handlerAdded, handlerRemoved
-
Constructor Details
-
LzmaFrameEncoder
public LzmaFrameEncoder()Creates LZMA encoder with default settings. -
LzmaFrameEncoder
public LzmaFrameEncoder(int lc, int lp, int pb) Creates LZMA encoder with specifiedlc,lp,pbvalues and the medium dictionary size of 65536. -
LzmaFrameEncoder
public LzmaFrameEncoder(int dictionarySize) Creates LZMA encoder with specified dictionary size and default values oflc= 3,lp= 0,pb= 2. -
LzmaFrameEncoder
public LzmaFrameEncoder(int lc, int lp, int pb, int dictionarySize) Creates LZMA encoder with specifiedlc,lp,pbvalues and custom dictionary size. -
LzmaFrameEncoder
public LzmaFrameEncoder(int lc, int lp, int pb, int dictionarySize, boolean endMarkerMode, int numFastBytes) Creates LZMA encoder with specified settings.- Parameters:
lc- the number of "literal context" bits, available values [0, 8], default value 3.lp- the number of "literal position" bits, available values [0, 4], default value 0.pb- the number of "position" bits, available values [0, 4], default value 2.dictionarySize- available values [0,Integer.MAX_VALUE], default value is 65536.endMarkerMode- indicates shouldLzmaFrameEncoderuse end of stream marker or not. Note, thatLzmaFrameEncoderalways sets size of uncompressed data in LZMA header, so EOS marker is unnecessary. But you may use it for better portability. For full description see "LZMA Decoding modes" section of LZMA-Specification.txt in official LZMA SDK.numFastBytes- available values [5, 273].
-
-
Method Details
-
encode
Description copied from class:MessageToByteEncoderEncode a message into aByteBuf. This method will be called for each written message that can be handled by this encoder.- Specified by:
encodein classMessageToByteEncoder<ByteBuf>- Parameters:
ctx- theChannelHandlerContextwhich thisMessageToByteEncoderbelongs toin- the message to encodeout- theByteBufinto which the encoded message will be written- Throws:
Exception- is thrown if an error occurs
-
allocateBuffer
protected ByteBuf allocateBuffer(ChannelHandlerContext ctx, ByteBuf in, boolean preferDirect) throws Exception Description copied from class:MessageToByteEncoderAllocate aByteBufwhich will be used as argument ofMessageToByteEncoder.encode(ChannelHandlerContext, I, ByteBuf). Sub-classes may override this method to returnByteBufwith a perfect matchinginitialCapacity.- Overrides:
allocateBufferin classMessageToByteEncoder<ByteBuf>- Throws:
Exception
-