Class ZstdEncoder
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelOutboundHandlerAdapter
-
- io.netty.handler.codec.MessageToByteEncoder<ByteBuf>
-
- io.netty.handler.codec.compression.ZstdEncoder
-
- All Implemented Interfaces:
ChannelHandler,ChannelOutboundHandler
public final class ZstdEncoder extends MessageToByteEncoder<ByteBuf>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Constructor Summary
Constructors Constructor Description ZstdEncoder()Creates a new Zstd encoder.ZstdEncoder(int compressionLevel)Creates a new Zstd encoder.ZstdEncoder(int blockSize, int maxEncodeSize)Creates a new Zstd encoder.ZstdEncoder(int compressionLevel, int blockSize, int maxEncodeSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ByteBufallocateBuffer(ChannelHandlerContext ctx, ByteBuf msg, boolean preferDirect)Allocate aByteBufwhich will be used as argument of#encode(ChannelHandlerContext, I, ByteBuf).protected voidencode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out)Encode a message into aByteBuf.voidflush(ChannelHandlerContext ctx)CallsChannelHandlerContext.flush()to forward to the nextChannelOutboundHandlerin theChannelPipeline.voidhandlerAdded(ChannelHandlerContext ctx)Do nothing by default, sub-classes may override this method.voidhandlerRemoved(ChannelHandlerContext ctx)Do nothing by default, sub-classes may override this method.-
Methods inherited from class io.netty.handler.codec.MessageToByteEncoder
acceptOutboundMessage, isPreferDirect, write
-
Methods inherited from class io.netty.channel.ChannelOutboundHandlerAdapter
bind, close, connect, deregister, disconnect, read
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, exceptionCaught, isSharable
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.channel.ChannelHandler
exceptionCaught
-
-
-
-
Constructor Detail
-
ZstdEncoder
public ZstdEncoder()
Creates a new Zstd encoder. Please note that if you use the default constructor, the default BLOCK_SIZE and MAX_BLOCK_SIZE will be used. If you want to specify BLOCK_SIZE and MAX_BLOCK_SIZE yourself, please useZstdEncoder(int,int)constructor
-
ZstdEncoder
public ZstdEncoder(int compressionLevel)
Creates a new Zstd encoder.- Parameters:
compressionLevel- specifies the level of the compression
-
ZstdEncoder
public ZstdEncoder(int blockSize, int maxEncodeSize)Creates a new Zstd encoder.- Parameters:
blockSize- is used to calculate the compressionLevelmaxEncodeSize- specifies the size of the largest compressed object
-
ZstdEncoder
public ZstdEncoder(int compressionLevel, int blockSize, int maxEncodeSize)- Parameters:
blockSize- is used to calculate the compressionLevelmaxEncodeSize- specifies the size of the largest compressed objectcompressionLevel- specifies the level of the compression
-
-
Method Detail
-
allocateBuffer
protected ByteBuf allocateBuffer(ChannelHandlerContext ctx, ByteBuf msg, boolean preferDirect)
Description copied from class:MessageToByteEncoderAllocate aByteBufwhich will be used as argument of#encode(ChannelHandlerContext, I, ByteBuf). Sub-classes may override this method to returnByteBufwith a perfect matchinginitialCapacity.- Overrides:
allocateBufferin classMessageToByteEncoder<ByteBuf>
-
encode
protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out)
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
-
flush
public void flush(ChannelHandlerContext ctx)
Description copied from class:ChannelOutboundHandlerAdapterCallsChannelHandlerContext.flush()to forward to the nextChannelOutboundHandlerin theChannelPipeline. Sub-classes may override this method to change behavior.- Specified by:
flushin interfaceChannelOutboundHandler- Overrides:
flushin classChannelOutboundHandlerAdapter- Parameters:
ctx- theChannelHandlerContextfor which the flush operation is made
-
handlerAdded
public void handlerAdded(ChannelHandlerContext ctx)
Description copied from class:ChannelHandlerAdapterDo nothing by default, sub-classes may override this method.- Specified by:
handlerAddedin interfaceChannelHandler- Overrides:
handlerAddedin classChannelHandlerAdapter
-
handlerRemoved
public void handlerRemoved(ChannelHandlerContext ctx) throws java.lang.Exception
Description copied from class:ChannelHandlerAdapterDo nothing by default, sub-classes may override this method.- Specified by:
handlerRemovedin interfaceChannelHandler- Overrides:
handlerRemovedin classChannelHandlerAdapter- Throws:
java.lang.Exception
-
-