类 LZWCompressor

  • 所有已实现的接口:
    Compressor, Debugable

    public class LZWCompressor
    extends java.lang.Object
    implements Compressor
    LZW compress algorithm
    • 方法概要

      所有方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      int compress​(byte[] in_data, int in_len, byte[] out_data)
      s = empty string; while (there is still data to be read) { ch = read a character; if (dictionary contains s+ch) { s = s+ch; } else { encode s to output file; add s+ch to dictionary; s = ch; } } encode s to output file;
      int decompress​(byte[] in_data, int in_len, byte[] out_data)
      prevcode = read in a code; decode/output prevcode; while (there is still data to read) { currcode = read in a code; entry = translation of currcode from dictionary; output entry; ch = first char of entry; add ((translation of prevcode)+ch) to dictionary; prevcode = currcode; }
      void setDebug​(boolean isDebug)
      enable Debug or not, default should be not enabled
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 构造器详细资料

      • LZWCompressor

        public LZWCompressor()
    • 方法详细资料

      • compress

        public int compress​(byte[] in_data,
                            int in_len,
                            byte[] out_data)
        s = empty string; while (there is still data to be read) { ch = read a character; if (dictionary contains s+ch) { s = s+ch; } else { encode s to output file; add s+ch to dictionary; s = ch; } } encode s to output file;
        指定者:
        compress 在接口中 Compressor
        参数:
        in_data - input
        in_len - length of input
        out_data - output
        返回:
        offset in output
      • decompress

        public int decompress​(byte[] in_data,
                              int in_len,
                              byte[] out_data)
        prevcode = read in a code; decode/output prevcode; while (there is still data to read) { currcode = read in a code; entry = translation of currcode from dictionary; output entry; ch = first char of entry; add ((translation of prevcode)+ch) to dictionary; prevcode = currcode; }
        指定者:
        decompress 在接口中 Compressor
        参数:
        in_data - input
        in_len - length of input
        out_data - output
        返回:
        offset in output
      • setDebug

        public void setDebug​(boolean isDebug)
        从接口复制的说明: Debugable
        enable Debug or not, default should be not enabled
        指定者:
        setDebug 在接口中 Debugable
        参数:
        isDebug - is debug