Class LzwInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class LzwInputStream
    extends java.io.InputStream
    This is the generic Shrinkit LZW decompression algorithm. It does not deal with the vagaries of the LZW/1 and LZW/2 data streams. It does, however, deal with dictionary clears (0x100) and the BitInputStream bit sizes.
    • Constructor Summary

      Constructors 
      Constructor Description
      LzwInputStream​(BitInputStream is)
      Create the LzwInputStream based on the given BitInputStream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clearData()
      Provide necessary housekeeping to reset LZW stream between NuFX buffer changes.
      void clearDictionary()
      Clear out the dictionary.
      void fillBuffer()
      Fill the buffer up with some decompressed data.
      int read()
      Answer with the next byte from the (now) decompressed input stream.
      • Methods inherited from class java.io.InputStream

        available, close, 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
    • Constructor Detail

      • LzwInputStream

        public LzwInputStream​(BitInputStream is)
        Create the LzwInputStream based on the given BitInputStream.
        See Also:
        BitInputStream
    • Method Detail

      • read

        public int read()
                 throws java.io.IOException
        Answer with the next byte from the (now) decompressed input stream.
        Specified by:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • fillBuffer

        public void fillBuffer()
                        throws java.io.IOException
        Fill the buffer up with some decompressed data. This may range from one byte to many bytes, depending on what is in the dictionary.
        Throws:
        java.io.IOException
        See Also:
        Wikipedia for the general algorithm
      • clearDictionary

        public void clearDictionary()
        Clear out the dictionary. It will be rebuilt on the next call to fillBuffer.
      • clearData

        public void clearData()
        Provide necessary housekeeping to reset LZW stream between NuFX buffer changes. The dictionary is the only item that is not cleared -- that needs to be done explicitly since behavior between LZW/1 and LZW/2 differ.