Methods Summary |
---|
public synchronized int | deflate(byte[] b, int off, int len)Fills specified buffer with compressed data. Returns actual number
of bytes of compressed data. A return value of 0 indicates that
needsInput() should be called in order to determine if more input
data is required.
if (b == null) {
throw new NullPointerException();
}
if (off < 0 || len < 0 || off > b.length - len) {
throw new ArrayIndexOutOfBoundsException();
}
return deflateBytes(b, off, len);
|
public int | deflate(byte[] b)Fills specified buffer with compressed data. Returns actual number
of bytes of compressed data. A return value of 0 indicates that
needsInput() should be called in order to determine if more input
data is required.
return deflate(b, 0, b.length);
|
private native int | deflateBytes(byte[] b, int off, int len)
|
public synchronized void | end()Closes the compressor and discards any unprocessed input.
This method should be called when the compressor is no longer
being used, but will also be called automatically by the
finalize() method. Once this method is called, the behavior
of the Deflater object is undefined.
if (strm != 0) {
end(strm);
strm = 0;
}
|
private static native void | end(long strm)
|
private void | ensureOpen()
if (strm == 0)
throw new NullPointerException();
|
protected void | finalize()Closes the compressor when garbage is collected.
end();
|
public synchronized void | finish()When called, indicates that compression should end with the current
contents of the input buffer.
finish = true;
|
public synchronized boolean | finished()Returns true if the end of the compressed data output stream has
been reached.
return finished;
|
public synchronized int | getAdler()Returns the ADLER-32 value of the uncompressed data.
ensureOpen();
return getAdler(strm);
|
private static native int | getAdler(long strm)
|
public synchronized long | getBytesRead()Returns the total number of uncompressed bytes input so far.
ensureOpen();
return getBytesRead(strm);
|
private static native long | getBytesRead(long strm)
|
public synchronized long | getBytesWritten()Returns the total number of compressed bytes output so far.
ensureOpen();
return getBytesWritten(strm);
|
private static native long | getBytesWritten(long strm)
|
public int | getTotalIn()Returns the total number of uncompressed bytes input so far.
Since the number of bytes may be greater than
Integer.MAX_VALUE, the {@link #getBytesRead()} method is now
the preferred means of obtaining this information.
return (int) getBytesRead();
|
public int | getTotalOut()Returns the total number of compressed bytes output so far.
Since the number of bytes may be greater than
Integer.MAX_VALUE, the {@link #getBytesWritten()} method is now
the preferred means of obtaining this information.
return (int) getBytesWritten();
|
private static native long | init(int level, int strategy, boolean nowrap)
|
private static native void | initIDs()
|
public boolean | needsInput()Returns true if the input data buffer is empty and setInput()
should be called in order to provide more input.
return len <= 0;
|
public synchronized void | reset()Resets deflater so that a new set of input data can be processed.
Keeps current compression level and strategy settings.
ensureOpen();
reset(strm);
finish = false;
finished = false;
off = len = 0;
|
private static native void | reset(long strm)
|
private static native void | setDictionary(long strm, byte[] b, int off, int len)
|
public synchronized void | setDictionary(byte[] b, int off, int len)Sets preset dictionary for compression. A preset dictionary is used
when the history buffer can be predetermined. When the data is later
uncompressed with Inflater.inflate(), Inflater.getAdler() can be called
in order to get the Adler-32 value of the dictionary required for
decompression.
if (strm == 0 || b == null) {
throw new NullPointerException();
}
if (off < 0 || len < 0 || off > b.length - len) {
throw new ArrayIndexOutOfBoundsException();
}
setDictionary(strm, b, off, len);
|
public void | setDictionary(byte[] b)Sets preset dictionary for compression. A preset dictionary is used
when the history buffer can be predetermined. When the data is later
uncompressed with Inflater.inflate(), Inflater.getAdler() can be called
in order to get the Adler-32 value of the dictionary required for
decompression.
setDictionary(b, 0, b.length);
|
public synchronized void | setInput(byte[] b, int off, int len)Sets input data for compression. This should be called whenever
needsInput() returns true indicating that more input data is required.
if (b== null) {
throw new NullPointerException();
}
if (off < 0 || len < 0 || off > b.length - len) {
throw new ArrayIndexOutOfBoundsException();
}
this.buf = b;
this.off = off;
this.len = len;
|
public void | setInput(byte[] b)Sets input data for compression. This should be called whenever
needsInput() returns true indicating that more input data is required.
setInput(b, 0, b.length);
|
public synchronized void | setLevel(int level)Sets the current compression level to the specified value.
if ((level < 0 || level > 9) && level != DEFAULT_COMPRESSION) {
throw new IllegalArgumentException("invalid compression level");
}
if (this.level != level) {
this.level = level;
setParams = true;
}
|
public synchronized void | setStrategy(int strategy)Sets the compression strategy to the specified value.
switch (strategy) {
case DEFAULT_STRATEGY:
case FILTERED:
case HUFFMAN_ONLY:
break;
default:
throw new IllegalArgumentException();
}
if (this.strategy != strategy) {
this.strategy = strategy;
setParams = true;
}
|