Class ExplodingInputStream
java.lang.Object
java.io.InputStream
org.apache.commons.compress.archivers.zip.ExplodingInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable,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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BitStreamThe stream of bits read from the input streamprivate final CircularBufferOutput buffer holding the decompressed dataprivate final intThe size of the sliding dictionary (4K or 8K)private BinaryTreeThe binary tree containing the 64 encoded distancesprivate final InputStreamThe underlying stream containing the compressed dataprivate BinaryTreeThe binary tree containing the 64 encoded lengthsprivate BinaryTreeThe binary tree containing the 256 encoded literals (null when only two trees are used)private final intprivate final intThe number of Shannon-Fano trees (2 or 3)private longprivate long -
Constructor Summary
ConstructorsConstructorDescriptionExplodingInputStream(int dictionarySize, int numberOfTrees, InputStream in) Create a new stream decompressing the content of the specified stream using the explode algorithm. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()private voidFill the sliding dictionary with more data.longGets the amount of raw or compressed bytes read by the stream.longGets the amount of decompressed bytes returned by the stream.private voidinit()Reads the encoded binary trees and prepares the bit stream.intread()Methods inherited from class java.io.InputStream
available, mark, markSupported, read, read, reset, skip
-
Field Details
-
in
The underlying stream containing the compressed data -
bits
The stream of bits read from the input stream -
dictionarySize
private final int dictionarySizeThe size of the sliding dictionary (4K or 8K) -
numberOfTrees
private final int numberOfTreesThe number of Shannon-Fano trees (2 or 3) -
minimumMatchLength
private final int minimumMatchLength -
literalTree
The binary tree containing the 256 encoded literals (null when only two trees are used) -
lengthTree
The binary tree containing the 64 encoded lengths -
distanceTree
The binary tree containing the 64 encoded distances -
buffer
Output buffer holding the decompressed data -
uncompressedCount
private long uncompressedCount -
treeSizes
private long treeSizes
-
-
Constructor Details
-
ExplodingInputStream
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 Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException- Since:
- 1.17
-
fillBuffer
Fill the sliding dictionary with more data.- Throws:
IOException- on error.
-
getCompressedCount
public long getCompressedCount()Description copied from interface:InputStreamStatisticsGets the amount of raw or compressed bytes read by the stream.- Specified by:
getCompressedCountin interfaceInputStreamStatistics- Returns:
- the amount of raw or compressed bytes read by the stream.
- Since:
- 1.17
-
getUncompressedCount
public long getUncompressedCount()Description copied from interface:InputStreamStatisticsGets the amount of decompressed bytes returned by the stream.- Specified by:
getUncompressedCountin interfaceInputStreamStatistics- Returns:
- the amount of decompressed bytes returned by the stream.
- Since:
- 1.17
-
init
Reads the encoded binary trees and prepares the bit stream.- Throws:
IOException
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-