home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / rt.jar / java / util / zip / Deflater.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-23  |  2.2 KB  |  125 lines

  1. package java.util.zip;
  2.  
  3. public class Deflater {
  4.    private int strm;
  5.    private byte[] buf;
  6.    private int off;
  7.    private int len;
  8.    private int level;
  9.    private int strategy;
  10.    private boolean setParams;
  11.    private boolean finish;
  12.    private boolean finished;
  13.    public static final int DEFLATED = 8;
  14.    public static final int NO_COMPRESSION = 0;
  15.    public static final int BEST_SPEED = 1;
  16.    public static final int BEST_COMPRESSION = 9;
  17.    public static final int DEFAULT_COMPRESSION = -1;
  18.    public static final int FILTERED = 1;
  19.    public static final int HUFFMAN_ONLY = 2;
  20.    public static final int DEFAULT_STRATEGY = 0;
  21.  
  22.    public Deflater(int var1, boolean var2) {
  23.       this.buf = new byte[0];
  24.       this.level = var1;
  25.       this.strategy = 0;
  26.       this.init(var2);
  27.    }
  28.  
  29.    public Deflater(int var1) {
  30.       this(var1, false);
  31.    }
  32.  
  33.    public Deflater() {
  34.       this(-1, false);
  35.    }
  36.  
  37.    public synchronized void setInput(byte[] var1, int var2, int var3) {
  38.       if (var1 == null) {
  39.          throw new NullPointerException();
  40.       } else if (var2 >= 0 && var3 >= 0 && var2 + var3 <= var1.length) {
  41.          this.buf = var1;
  42.          this.off = var2;
  43.          this.len = var3;
  44.       } else {
  45.          throw new ArrayIndexOutOfBoundsException();
  46.       }
  47.    }
  48.  
  49.    public void setInput(byte[] var1) {
  50.       this.setInput(var1);
  51.    }
  52.  
  53.    public synchronized native void setDictionary(byte[] var1, int var2, int var3);
  54.  
  55.    public void setDictionary(byte[] var1) {
  56.       this.setDictionary(var1, 0, var1.length);
  57.    }
  58.  
  59.    public synchronized void setStrategy(int var1) {
  60.       switch (var1) {
  61.          case 0:
  62.          case 1:
  63.          case 2:
  64.             if (this.strategy != var1) {
  65.                this.strategy = var1;
  66.                this.setParams = true;
  67.             }
  68.  
  69.             return;
  70.          default:
  71.             throw new IllegalArgumentException();
  72.       }
  73.    }
  74.  
  75.    public synchronized void setLevel(int var1) {
  76.       if ((this.level < 0 || this.level > 9) && this.level != -1) {
  77.          throw new IllegalArgumentException("invalid compression level");
  78.       } else {
  79.          if (this.level != this.level) {
  80.             this.level = this.level;
  81.             this.setParams = true;
  82.          }
  83.  
  84.       }
  85.    }
  86.  
  87.    public boolean needsInput() {
  88.       return this.len <= 0;
  89.    }
  90.  
  91.    public synchronized void finish() {
  92.       this.finish = true;
  93.    }
  94.  
  95.    public synchronized boolean finished() {
  96.       return this.finished;
  97.    }
  98.  
  99.    public synchronized native int deflate(byte[] var1, int var2, int var3);
  100.  
  101.    public int deflate(byte[] var1) {
  102.       return this.deflate(var1, 0, var1.length);
  103.    }
  104.  
  105.    public synchronized native int getAdler();
  106.  
  107.    public synchronized native int getTotalIn();
  108.  
  109.    public synchronized native int getTotalOut();
  110.  
  111.    public synchronized native void reset();
  112.  
  113.    public synchronized native void end();
  114.  
  115.    protected void finalize() {
  116.       this.end();
  117.    }
  118.  
  119.    private native void init(boolean var1);
  120.  
  121.    static {
  122.       System.loadLibrary("zip");
  123.    }
  124. }
  125.