Class ZlibDecoder
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.ByteToMessageDecoder
io.netty.handler.codec.compression.ZlibDecoder
- All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler
- Direct Known Subclasses:
JdkZlibDecoder, JZlibDecoder
Decompresses a
ByteBuf using the deflate algorithm.-
Nested Class Summary
Nested classes/interfaces inherited from class ByteToMessageDecoder
ByteToMessageDecoder.CumulatorNested classes/interfaces inherited from interface ChannelHandler
ChannelHandler.Sharable -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intMaximum allowed size of the decompression buffer.Fields inherited from class ByteToMessageDecoder
COMPOSITE_CUMULATOR, MERGE_CUMULATOR -
Constructor Summary
ConstructorsConstructorDescriptionSame asZlibDecoder(int)with maxAllocation = 0.ZlibDecoder(int maxAllocation) Construct a new ZlibDecoder. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddecompressionBufferExhausted(ByteBuf buffer) Called when the decompression buffer cannot be expanded further.abstract booleanisClosed()Returnstrueif and only if the end of the compressed stream has been reached.protected ByteBufprepareDecompressBuffer(ChannelHandlerContext ctx, ByteBuf buffer, int preferredSize) Allocate or expand the decompression buffer, without exceeding the maximum allocation.Methods inherited from class ByteToMessageDecoder
actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, decode, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggeredMethods inherited from class ChannelInboundHandlerAdapter
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaughtMethods inherited from class ChannelHandlerAdapter
ensureNotSharable, handlerAdded, isSharableMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ChannelHandler
handlerAdded
-
Field Details
-
maxAllocation
protected final int maxAllocationMaximum allowed size of the decompression buffer.
-
-
Constructor Details
-
ZlibDecoder
public ZlibDecoder()Same asZlibDecoder(int)with maxAllocation = 0. -
ZlibDecoder
public ZlibDecoder(int maxAllocation) Construct a new ZlibDecoder.- Parameters:
maxAllocation- Maximum size of the decompression buffer. Must be >= 0. If zero, maximum size is decided by theByteBufAllocator.
-
-
Method Details
-
isClosed
public abstract boolean isClosed()Returnstrueif and only if the end of the compressed stream has been reached. -
prepareDecompressBuffer
protected ByteBuf prepareDecompressBuffer(ChannelHandlerContext ctx, ByteBuf buffer, int preferredSize) Allocate or expand the decompression buffer, without exceeding the maximum allocation. CallsdecompressionBufferExhausted(ByteBuf)if the buffer is full and cannot be expanded further. -
decompressionBufferExhausted
Called when the decompression buffer cannot be expanded further. Default implementation is a no-op, but subclasses can override in case they want to do something before theDecompressionExceptionis thrown, such as log the data that was decompressed so far.
-