Class JdkZlibDecompressor
java.lang.Object
io.netty.handler.codec.compression.InputBufferingDecompressor
io.netty.handler.codec.compression.JdkZlibDecompressor
- All Implemented Interfaces:
Decompressor, AutoCloseable
Decompress a
ByteBuf using the inflate algorithm.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classprivate static enumNested classes/interfaces inherited from interface Decompressor
Decompressor.AbstractDecompressorBuilder, Decompressor.Status -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ByteBufChecksumprivate booleanprivate final booleanprivate final byte[]private static final intprivate static final intprivate static final intprivate booleanprivate intprivate static final intprivate static final intprivate booleanprivate JdkZlibDecompressor.GzipStateprivate Inflaterprivate booleanIf this is true, the lastInflater.inflate(byte[], int, int)filled the output buffer completely, so the inflater may still hold decoded data even ifInflater.needsInput()reports that all input was consumed.private booleanIf this is true, part of the input buffer is still in use by theinflater, so we shouldn't touch that buffer too much (e.g.private final intprivate static final intSmallest output buffer we hand toInflater.inflate(byte[], int, int).private intFields inherited from class InputBufferingDecompressor
allocator -
Constructor Summary
ConstructorsConstructorDescriptionJdkZlibDecompressor(JdkZlibDecompressor.Builder builder, ByteBufAllocator allocator) -
Method Summary
Modifier and TypeMethodDescriptionstatic JdkZlibDecompressor.Builderbuilder()voidclose()Close this decompressor, cleaning up any associated resources.private voidconsumeInput(ByteBuf buf) voidNotify the decompressor that the end of input has been reached.private booleanprivate static booleanlooksLikeZlib(short cmf_flg) (package private) voidprocessInput(ByteBuf buf) Process some input.(package private) ByteBufprocessOutput(ByteBuf buf) Produce some output.private booleanRead the GZIP footer.private booleanprivate booleanskipIfNeeded(ByteBuf in, int flagMask) Skip bytes in the input if needed until we find the end marker0x00.status()Get the current status.private booleanVerifies CRC.private booleanverifyCrc16(ByteBuf in) Methods inherited from class InputBufferingDecompressor
addInput, available, takeOutput
-
Field Details
-
FHCRC
private static final int FHCRC- See Also:
-
FEXTRA
private static final int FEXTRA- See Also:
-
FNAME
private static final int FNAME- See Also:
-
FCOMMENT
private static final int FCOMMENT- See Also:
-
FRESERVED
private static final int FRESERVED- See Also:
-
MIN_OUTPUT_BUFFER_SIZE
private static final int MIN_OUTPUT_BUFFER_SIZESmallest output buffer we hand toInflater.inflate(byte[], int, int). The number of remaining input bytes is only a hint for how much output to expect: the inflater may still hold decoded data that did not fit into the previous output buffer, and by then it may have consumed all input bytes already (Inflater.getRemaining()== 0). Inflating into a zero-sized buffer can never make progress.- See Also:
-
inflater
-
maxAllocation
private final int maxAllocation -
dictionary
private final byte[] dictionary -
crc
-
decompressConcatenated
private final boolean decompressConcatenated -
gzipState
-
flags
private int flags -
xlen
private int xlen -
decideZlibOrNone
private boolean decideZlibOrNone -
finished
private boolean finished -
gzipMemberFinished
private boolean gzipMemberFinished -
inputBufferInInflater
private boolean inputBufferInInflaterIf this is true, part of the input buffer is still in use by theinflater, so we shouldn't touch that buffer too much (e.g. compact it). -
inflaterHasPendingOutput
private boolean inflaterHasPendingOutputIf this is true, the lastInflater.inflate(byte[], int, int)filled the output buffer completely, so the inflater may still hold decoded data even ifInflater.needsInput()reports that all input was consumed.
-
-
Constructor Details
-
JdkZlibDecompressor
JdkZlibDecompressor(JdkZlibDecompressor.Builder builder, ByteBufAllocator allocator)
-
-
Method Details
-
status
Description copied from interface:DecompressorGet the current status. Like the other operations on this class, calling this method is not permitted if the decompressor has failed or was closed.- Returns:
- The current status
- Throws:
DecompressionException
-
endOfInput
Description copied from interface:DecompressorNotify the decompressor that the end of input has been reached. Some implementations may flush remaining data or throw an exception if the input is truncated, but most implementations do nothing. Only permitted forDecompressor.Status.NEED_INPUT.- Throws:
DecompressionException
-
processInput
Description copied from class:InputBufferingDecompressorProcess some input. The input buffer ownership does not transfer to this method: If there's still data unread after this method finishes, it will be buffered.- Specified by:
processInputin classInputBufferingDecompressor- Parameters:
buf- The input buffer- Throws:
DecompressionException
-
consumeInput
-
processOutput
Description copied from class:InputBufferingDecompressorProduce some output. The input buffer parameter may be read from to consume some more data, but note that this method must return a buffer even if the input is too short.- Specified by:
processOutputin classInputBufferingDecompressor- Parameters:
buf- The input buffer- Throws:
DecompressionException
-
readGZIPHeader
-
skipIfNeeded
Skip bytes in the input if needed until we find the end marker0x00.- Parameters:
in- the inputflagMask- the mask that should be present in theflagswhen we need to skip bytes.- Returns:
trueif the operation is complete and we can move to the next state,falseif we need the retry again once we have more readable bytes.
-
verifyCrc
-
verifyCrc16
-
looksLikeZlib
private static boolean looksLikeZlib(short cmf_flg) -
close
public void close()Description copied from interface:DecompressorClose this decompressor, cleaning up any associated resources. This method is idempotent.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceDecompressor- Overrides:
closein classInputBufferingDecompressor
-
builder
-