Methods Summary |
---|
private native long | createStream(int level, int strategy1, boolean noHeader1)
|
public int | deflate(byte[] buf)Deflates the data (previously passed to {@code setInput}) into the
supplied buffer.
return deflate(buf, 0, buf.length);
|
public synchronized int | deflate(byte[] buf, int off, int nbytes)Deflates data (previously passed to {@code setInput}) into a specific
region within the supplied buffer.
if (streamHandle == -1) {
throw new IllegalStateException();
}
// avoid int overflow, check null buf
if (off <= buf.length && nbytes >= 0 && off >= 0
&& buf.length - off >= nbytes) {
// put a stub buffer, no effect.
if (null == inputBuffer) {
setInput(STUB_INPUT_BUFFER);
}
return deflateImpl(buf, off, nbytes, streamHandle, flushParm);
}
throw new ArrayIndexOutOfBoundsException();
|
private native synchronized int | deflateImpl(byte[] buf, int off, int nbytes, long handle, int flushParm1)
|
public synchronized void | end()Frees all resources held onto by this deflating algorithm. Any unused
input or output is discarded. While this method is used by {@code
finalize()}, it can be called explicitly in order to free native
resources before the next GC cycle. After {@code end()} was called other
methods will typically throw an {@code IllegalStateException}.
if (streamHandle != -1) {
endImpl(streamHandle);
inputBuffer = null;
streamHandle = -1;
}
|
private native synchronized void | endImpl(long handle)
|
protected void | finalize()
end();
|
public synchronized void | finish()Indicates to the {@code Deflater} that all uncompressed input has been provided
to it.
flushParm = Z_FINISH;
|
public synchronized boolean | finished()Returns whether or not all provided data has been successfully
compressed.
return finished;
|
public synchronized int | getAdler()Returns the Adler32 checksum of uncompressed data currently read. If a
preset dictionary is used getAdler() will return the Adler32 checksum of
the dictionary used.
if (streamHandle == -1) {
throw new IllegalStateException();
}
return getAdlerImpl(streamHandle);
|
private native synchronized int | getAdlerImpl(long handle)
|
public synchronized long | getBytesRead()Returns a long int of total number of bytes read by the {@code Deflater}. This
method performs the same as {@code getTotalIn} except it returns a long value
instead of an integer
// Throw NPE here
if (streamHandle == -1) {
throw new NullPointerException();
}
return getTotalInImpl(streamHandle);
|
public synchronized long | getBytesWritten()Returns a long int of total number of bytes of read by the {@code Deflater}. This
method performs the same as {@code getTotalOut} except it returns a long
value instead of an integer
// Throw NPE here
if (streamHandle == -1) {
throw new NullPointerException();
}
return getTotalOutImpl(streamHandle);
|
public synchronized int | getTotalIn()Returns the total number of bytes of input consumed by the {@code Deflater}.
if (streamHandle == -1) {
throw new IllegalStateException();
}
return (int)getTotalInImpl(streamHandle);
|
private native synchronized long | getTotalInImpl(long handle)
|
public synchronized int | getTotalOut()Returns the total number of compressed bytes output by this {@code Deflater}.
if (streamHandle == -1) {
throw new IllegalStateException();
}
return (int)getTotalOutImpl(streamHandle);
|
private native synchronized long | getTotalOutImpl(long handle)
|
public synchronized boolean | needsInput()Counterpart to setInput(). Indicates whether or not all bytes of
uncompressed input have been consumed by the {@code Deflater}. If needsInput()
returns true setInput() must be called before deflation can continue. If
all bytes of uncompressed data have been provided to the {@code Deflater}
finish() must be called to ensure the compressed data is output.
if (inputBuffer == null) {
return true;
}
return inRead == inLength;
|
private static native void | oneTimeInitialization()
|
public synchronized void | reset()Resets the {@code Deflater} to accept new input without affecting any
previously made settings for the compression strategy or level. This
operation must be called after {@code finished()} returns
{@code true} if the {@code Deflater} is to be reused.
if (streamHandle == -1) {
throw new NullPointerException();
}
flushParm = Z_NO_FLUSH;
finished = false;
resetImpl(streamHandle);
inputBuffer = null;
|
private native synchronized void | resetImpl(long handle)
|
public void | setDictionary(byte[] buf)Sets the dictionary to be used for compression by this {@code Deflater}.
setDictionary() can only be called if this {@code Deflater} supports the writing
of ZLIB headers. This is the default behaviour but can be overridden
using {@code Deflater(int, boolean)}.
setDictionary(buf, 0, buf.length);
|
public synchronized void | setDictionary(byte[] buf, int off, int nbytes)Sets the dictionary to be used for compression by this {@code Deflater}.
setDictionary() can only be called if this {@code Deflater} supports the writing
of ZLIB headers. This is the default behaviour but can be overridden
using {@code Deflater(int, boolean)}.
if (streamHandle == -1) {
throw new IllegalStateException();
}
// avoid int overflow, check null buf
if (off <= buf.length && nbytes >= 0 && off >= 0
&& buf.length - off >= nbytes) {
setDictionaryImpl(buf, off, nbytes, streamHandle);
} else {
throw new ArrayIndexOutOfBoundsException();
}
|
private native synchronized void | setDictionaryImpl(byte[] buf, int off, int nbytes, long handle)
|
public void | setInput(byte[] buf)Sets the input buffer the {@code Deflater} will use to extract uncompressed bytes
for later compression.
setInput(buf, 0, buf.length);
|
public synchronized void | setInput(byte[] buf, int off, int nbytes)Sets the input buffer the {@code Deflater} will use to extract uncompressed bytes
for later compression. Input will be taken from the buffer region
starting at off and ending at nbytes - 1.
if (streamHandle == -1) {
throw new IllegalStateException();
}
// avoid int overflow, check null buf
if (off <= buf.length && nbytes >= 0 && off >= 0
&& buf.length - off >= nbytes) {
inLength = nbytes;
inRead = 0;
if (inputBuffer == null) {
setLevelsImpl(compressLevel, strategy, streamHandle);
}
inputBuffer = buf;
setInputImpl(buf, off, nbytes, streamHandle);
} else {
throw new ArrayIndexOutOfBoundsException();
}
|
private native synchronized void | setInputImpl(byte[] buf, int off, int nbytes, long handle)
|
public synchronized void | setLevel(int level)Sets the compression level to be used when compressing data. The
compression level must be a value between 0 and 9. This value must be set
prior to calling setInput().
if (level < DEFAULT_COMPRESSION || level > BEST_COMPRESSION) {
throw new IllegalArgumentException();
}
if (inputBuffer != null) {
throw new IllegalStateException();
}
compressLevel = level;
|
private native synchronized void | setLevelsImpl(int level, int strategy, long handle)
|
public synchronized void | setStrategy(int strategy)Sets the compression strategy to be used. The strategy must be one of
FILTERED, HUFFMAN_ONLY or DEFAULT_STRATEGY.This value must be set prior
to calling setInput().
if (strategy < DEFAULT_STRATEGY || strategy > HUFFMAN_ONLY) {
throw new IllegalArgumentException();
}
if (inputBuffer != null) {
throw new IllegalStateException();
}
this.strategy = strategy;
|