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 BitStream
bits
The stream of bits read from the input streamprivate CircularBuffer
buffer
Output buffer holding the decompressed dataprivate int
dictionarySize
The size of the sliding dictionary (4K or 8K)private BinaryTree
distanceTree
The binary tree containing the 64 encoded distancesprivate java.io.InputStream
in
The underlying stream containing the compressed dataprivate BinaryTree
lengthTree
The binary tree containing the 64 encoded lengthsprivate BinaryTree
literalTree
The binary tree containing the 256 encoded literals (null when only two trees are used)private int
minimumMatchLength
private int
numberOfTrees
The number of Shannon-Fano trees (2 or 3)private long
treeSizes
private long
uncompressedCount
-
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 void
close()
private void
fillBuffer()
Fill the sliding dictionary with more data.long
getCompressedCount()
long
getUncompressedCount()
private void
init()
Reads the encoded binary trees and prepares the bit stream.int
read()
-
-
-
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.IOException
Reads the encoded binary trees and prepares the bit stream.- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException
- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
getCompressedCount
public long getCompressedCount()
- Specified by:
getCompressedCount
in interfaceInputStreamStatistics
- Returns:
- the amount of raw or compressed bytes read by the stream
- Since:
- 1.17
-
getUncompressedCount
public long getUncompressedCount()
- Specified by:
getUncompressedCount
in interfaceInputStreamStatistics
- Returns:
- the amount of decompressed bytes returned by the stream
- Since:
- 1.17
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
- Throws:
java.io.IOException
- Since:
- 1.17
-
fillBuffer
private void fillBuffer() throws java.io.IOException
Fill the sliding dictionary with more data.- Throws:
java.io.IOException
-
-