Class MyLzwCompressor


  • public class MyLzwCompressor
    extends java.lang.Object
    • Field Detail

      • codeSize

        private int codeSize
      • initialCodeSize

        private final int initialCodeSize
      • codes

        private int codes
      • byteOrder

        private final java.nio.ByteOrder byteOrder
      • earlyLimit

        private final boolean earlyLimit
      • clearCode

        private final int clearCode
      • eoiCode

        private final int eoiCode
    • Constructor Detail

      • MyLzwCompressor

        public MyLzwCompressor​(int initialCodeSize,
                               java.nio.ByteOrder byteOrder,
                               boolean earlyLimit)
      • MyLzwCompressor

        public MyLzwCompressor​(int initialCodeSize,
                               java.nio.ByteOrder byteOrder,
                               boolean earlyLimit,
                               MyLzwCompressor.Listener listener)
    • Method Detail

      • initializeStringTable

        private void initializeStringTable()
      • clearTable

        private void clearTable()
      • incrementCodeSize

        private void incrementCodeSize()
      • writeDataCode

        private void writeDataCode​(MyBitOutputStream bos,
                                   int code)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • writeClearCode

        private void writeClearCode​(MyBitOutputStream bos)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • writeEoiCode

        private void writeEoiCode​(MyBitOutputStream bos)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • writeCode

        private void writeCode​(MyBitOutputStream bos,
                               int code)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • isInTable

        private boolean isInTable​(byte[] bytes,
                                  int start,
                                  int length)
      • codeFromString

        private int codeFromString​(byte[] bytes,
                                   int start,
                                   int length)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • addTableEntry

        private boolean addTableEntry​(MyBitOutputStream bos,
                                      byte[] bytes,
                                      int start,
                                      int length)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • compress

        public byte[] compress​(byte[] bytes)
                        throws java.io.IOException
        Throws:
        java.io.IOException