Class FastLzFrameEncoder
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelOutboundHandlerAdapter
io.netty.handler.codec.MessageToByteEncoder<ByteBuf>
io.netty.handler.codec.compression.FastLzFrameEncoder
- All Implemented Interfaces:
ChannelHandler, ChannelOutboundHandler
Compresses a
ByteBuf using the FastLZ algorithm.
See FastLZ format.-
Nested Class Summary
Nested classes/interfaces inherited from interface ChannelHandler
ChannelHandler.SharableModifier and TypeInterfaceDescriptionstatic @interfaceIndicates that the same instance of the annotatedChannelHandlercan be added to one or moreChannelPipelines multiple times without a race condition. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a FastLZ encoder without checksum calculator and with auto detection of compression level.FastLzFrameEncoder(boolean validateChecksums) Creates a FastLZ encoder with auto detection of compression level and calculation of checksums as specified.FastLzFrameEncoder(int level) Creates a FastLZ encoder with specified compression level and without checksum calculator.FastLzFrameEncoder(int level, Checksum checksum) Creates a FastLZ encoder with specified compression level and checksum calculator. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidencode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) Encode a message into aByteBuf.Methods inherited from class MessageToByteEncoder
acceptOutboundMessage, allocateBuffer, isPreferDirect, writeModifier and TypeMethodDescriptionbooleanReturnstrueif the given message should be handled.protected ByteBufallocateBuffer(ChannelHandlerContext ctx, ByteBuf msg, boolean preferDirect) Allocate aByteBufwhich will be used as argument ofMessageToByteEncoder.encode(ChannelHandlerContext, I, ByteBuf).protected booleanvoidwrite(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) CallsChannelOutboundInvoker.write(Object, ChannelPromise)to forward to the nextChannelOutboundHandlerin theChannelPipeline.Methods inherited from class ChannelOutboundHandlerAdapter
bind, close, connect, deregister, disconnect, flush, readModifier and TypeMethodDescriptionvoidbind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) CallsChannelOutboundInvoker.bind(SocketAddress, ChannelPromise)to forward to the nextChannelOutboundHandlerin theChannelPipeline.voidclose(ChannelHandlerContext ctx, ChannelPromise promise) CallsChannelOutboundInvoker.close(ChannelPromise)to forward to the nextChannelOutboundHandlerin theChannelPipeline.voidconnect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) CallsChannelOutboundInvoker.connect(SocketAddress, SocketAddress, ChannelPromise)to forward to the nextChannelOutboundHandlerin theChannelPipeline.voidderegister(ChannelHandlerContext ctx, ChannelPromise promise) CallsChannelOutboundInvoker.deregister(ChannelPromise)to forward to the nextChannelOutboundHandlerin theChannelPipeline.voiddisconnect(ChannelHandlerContext ctx, ChannelPromise promise) CallsChannelOutboundInvoker.disconnect(ChannelPromise)to forward to the nextChannelOutboundHandlerin theChannelPipeline.voidCallsChannelHandlerContext.flush()to forward to the nextChannelOutboundHandlerin theChannelPipeline.voidCallsChannelHandlerContext.read()to forward to the nextChannelOutboundHandlerin theChannelPipeline.Methods inherited from class ChannelHandlerAdapter
ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharableModifier and TypeMethodDescriptionprotected voidvoidexceptionCaught(ChannelHandlerContext ctx, Throwable cause) Deprecated.voidDo nothing by default, sub-classes may override this method.voidDo nothing by default, sub-classes may override this method.booleanReturntrueif the implementation isChannelHandler.Sharableand so can be added to differentChannelPipelines.
-
Constructor Details
-
FastLzFrameEncoder
public FastLzFrameEncoder()Creates a FastLZ encoder without checksum calculator and with auto detection of compression level. -
FastLzFrameEncoder
public FastLzFrameEncoder(int level) Creates a FastLZ encoder with specified compression level and without checksum calculator.- Parameters:
level- supports only these values: 0 - Encoder will choose level automatically depending on the length of the input buffer. 1 - Level 1 is the fastest compression and generally useful for short data. 2 - Level 2 is slightly slower but it gives better compression ratio.
-
FastLzFrameEncoder
public FastLzFrameEncoder(boolean validateChecksums) Creates a FastLZ encoder with auto detection of compression level and calculation of checksums as specified.- Parameters:
validateChecksums- If true, the checksum of each block will be calculated and this value will be added to the header of block. By defaultFastLzFrameEncoderusesAdler32for checksum calculation.
-
FastLzFrameEncoder
Creates a FastLZ encoder with specified compression level and checksum calculator.- Parameters:
level- supports only these values: 0 - Encoder will choose level automatically depending on the length of the input buffer. 1 - Level 1 is the fastest compression and generally useful for short data. 2 - Level 2 is slightly slower but it gives better compression ratio.checksum- theChecksuminstance to use to check data for integrity. You may setnullif you don't want to validate checksum of each block.
-
-
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
-
ChannelInboundHandler