Top Description Inners Fields Constructors Methods
io.netty.handler.codec.compression

public Class JdkZlibDecoder

extends ZlibDecoder
Class Inheritance
Imports
io.netty.buffer.ByteBuf, .ByteBufAllocator, io.netty.channel.ChannelHandlerContext, io.netty.util.internal.ObjectUtil, java.util.List, java.util.zip.CRC32, .DataFormatException, .Deflater, .Inflater

Decompress a ByteBuf using the inflate algorithm.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum

Field Summary

Modifier and TypeField and Description
private final ByteBufChecksum
private boolean
private final boolean
private final byte[]
private static final int
private static final int
private static final int
private volatile boolean
private int
private static final int
private static final int
private JdkZlibDecoder.GzipState
private Inflater
private int
Inherited from io.netty.handler.codec.compression.ZlibDecoder:
maxAllocation

Constructor Summary

AccessConstructor and Description
public
JdkZlibDecoder()

Creates a new instance with the default wrapper (ZlibWrapper#ZLIB).

public
JdkZlibDecoder(int
Maximum size of the decompression buffer. Must be >= 0. If zero, maximum size is decided by the ByteBufAllocator.
maxAllocation
)

Creates a new instance with the default wrapper (ZlibWrapper#ZLIB) and the specified maximum buffer allocation.

public
JdkZlibDecoder(byte[] dictionary)

Creates a new instance with the specified preset dictionary.

public
JdkZlibDecoder(byte[] dictionary, int
Maximum size of the decompression buffer. Must be >= 0. If zero, maximum size is decided by the ByteBufAllocator.
maxAllocation
)

Creates a new instance with the specified preset dictionary and maximum buffer allocation.

public
JdkZlibDecoder(ZlibWrapper wrapper)

Creates a new instance with the specified wrapper.

public
JdkZlibDecoder(ZlibWrapper wrapper, int
Maximum size of the decompression buffer. Must be >= 0. If zero, maximum size is decided by the ByteBufAllocator.
maxAllocation
)

Creates a new instance with the specified wrapper and maximum buffer allocation.

public
JdkZlibDecoder(ZlibWrapper wrapper, boolean decompressConcatenated)

public
JdkZlibDecoder(ZlibWrapper wrapper, boolean decompressConcatenated, int maxAllocation)

public
JdkZlibDecoder(boolean decompressConcatenated)

public
JdkZlibDecoder(boolean decompressConcatenated, int maxAllocation)

private
JdkZlibDecoder(ZlibWrapper wrapper, byte[] dictionary, boolean decompressConcatenated, int maxAllocation)

Method Summary

Modifier and TypeMethod and Description
protected void
decode(ChannelHandlerContext ctx, ByteBuf
the ByteBuf from which to read data
in
,
List<Object>
the List to which decoded messages should be added
out
)

Implements abstract io.netty.handler.codec.ByteToMessageDecoder.decode.

Decode the from one ByteBuf to an other.
protected void
decompressionBufferExhausted(ByteBuf buffer)

Overrides io.netty.handler.codec.compression.ZlibDecoder.decompressionBufferExhausted.

Called when the decompression buffer cannot be expanded further.
private boolean
protected void
handlerRemoved0(ChannelHandlerContext ctx)

Overrides io.netty.handler.codec.ByteToMessageDecoder.handlerRemoved0.

Gets called after the ByteToMessageDecoder was removed from the actual context and it doesn't handle events anymore.
public boolean
isClosed()

Implements abstract io.netty.handler.codec.compression.ZlibDecoder.isClosed.

Returns true if and only if the end of the compressed stream has been reached.
private static boolean
looksLikeZlib(short cmf_flg)

private boolean

Returns:

true if the footer could be read, false if the read could not be performed as the input ByteBuf doesn't have enough readable bytes (8 bytes).
readGZIPFooter
(ByteBuf
the input.
in
)

Read the GZIP footer.

private boolean
private boolean

Returns:

true if the operation is complete and we can move to the next state, false if we need the retry again once we have more readable bytes.
skipIfNeeded
(ByteBuf
the input
in
,
int
the mask that should be present in the flags when we need to skip bytes.
flagMask
)

Skip bytes in the input if needed until we find the end marker 0x00.

private boolean

Returns:

true if verification could be performed, false if verification could not be performed as the input ByteBuf doesn't have enough readable bytes (4 bytes).
verifyCrc
(ByteBuf
the input.
in
)

Verifies CRC.

private boolean
Inherited from io.netty.handler.codec.compression.ZlibDecoder:
prepareDecompressBuffer

Field Detail

crcback to summary
private final ByteBufChecksum crc
decideZlibOrNoneback to summary
private boolean decideZlibOrNone
decompressConcatenatedback to summary
private final boolean decompressConcatenated
dictionaryback to summary
private final byte[] dictionary
FCOMMENTback to summary
private static final int FCOMMENT
FEXTRAback to summary
private static final int FEXTRA
FHCRCback to summary
private static final int FHCRC
finishedback to summary
private volatile boolean finished
flagsback to summary
private int flags
FNAMEback to summary
private static final int FNAME
FRESERVEDback to summary
private static final int FRESERVED
gzipStateback to summary
private JdkZlibDecoder.GzipState gzipState
inflaterback to summary
private Inflater inflater
xlenback to summary
private int xlen

Constructor Detail

JdkZlibDecoderback to summary
public JdkZlibDecoder()

Creates a new instance with the default wrapper (ZlibWrapper#ZLIB).

JdkZlibDecoderback to summary
public JdkZlibDecoder(int maxAllocation)

Creates a new instance with the default wrapper (ZlibWrapper#ZLIB) and the specified maximum buffer allocation.

Parameters
maxAllocation:int

Maximum size of the decompression buffer. Must be >= 0. If zero, maximum size is decided by the ByteBufAllocator.

JdkZlibDecoderback to summary
public JdkZlibDecoder(byte[] dictionary)

Creates a new instance with the specified preset dictionary. The wrapper is always ZlibWrapper#ZLIB because it is the only format that supports the preset dictionary.

JdkZlibDecoderback to summary
public JdkZlibDecoder(byte[] dictionary, int maxAllocation)

Creates a new instance with the specified preset dictionary and maximum buffer allocation. The wrapper is always ZlibWrapper#ZLIB because it is the only format that supports the preset dictionary.

Parameters
maxAllocation:int

Maximum size of the decompression buffer. Must be >= 0. If zero, maximum size is decided by the ByteBufAllocator.

JdkZlibDecoderback to summary
public JdkZlibDecoder(ZlibWrapper wrapper)

Creates a new instance with the specified wrapper. Be aware that only ZlibWrapper#GZIP, ZlibWrapper#ZLIB and ZlibWrapper#NONE are supported atm.

JdkZlibDecoderback to summary
public JdkZlibDecoder(ZlibWrapper wrapper, int maxAllocation)

Creates a new instance with the specified wrapper and maximum buffer allocation. Be aware that only ZlibWrapper#GZIP, ZlibWrapper#ZLIB and ZlibWrapper#NONE are supported atm.

Parameters
maxAllocation:int

Maximum size of the decompression buffer. Must be >= 0. If zero, maximum size is decided by the ByteBufAllocator.

JdkZlibDecoderback to summary
public JdkZlibDecoder(ZlibWrapper wrapper, boolean decompressConcatenated)
JdkZlibDecoderback to summary
public JdkZlibDecoder(ZlibWrapper wrapper, boolean decompressConcatenated, int maxAllocation)
JdkZlibDecoderback to summary
public JdkZlibDecoder(boolean decompressConcatenated)
JdkZlibDecoderback to summary
public JdkZlibDecoder(boolean decompressConcatenated, int maxAllocation)
JdkZlibDecoderback to summary
private JdkZlibDecoder(ZlibWrapper wrapper, byte[] dictionary, boolean decompressConcatenated, int maxAllocation)

Method Detail

decodeback to summary
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception

Implements abstract io.netty.handler.codec.ByteToMessageDecoder.decode.

Doc from io.netty.handler.codec.ByteToMessageDecoder.decode.

Decode the from one ByteBuf to an other. This method will be called till either the input ByteBuf has nothing to read when return from this method or till nothing was read from the input ByteBuf.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this ByteToMessageDecoder belongs to

in:ByteBuf

the ByteBuf from which to read data

out:List<Object>

the List to which decoded messages should be added

Annotations
@Override
Exceptions
Exception:
is thrown if an error occurs
decompressionBufferExhaustedback to summary
protected void decompressionBufferExhausted(ByteBuf buffer)

Overrides io.netty.handler.codec.compression.ZlibDecoder.decompressionBufferExhausted.

Doc from io.netty.handler.codec.compression.ZlibDecoder.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 the DecompressionException is thrown, such as log the data that was decompressed so far.

Annotations
@Override
handleGzipFooterback to summary
private boolean handleGzipFooter(ByteBuf in)
handlerRemoved0back to summary
protected void handlerRemoved0(ChannelHandlerContext ctx) throws Exception

Overrides io.netty.handler.codec.ByteToMessageDecoder.handlerRemoved0.

Doc from io.netty.handler.codec.ByteToMessageDecoder.handlerRemoved0.

Gets called after the ByteToMessageDecoder was removed from the actual context and it doesn't handle events anymore.

Annotations
@Override
isClosedback to summary
public boolean isClosed()

Implements abstract io.netty.handler.codec.compression.ZlibDecoder.isClosed.

Doc from io.netty.handler.codec.compression.ZlibDecoder.isClosed.

Returns true if and only if the end of the compressed stream has been reached.

Annotations
@Override
looksLikeZlibback to summary
private static boolean looksLikeZlib(short cmf_flg)
readGZIPFooterback to summary
private boolean readGZIPFooter(ByteBuf in)

Read the GZIP footer.

Parameters
in:ByteBuf

the input.

Returns:boolean

true if the footer could be read, false if the read could not be performed as the input ByteBuf doesn't have enough readable bytes (8 bytes).

readGZIPHeaderback to summary
private boolean readGZIPHeader(ByteBuf in)
skipIfNeededback to summary
private boolean skipIfNeeded(ByteBuf in, int flagMask)

Skip bytes in the input if needed until we find the end marker 0x00.

Parameters
in:ByteBuf

the input

flagMask:int

the mask that should be present in the flags when we need to skip bytes.

Returns:boolean

true if the operation is complete and we can move to the next state, false if we need the retry again once we have more readable bytes.

verifyCrcback to summary
private boolean verifyCrc(ByteBuf in)

Verifies CRC.

Parameters
in:ByteBuf

the input.

Returns:boolean

true if verification could be performed, false if verification could not be performed as the input ByteBuf doesn't have enough readable bytes (4 bytes).

verifyCrc16back to summary
private boolean verifyCrc16(ByteBuf in)
io.netty.handler.codec.compression back to summary

private final Enum JdkZlibDecoder.GzipState

extends Enum<JdkZlibDecoder.GzipState>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final JdkZlibDecoder.GzipState
public static final JdkZlibDecoder.GzipState
public static final JdkZlibDecoder.GzipState
public static final JdkZlibDecoder.GzipState
public static final JdkZlibDecoder.GzipState
public static final JdkZlibDecoder.GzipState
public static final JdkZlibDecoder.GzipState
public static final JdkZlibDecoder.GzipState

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static JdkZlibDecoder.GzipState
public static JdkZlibDecoder.GzipState[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

FLG_READback to summary
public static final JdkZlibDecoder.GzipState FLG_READ
FOOTER_STARTback to summary
public static final JdkZlibDecoder.GzipState FOOTER_START
HEADER_ENDback to summary
public static final JdkZlibDecoder.GzipState HEADER_END
HEADER_STARTback to summary
public static final JdkZlibDecoder.GzipState HEADER_START
PROCESS_FHCRCback to summary
public static final JdkZlibDecoder.GzipState PROCESS_FHCRC
SKIP_COMMENTback to summary
public static final JdkZlibDecoder.GzipState SKIP_COMMENT
SKIP_FNAMEback to summary
public static final JdkZlibDecoder.GzipState SKIP_FNAME
XLEN_READback to summary
public static final JdkZlibDecoder.GzipState XLEN_READ

Constructor Detail

GzipStateback to summary
private GzipState()

Method Detail

valueOfback to summary
public static JdkZlibDecoder.GzipState valueOf(String name)
valuesback to summary
public static JdkZlibDecoder.GzipState[] values()