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 ByteBuf
allocateBuffer(ChannelHandlerContext ctx, ByteBuf msg, boolean preferDirect)
Allocate aByteBuf
which will be used as argument of#encode(ChannelHandlerContext, I, ByteBuf)
.protected void
encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out)
Encode a message into aByteBuf
.void
flush(ChannelHandlerContext ctx)
CallsChannelHandlerContext.flush()
to forward to the nextChannelOutboundHandler
in theChannelPipeline
.void
handlerAdded(ChannelHandlerContext ctx)
Do nothing by default, sub-classes may override this method.void
handlerRemoved(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:MessageToByteEncoder
Allocate aByteBuf
which will be used as argument of#encode(ChannelHandlerContext, I, ByteBuf)
. Sub-classes may override this method to returnByteBuf
with a perfect matchinginitialCapacity
.- Overrides:
allocateBuffer
in classMessageToByteEncoder<ByteBuf>
-
encode
protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out)
Description copied from class:MessageToByteEncoder
Encode a message into aByteBuf
. This method will be called for each written message that can be handled by this encoder.- Specified by:
encode
in classMessageToByteEncoder<ByteBuf>
- Parameters:
ctx
- theChannelHandlerContext
which thisMessageToByteEncoder
belongs toin
- the message to encodeout
- theByteBuf
into which the encoded message will be written
-
flush
public void flush(ChannelHandlerContext ctx)
Description copied from class:ChannelOutboundHandlerAdapter
CallsChannelHandlerContext.flush()
to forward to the nextChannelOutboundHandler
in theChannelPipeline
. Sub-classes may override this method to change behavior.- Specified by:
flush
in interfaceChannelOutboundHandler
- Overrides:
flush
in classChannelOutboundHandlerAdapter
- Parameters:
ctx
- theChannelHandlerContext
for which the flush operation is made
-
handlerAdded
public void handlerAdded(ChannelHandlerContext ctx)
Description copied from class:ChannelHandlerAdapter
Do nothing by default, sub-classes may override this method.- Specified by:
handlerAdded
in interfaceChannelHandler
- Overrides:
handlerAdded
in classChannelHandlerAdapter
-
handlerRemoved
public void handlerRemoved(ChannelHandlerContext ctx) throws java.lang.Exception
Description copied from class:ChannelHandlerAdapter
Do nothing by default, sub-classes may override this method.- Specified by:
handlerRemoved
in interfaceChannelHandler
- Overrides:
handlerRemoved
in classChannelHandlerAdapter
- Throws:
java.lang.Exception
-
-