Class ExplodingInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.commons.compress.archivers.zip.ExplodingInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,InputStreamStatistics
class ExplodingInputStream extends java.io.InputStream implements InputStreamStatistics
The implode compression method was added to PKZIP 1.01 released in 1989. It was then dropped from PKZIP 2.0 released in 1993 in favor of the deflate method.The algorithm is described in the ZIP File Format Specification.
- Since:
- 1.7
- See Also:
- ZIP File Format Specification
-
-
Field Summary
Fields Modifier and Type Field Description private BitStreambitsThe stream of bits read from the input streamprivate CircularBufferbufferOutput buffer holding the decompressed dataprivate intdictionarySizeThe size of the sliding dictionary (4K or 8K)private BinaryTreedistanceTreeThe binary tree containing the 64 encoded distancesprivate java.io.InputStreaminThe underlying stream containing the compressed dataprivate BinaryTreelengthTreeThe binary tree containing the 64 encoded lengthsprivate BinaryTreeliteralTreeThe binary tree containing the 256 encoded literals (null when only two trees are used)private intminimumMatchLengthprivate intnumberOfTreesThe number of Shannon-Fano trees (2 or 3)private longtreeSizesprivate longuncompressedCount
-
Constructor Summary
Constructors Constructor Description ExplodingInputStream(int dictionarySize, int numberOfTrees, java.io.InputStream in)Create a new stream decompressing the content of the specified stream using the explode algorithm.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()private voidfillBuffer()Fill the sliding dictionary with more data.longgetCompressedCount()longgetUncompressedCount()private voidinit()Reads the encoded binary trees and prepares the bit stream.intread()
-
-
-
Field Detail
-
in
private final java.io.InputStream in
The underlying stream containing the compressed data
-
bits
private BitStream bits
The stream of bits read from the input stream
-
dictionarySize
private final int dictionarySize
The size of the sliding dictionary (4K or 8K)
-
numberOfTrees
private final int numberOfTrees
The number of Shannon-Fano trees (2 or 3)
-
minimumMatchLength
private final int minimumMatchLength
-
literalTree
private BinaryTree literalTree
The binary tree containing the 256 encoded literals (null when only two trees are used)
-
lengthTree
private BinaryTree lengthTree
The binary tree containing the 64 encoded lengths
-
distanceTree
private BinaryTree distanceTree
The binary tree containing the 64 encoded distances
-
buffer
private final CircularBuffer buffer
Output buffer holding the decompressed data
-
uncompressedCount
private long uncompressedCount
-
treeSizes
private long treeSizes
-
-
Constructor Detail
-
ExplodingInputStream
public ExplodingInputStream(int dictionarySize, int numberOfTrees, java.io.InputStream in)Create a new stream decompressing the content of the specified stream using the explode algorithm.- Parameters:
dictionarySize- the size of the sliding dictionary (4096 or 8192)numberOfTrees- the number of trees (2 or 3)in- the compressed data stream
-
-
Method Detail
-
init
private void init() throws java.io.IOExceptionReads the encoded binary trees and prepares the bit stream.- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
getCompressedCount
public long getCompressedCount()
- Specified by:
getCompressedCountin interfaceInputStreamStatistics- Returns:
- the amount of raw or compressed bytes read by the stream
- Since:
- 1.17
-
getUncompressedCount
public long getUncompressedCount()
- Specified by:
getUncompressedCountin interfaceInputStreamStatistics- Returns:
- the amount of decompressed bytes returned by the stream
- Since:
- 1.17
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException- Since:
- 1.17
-
fillBuffer
private void fillBuffer() throws java.io.IOExceptionFill the sliding dictionary with more data.- Throws:
java.io.IOException
-
-