Class 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
    • 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()  
      • Methods inherited from class java.io.InputStream

        available, mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 class java.io.InputStream
        Throws:
        java.io.IOException
      • getCompressedCount

        public long getCompressedCount()
        Specified by:
        getCompressedCount in interface InputStreamStatistics
        Returns:
        the amount of raw or compressed bytes read by the stream
        Since:
        1.17
      • getUncompressedCount

        public long getUncompressedCount()
        Specified by:
        getUncompressedCount in interface InputStreamStatistics
        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 interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.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