home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / java / util / zip / Deflater.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  2.5 KB  |  196 lines

  1. package java.util.zip;
  2.  
  3. import java.security.AccessController;
  4. import sun.security.action.LoadLibraryAction;
  5.  
  6. public class Deflater {
  7.    private long strm;
  8.    private byte[] buf;
  9.    private int off;
  10.    private int len;
  11.    private int level;
  12.    private int strategy;
  13.    private boolean setParams;
  14.    private boolean finish;
  15.    private boolean finished;
  16.    public static final int DEFLATED = 8;
  17.    public static final int NO_COMPRESSION = 0;
  18.    public static final int BEST_SPEED = 1;
  19.    public static final int BEST_COMPRESSION = 9;
  20.    public static final int DEFAULT_COMPRESSION = -1;
  21.    public static final int FILTERED = 1;
  22.    public static final int HUFFMAN_ONLY = 2;
  23.    public static final int DEFAULT_STRATEGY = 0;
  24.  
  25.    public Deflater(int var1, boolean var2) {
  26.       this.buf = new byte[0];
  27.       this.level = var1;
  28.       this.strategy = 0;
  29.       this.strm = init(var1, 0, var2);
  30.    }
  31.  
  32.    public Deflater(int var1) {
  33.       this(var1, false);
  34.    }
  35.  
  36.    public Deflater() {
  37.       this(-1, false);
  38.    }
  39.  
  40.    public synchronized void setInput(byte[] var1, int var2, int var3) {
  41.       if (var1 == null) {
  42.          throw new NullPointerException();
  43.       } else if (var2 >= 0 && var3 >= 0 && var2 + var3 <= var1.length) {
  44.          this.buf = var1;
  45.          this.off = var2;
  46.          this.len = var3;
  47.       } else {
  48.          throw new ArrayIndexOutOfBoundsException();
  49.       }
  50.    }
  51.  
  52.    public void setInput(byte[] var1) {
  53.       this.setInput(var1, 0, var1.length);
  54.    }
  55.  
  56.    public synchronized void setDictionary(byte[] var1, int var2, int var3) {
  57.       if (this.strm != 0L && var1 != null) {
  58.          if (var2 >= 0 && var3 >= 0 && var2 + var3 <= var1.length) {
  59.             setDictionary(this.strm, var1, var2, var3);
  60.          } else {
  61.             throw new ArrayIndexOutOfBoundsException();
  62.          }
  63.       } else {
  64.          throw new NullPointerException();
  65.       }
  66.    }
  67.  
  68.    public void setDictionary(byte[] var1) {
  69.       this.setDictionary(var1, 0, var1.length);
  70.    }
  71.  
  72.    public synchronized void setStrategy(int var1) {
  73.       switch (var1) {
  74.          case 0:
  75.          case 1:
  76.          case 2:
  77.             if (this.strategy != var1) {
  78.                this.strategy = var1;
  79.                this.setParams = true;
  80.             }
  81.  
  82.             return;
  83.          default:
  84.             throw new IllegalArgumentException();
  85.       }
  86.    }
  87.  
  88.    public synchronized void setLevel(int var1) {
  89.       if ((var1 < 0 || var1 > 9) && var1 != -1) {
  90.          throw new IllegalArgumentException("invalid compression level");
  91.       } else {
  92.          if (this.level != var1) {
  93.             this.level = var1;
  94.             this.setParams = true;
  95.          }
  96.  
  97.       }
  98.    }
  99.  
  100.    public boolean needsInput() {
  101.       return this.len <= 0;
  102.    }
  103.  
  104.    public synchronized void finish() {
  105.       this.finish = true;
  106.    }
  107.  
  108.    public synchronized boolean finished() {
  109.       return this.finished;
  110.    }
  111.  
  112.    public synchronized int deflate(byte[] var1, int var2, int var3) {
  113.       if (var1 == null) {
  114.          throw new NullPointerException();
  115.       } else if (var2 >= 0 && var3 >= 0 && var2 + var3 <= var1.length) {
  116.          return this.deflateBytes(var1, var2, var3);
  117.       } else {
  118.          throw new ArrayIndexOutOfBoundsException();
  119.       }
  120.    }
  121.  
  122.    public int deflate(byte[] var1) {
  123.       return this.deflate(var1, 0, var1.length);
  124.    }
  125.  
  126.    public synchronized int getAdler() {
  127.       if (this.strm == 0L) {
  128.          throw new NullPointerException();
  129.       } else {
  130.          return getAdler(this.strm);
  131.       }
  132.    }
  133.  
  134.    public synchronized int getTotalIn() {
  135.       if (this.strm == 0L) {
  136.          throw new NullPointerException();
  137.       } else {
  138.          return getTotalIn(this.strm);
  139.       }
  140.    }
  141.  
  142.    public synchronized int getTotalOut() {
  143.       if (this.strm == 0L) {
  144.          throw new NullPointerException();
  145.       } else {
  146.          return getTotalOut(this.strm);
  147.       }
  148.    }
  149.  
  150.    public synchronized void reset() {
  151.       if (this.strm == 0L) {
  152.          throw new NullPointerException();
  153.       } else {
  154.          reset(this.strm);
  155.          this.finish = false;
  156.          this.finished = false;
  157.          this.off = this.len = 0;
  158.       }
  159.    }
  160.  
  161.    public synchronized void end() {
  162.       if (this.strm != 0L) {
  163.          end(this.strm);
  164.          this.strm = 0L;
  165.       }
  166.  
  167.    }
  168.  
  169.    protected void finalize() {
  170.       this.end();
  171.    }
  172.  
  173.    private static native void initIDs();
  174.  
  175.    private static native long init(int var0, int var1, boolean var2);
  176.  
  177.    private static native void setDictionary(long var0, byte[] var2, int var3, int var4);
  178.  
  179.    private native int deflateBytes(byte[] var1, int var2, int var3);
  180.  
  181.    private static native int getAdler(long var0);
  182.  
  183.    private static native int getTotalIn(long var0);
  184.  
  185.    private static native int getTotalOut(long var0);
  186.  
  187.    private static native void reset(long var0);
  188.  
  189.    private static native void end(long var0);
  190.  
  191.    static {
  192.       AccessController.doPrivileged(new LoadLibraryAction("zip"));
  193.       initIDs();
  194.    }
  195. }
  196.