Top Description Inners Fields Constructors Methods
org.apache.commons.compress.compressors.deflate64

pack-priv Class HuffmanDecoder

extends Object
implements Closeable
Class Inheritance
All Implemented Interfaces
java.io.Closeable, java.lang.AutoCloseable
Static Imports
org.apache.commons.compress.compressors.deflate64.HuffmanState.DYNAMIC_CODES, .HuffmanState.FIXED_CODES, .HuffmanState.INITIAL, .HuffmanState.STORED

TODO This class can't be final because it is mocked by Mockito.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private abstract static class
private static class
private class
private static class
private class

Field Summary

Modifier and TypeField and Description
private static final int[]
CODE_LENGTHS_ORDER

When using dynamic huffman codes the order in which the values are stored follows the positioning below

private static final int[]
DISTANCE_TABLE

--------------------------------------------------------------------
idx  xtra  dist     idx  xtra  dist       idx  xtra  dist
--------------------------------------------------------------------
0    0     1        10   4     33-48      20    9   1025-1536
1    0     2        11   4     49-64      21    9   1537-2048
2    0     3        12   5     65-96      22   10   2049-3072
3    0     4        13   5     97-128     23   10   3073-4096
4    1     5,6      14   6     129-192    24   11   4097-6144
5    1     7,8      15   6     193-256    25   11   6145-8192
6    2     9-12     16   7     257-384    26   12   8193-12288
7    2     13-16    17   7     385-512    27   12   12289-16384
8    3     17-24    18   8     513-768    28   13   16385-24576
9    3     25-32    19   8     769-1024   29   13   24577-32768
30   14   32769-49152
31   14   49153-65536
--------------------------------------------------------------------
private boolean
private static final int[]
private static final int[]
FIXED_LITERALS

Huffman Fixed Literal / Distance tables for mode 1

private final InputStream
private final HuffmanDecoder.DecodingMemory
private BitInputStream
private static final short[]
RUN_LENGTH_TABLE

--------------------------------------------------------------------
idx  xtra  base     idx  xtra  base     idx  xtra  base
--------------------------------------------------------------------
257   0     3       267   1   15,16     277   4   67-82
258   0     4       268   1   17,18     278   4   83-98
259   0     5       269   2   19-22     279   4   99-114
260   0     6       270   2   23-26     280   4   115-130
261   0     7       271   2   27-30     281   5   131-162
262   0     8       272   2   31-34     282   5   163-194
263   0     9       273   3   35-42     283   5   195-226
264   0     10      274   3   43-50     284   5   227-257
265   1     11,12   275   3   51-58     285   16  3
266   1     13,14   276   3   59-66
--------------------------------------------------------------------
private HuffmanDecoder.DecoderState

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv int
private static HuffmanDecoder.BinaryTreeNode
buildTree(final int[] litTable)

public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.
public int
decode(final byte[] b)

public int
decode(final byte[] b, final int off, final int len)

pack-priv long
private static int[]
getCodes(final int[] litTable)

private static int
private static void
populateDynamicTables(final BitInputStream reader, final int[] literals, final int[] distances)

private static long
readBits(final BitInputStream reader, final int numBits)

private long
readBits(final int numBits)

private int[][]
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CODE_LENGTHS_ORDERback to summary
private static final int[] CODE_LENGTHS_ORDER

When using dynamic huffman codes the order in which the values are stored follows the positioning below

DISTANCE_TABLEback to summary
private static final int[] DISTANCE_TABLE
--------------------------------------------------------------------
idx  xtra  dist     idx  xtra  dist       idx  xtra  dist
--------------------------------------------------------------------
0    0     1        10   4     33-48      20    9   1025-1536
1    0     2        11   4     49-64      21    9   1537-2048
2    0     3        12   5     65-96      22   10   2049-3072
3    0     4        13   5     97-128     23   10   3073-4096
4    1     5,6      14   6     129-192    24   11   4097-6144
5    1     7,8      15   6     193-256    25   11   6145-8192
6    2     9-12     16   7     257-384    26   12   8193-12288
7    2     13-16    17   7     385-512    27   12   12289-16384
8    3     17-24    18   8     513-768    28   13   16385-24576
9    3     25-32    19   8     769-1024   29   13   24577-32768
30   14   32769-49152
31   14   49153-65536
--------------------------------------------------------------------
value = (base of distance) << 4 | (number of extra bits to read)
finalBlockback to summary
private boolean finalBlock
FIXED_DISTANCEback to summary
private static final int[] FIXED_DISTANCE
FIXED_LITERALSback to summary
private static final int[] FIXED_LITERALS

Huffman Fixed Literal / Distance tables for mode 1

inback to summary
private final InputStream in
memoryback to summary
private final HuffmanDecoder.DecodingMemory memory
readerback to summary
private BitInputStream reader
RUN_LENGTH_TABLEback to summary
private static final short[] RUN_LENGTH_TABLE
--------------------------------------------------------------------
idx  xtra  base     idx  xtra  base     idx  xtra  base
--------------------------------------------------------------------
257   0     3       267   1   15,16     277   4   67-82
258   0     4       268   1   17,18     278   4   83-98
259   0     5       269   2   19-22     279   4   99-114
260   0     6       270   2   23-26     280   4   115-130
261   0     7       271   2   27-30     281   5   131-162
262   0     8       272   2   31-34     282   5   163-194
263   0     9       273   3   35-42     283   5   195-226
264   0     10      274   3   43-50     284   5   227-257
265   1     11,12   275   3   51-58     285   16  3
266   1     13,14   276   3   59-66
--------------------------------------------------------------------
value = (base of run length) << 5 | (number of extra bits to read)
stateback to summary
private HuffmanDecoder.DecoderState state

Constructor Detail

HuffmanDecoderback to summary
pack-priv HuffmanDecoder(final InputStream in)

Method Detail

availableback to summary
pack-priv int available() throws IOException
buildTreeback to summary
private static HuffmanDecoder.BinaryTreeNode buildTree(final int[] litTable)
closeback to summary
public void close()

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
decodeback to summary
public int decode(final byte[] b) throws IOException
decodeback to summary
public int decode(final byte[] b, final int off, final int len) throws IOException
getBytesReadback to summary
pack-priv long getBytesRead()
Since
1.17
getCodesback to summary
private static int[] getCodes(final int[] litTable)
nextSymbolback to summary
private static int nextSymbol(final BitInputStream reader, final HuffmanDecoder.BinaryTreeNode tree) throws IOException
populateDynamicTablesback to summary
private static void populateDynamicTables(final BitInputStream reader, final int[] literals, final int[] distances) throws IOException
readBitsback to summary
private static long readBits(final BitInputStream reader, final int numBits) throws IOException
readBitsback to summary
private long readBits(final int numBits) throws IOException
readDynamicTablesback to summary
private int[][] readDynamicTables() throws IOException
switchToUncompressedStateback to summary
private void switchToUncompressedState() throws IOException
org.apache.commons.compress.compressors.deflate64 back to summary

private final Class HuffmanDecoder.BinaryTreeNode

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.commons.compress.compressors.deflate64.HuffmanDecoder.BinaryTreeNode

Field Summary

Modifier and TypeField and Description
private final int
pack-priv HuffmanDecoder.BinaryTreeNode
pack-priv int
pack-priv HuffmanDecoder.BinaryTreeNode

Constructor Summary

AccessConstructor and Description
private
BinaryTreeNode(final int bits)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
leaf(final int symbol)

pack-priv HuffmanDecoder.BinaryTreeNode
left()

pack-priv HuffmanDecoder.BinaryTreeNode
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bitsback to summary
private final int bits
leftNodeback to summary
pack-priv HuffmanDecoder.BinaryTreeNode leftNode
literalback to summary
pack-priv int literal
rightNodeback to summary
pack-priv HuffmanDecoder.BinaryTreeNode rightNode

Constructor Detail

BinaryTreeNodeback to summary
private BinaryTreeNode(final int bits)

Method Detail

leafback to summary
pack-priv void leaf(final int symbol)
leftback to summary
pack-priv HuffmanDecoder.BinaryTreeNode left()
rightback to summary
pack-priv HuffmanDecoder.BinaryTreeNode right()
org.apache.commons.compress.compressors.deflate64 back to summary

private abstract Class HuffmanDecoder.DecoderState

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.commons.compress.compressors.deflate64.HuffmanDecoder.DecoderState
Known Direct Subclasses
org.apache.commons.compress.compressors.deflate64.HuffmanDecoder.HuffmanCodes, org.apache.commons.compress.compressors.deflate64.HuffmanDecoder.InitialState, org.apache.commons.compress.compressors.deflate64.HuffmanDecoder.UncompressedState

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv abstract int
pack-priv abstract boolean
pack-priv abstract int
read(byte[] b, int off, int len)

pack-priv abstract HuffmanState
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DecoderStateback to summary
private DecoderState()

Method Detail

availableback to summary
pack-priv abstract int available() throws IOException
hasDataback to summary
pack-priv abstract boolean hasData()
readback to summary
pack-priv abstract int read(byte[] b, int off, int len) throws IOException
stateback to summary
pack-priv abstract HuffmanState state()
org.apache.commons.compress.compressors.deflate64 back to summary

private final Class HuffmanDecoder.DecodingMemory

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.commons.compress.compressors.deflate64.HuffmanDecoder.DecodingMemory

Field Summary

Modifier and TypeField and Description
private final int
private final byte[]
private int
private boolean

Constructor Summary

AccessConstructor and Description
private
private
DecodingMemory(final int bits)

Method Summary

Modifier and TypeMethod and Description
pack-priv byte
add(final byte b)

pack-priv void
add(final byte[] b, final int off, final int len)

private int
incCounter(final int counter)

pack-priv void
recordToBuffer(final int distance, final int length, final byte[] buff)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

maskback to summary
private final int mask
memoryback to summary
private final byte[] memory
wHeadback to summary
private int wHead
wrappedAroundback to summary
private boolean wrappedAround

Constructor Detail

DecodingMemoryback to summary
private DecodingMemory()
DecodingMemoryback to summary
private DecodingMemory(final int bits)

Method Detail

addback to summary
pack-priv byte add(final byte b)
addback to summary
pack-priv void add(final byte[] b, final int off, final int len)
incCounterback to summary
private int incCounter(final int counter)
recordToBufferback to summary
pack-priv void recordToBuffer(final int distance, final int length, final byte[] buff)
org.apache.commons.compress.compressors.deflate64 back to summary

private final Class HuffmanDecoder.HuffmanCodes

extends DecoderState
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final HuffmanDecoder.BinaryTreeNode
private boolean
private final HuffmanDecoder.BinaryTreeNode
private byte[]
private int
private int
private final HuffmanState

Constructor Summary

AccessConstructor and Description
pack-priv
HuffmanCodes(final HuffmanState state, final int[] lengths, final int[] distance)

Method Summary

Modifier and TypeMethod and Description
pack-priv int
private int
copyFromRunBuffer(final byte[] b, final int off, final int len)

private int
decodeNext(final byte[] b, final int off, final int len)

pack-priv boolean
pack-priv int
read(final byte[] b, final int off, final int len)

Implements abstract org.apache.commons.compress.compressors.deflate64.HuffmanDecoder.DecoderState.read.

pack-priv HuffmanState

Field Detail

distanceTreeback to summary
private final HuffmanDecoder.BinaryTreeNode distanceTree
endOfBlockback to summary
private boolean endOfBlock
lengthTreeback to summary
private final HuffmanDecoder.BinaryTreeNode lengthTree
runBufferback to summary
private byte[] runBuffer
runBufferLengthback to summary
private int runBufferLength
runBufferPosback to summary
private int runBufferPos
stateback to summary
private final HuffmanState state

Constructor Detail

HuffmanCodesback to summary
pack-priv HuffmanCodes(final HuffmanState state, final int[] lengths, final int[] distance)

Method Detail

availableback to summary
pack-priv int available()

Implements abstract org.apache.commons.compress.compressors.deflate64.HuffmanDecoder.DecoderState.available.

Annotations
@Override
copyFromRunBufferback to summary
private int copyFromRunBuffer(final byte[] b, final int off, final int len)
decodeNextback to summary
private int decodeNext(final byte[] b, final int off, final int len) throws IOException
hasDataback to summary
pack-priv boolean hasData()

Implements abstract org.apache.commons.compress.compressors.deflate64.HuffmanDecoder.DecoderState.hasData.

Annotations
@Override
readback to summary
pack-priv int read(final byte[] b, final int off, final int len) throws IOException

Implements abstract org.apache.commons.compress.compressors.deflate64.HuffmanDecoder.DecoderState.read.

Annotations
@Override
stateback to summary
pack-priv HuffmanState state()

Implements abstract org.apache.commons.compress.compressors.deflate64.HuffmanDecoder.DecoderState.state.

Annotations
@Override
org.apache.commons.compress.compressors.deflate64 back to summary

private final Class HuffmanDecoder.InitialState

extends DecoderState
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv int
pack-priv boolean
pack-priv int
read(final byte[] b, final int off, final int len)

Implements abstract org.apache.commons.compress.compressors.deflate64.HuffmanDecoder.DecoderState.read.

pack-priv HuffmanState

Constructor Detail

InitialStateback to summary
private InitialState()

Method Detail

availableback to summary
pack-priv int available()

Implements abstract org.apache.commons.compress.compressors.deflate64.HuffmanDecoder.DecoderState.available.

Annotations
@Override
hasDataback to summary
pack-priv boolean hasData()

Implements abstract org.apache.commons.compress.compressors.deflate64.HuffmanDecoder.DecoderState.hasData.

Annotations
@Override
readback to summary
pack-priv int read(final byte[] b, final int off, final int len) throws IOException

Implements abstract org.apache.commons.compress.compressors.deflate64.HuffmanDecoder.DecoderState.read.

Annotations
@Override
stateback to summary
pack-priv HuffmanState state()

Implements abstract org.apache.commons.compress.compressors.deflate64.HuffmanDecoder.DecoderState.state.

Annotations
@Override
org.apache.commons.compress.compressors.deflate64 back to summary

private final Class HuffmanDecoder.UncompressedState

extends DecoderState
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final long
private long

Constructor Summary

AccessConstructor and Description
private
UncompressedState(final long blockLength)

Method Summary

Modifier and TypeMethod and Description
pack-priv int
pack-priv boolean
pack-priv int
read(final byte[] b, final int off, final int len)

Implements abstract org.apache.commons.compress.compressors.deflate64.HuffmanDecoder.DecoderState.read.

pack-priv HuffmanState

Field Detail

blockLengthback to summary
private final long blockLength
readback to summary
private long read

Constructor Detail

UncompressedStateback to summary
private UncompressedState(final long blockLength)

Method Detail

availableback to summary
pack-priv int available() throws IOException

Implements abstract org.apache.commons.compress.compressors.deflate64.HuffmanDecoder.DecoderState.available.

Annotations
@Override
hasDataback to summary
pack-priv boolean hasData()

Implements abstract org.apache.commons.compress.compressors.deflate64.HuffmanDecoder.DecoderState.hasData.

Annotations
@Override
readback to summary
pack-priv int read(final byte[] b, final int off, final int len) throws IOException

Implements abstract org.apache.commons.compress.compressors.deflate64.HuffmanDecoder.DecoderState.read.

Annotations
@Override
stateback to summary
pack-priv HuffmanState state()

Implements abstract org.apache.commons.compress.compressors.deflate64.HuffmanDecoder.DecoderState.state.

Annotations
@Override