home *** CD-ROM | disk | FTP | other *** search
- package java.util.zip;
-
- import java.security.AccessController;
- import sun.security.action.LoadLibraryAction;
-
- public class Deflater {
- private long strm;
- private byte[] buf;
- private int off;
- private int len;
- private int level;
- private int strategy;
- private boolean setParams;
- private boolean finish;
- private boolean finished;
- public static final int DEFLATED = 8;
- public static final int NO_COMPRESSION = 0;
- public static final int BEST_SPEED = 1;
- public static final int BEST_COMPRESSION = 9;
- public static final int DEFAULT_COMPRESSION = -1;
- public static final int FILTERED = 1;
- public static final int HUFFMAN_ONLY = 2;
- public static final int DEFAULT_STRATEGY = 0;
-
- public Deflater(int var1, boolean var2) {
- this.buf = new byte[0];
- this.level = var1;
- this.strategy = 0;
- this.strm = init(var1, 0, var2);
- }
-
- public Deflater(int var1) {
- this(var1, false);
- }
-
- public Deflater() {
- this(-1, false);
- }
-
- public synchronized void setInput(byte[] var1, int var2, int var3) {
- if (var1 == null) {
- throw new NullPointerException();
- } else if (var2 >= 0 && var3 >= 0 && var2 + var3 <= var1.length) {
- this.buf = var1;
- this.off = var2;
- this.len = var3;
- } else {
- throw new ArrayIndexOutOfBoundsException();
- }
- }
-
- public void setInput(byte[] var1) {
- this.setInput(var1, 0, var1.length);
- }
-
- public synchronized void setDictionary(byte[] var1, int var2, int var3) {
- if (this.strm != 0L && var1 != null) {
- if (var2 >= 0 && var3 >= 0 && var2 + var3 <= var1.length) {
- setDictionary(this.strm, var1, var2, var3);
- } else {
- throw new ArrayIndexOutOfBoundsException();
- }
- } else {
- throw new NullPointerException();
- }
- }
-
- public void setDictionary(byte[] var1) {
- this.setDictionary(var1, 0, var1.length);
- }
-
- public synchronized void setStrategy(int var1) {
- switch (var1) {
- case 0:
- case 1:
- case 2:
- if (this.strategy != var1) {
- this.strategy = var1;
- this.setParams = true;
- }
-
- return;
- default:
- throw new IllegalArgumentException();
- }
- }
-
- public synchronized void setLevel(int var1) {
- if ((var1 < 0 || var1 > 9) && var1 != -1) {
- throw new IllegalArgumentException("invalid compression level");
- } else {
- if (this.level != var1) {
- this.level = var1;
- this.setParams = true;
- }
-
- }
- }
-
- public boolean needsInput() {
- return this.len <= 0;
- }
-
- public synchronized void finish() {
- this.finish = true;
- }
-
- public synchronized boolean finished() {
- return this.finished;
- }
-
- public synchronized int deflate(byte[] var1, int var2, int var3) {
- if (var1 == null) {
- throw new NullPointerException();
- } else if (var2 >= 0 && var3 >= 0 && var2 + var3 <= var1.length) {
- return this.deflateBytes(var1, var2, var3);
- } else {
- throw new ArrayIndexOutOfBoundsException();
- }
- }
-
- public int deflate(byte[] var1) {
- return this.deflate(var1, 0, var1.length);
- }
-
- public synchronized int getAdler() {
- if (this.strm == 0L) {
- throw new NullPointerException();
- } else {
- return getAdler(this.strm);
- }
- }
-
- public synchronized int getTotalIn() {
- if (this.strm == 0L) {
- throw new NullPointerException();
- } else {
- return getTotalIn(this.strm);
- }
- }
-
- public synchronized int getTotalOut() {
- if (this.strm == 0L) {
- throw new NullPointerException();
- } else {
- return getTotalOut(this.strm);
- }
- }
-
- public synchronized void reset() {
- if (this.strm == 0L) {
- throw new NullPointerException();
- } else {
- reset(this.strm);
- this.finish = false;
- this.finished = false;
- this.off = this.len = 0;
- }
- }
-
- public synchronized void end() {
- if (this.strm != 0L) {
- end(this.strm);
- this.strm = 0L;
- }
-
- }
-
- protected void finalize() {
- this.end();
- }
-
- private static native void initIDs();
-
- private static native long init(int var0, int var1, boolean var2);
-
- private static native void setDictionary(long var0, byte[] var2, int var3, int var4);
-
- private native int deflateBytes(byte[] var1, int var2, int var3);
-
- private static native int getAdler(long var0);
-
- private static native int getTotalIn(long var0);
-
- private static native int getTotalOut(long var0);
-
- private static native void reset(long var0);
-
- private static native void end(long var0);
-
- static {
- AccessController.doPrivileged(new LoadLibraryAction("zip"));
- initIDs();
- }
- }
-