Methods Summary |
---|
private native long | createStream(boolean noHeader1)
|
public synchronized void | end()Release any resources associated with this {@code Inflater}. Any unused
input/output is discarded. This is also called by the finalize method.
if (streamHandle != -1) {
endImpl(streamHandle);
inRead = 0;
inLength = 0;
streamHandle = -1;
}
|
private native synchronized void | endImpl(long handle)
|
protected void | finalize()
end();
|
public synchronized boolean | finished()Indicates if the {@code Inflater} has inflated the entire deflated
stream. If deflated bytes remain and {@code needsInput()} returns {@code
true} this method will return {@code false}. This method should be
called after all deflated input is supplied to the {@code Inflater}.
return finished;
|
public synchronized int | getAdler()Returns the Adler32 checksum of either all bytes inflated, or the
checksum of the preset dictionary if one has been supplied.
if (streamHandle == -1) {
throw new IllegalStateException();
}
return getAdlerImpl(streamHandle);
|
private native synchronized int | getAdlerImpl(long handle)
|
public synchronized long | getBytesRead()Returns the total number of bytes read by the {@code Inflater}. This
method performs the same as {@code getTotalIn()} except that it returns a
{@code long} value instead of an integer.
// Throw NPE here
if (streamHandle == -1) {
throw new NullPointerException();
}
return getTotalInImpl(streamHandle);
|
public synchronized long | getBytesWritten()Returns a the total number of bytes read by the {@code Inflater}. This
method performs the same as {@code getTotalOut} except it returns a
{@code long} value instead of an integer.
// Throw NPE here
if (streamHandle == -1) {
throw new NullPointerException();
}
return getTotalOutImpl(streamHandle);
|
public synchronized int | getRemaining()Returns the number of bytes of current input remaining to be read by the
inflater.
return inLength - inRead;
|
public synchronized int | getTotalIn()Returns total number of bytes of input read by the {@code Inflater}. The
result value is limited by {@code Integer.MAX_VALUE}.
if (streamHandle == -1) {
throw new IllegalStateException();
}
long totalIn = getTotalInImpl(streamHandle);
return (totalIn <= Integer.MAX_VALUE ? (int) totalIn
: Integer.MAX_VALUE);
|
private native synchronized long | getTotalInImpl(long handle)
|
public synchronized int | getTotalOut()Returns total number of bytes written to the output buffer by the {@code
Inflater}. The result value is limited by {@code Integer.MAX_VALUE}.
if (streamHandle == -1) {
throw new IllegalStateException();
}
long totalOut = getTotalOutImpl(streamHandle);
return (totalOut <= Integer.MAX_VALUE ? (int) totalOut
: Integer.MAX_VALUE);
|
private native synchronized long | getTotalOutImpl(long handle)
|
public int | inflate(byte[] buf)Inflates bytes from current input and stores them in {@code buf}.
return inflate(buf, 0, buf.length);
|
public synchronized int | inflate(byte[] buf, int off, int nbytes)Inflates up to n bytes from the current input and stores them in {@code
buf} starting at {@code off}.
// avoid int overflow, check null buf
if (off <= buf.length && nbytes >= 0 && off >= 0
&& buf.length - off >= nbytes) {
if (nbytes == 0)
return 0;
if (streamHandle == -1) {
throw new IllegalStateException();
}
if (!pass_magic_number_check) {
throw new DataFormatException();
}
if (needsInput()) {
return 0;
}
boolean neededDict = needsDictionary;
needsDictionary = false;
int result = inflateImpl(buf, off, nbytes, streamHandle);
if (needsDictionary && neededDict) {
throw new DataFormatException(Messages.getString("archive.27")); //$NON-NLS-1$
}
return result;
}
throw new ArrayIndexOutOfBoundsException();
|
private native synchronized int | inflateImpl(byte[] buf, int off, int nbytes, long handle)
|
public synchronized boolean | needsDictionary()Indicates whether the input bytes were compressed with a preset
dictionary. This method should be called prior to {@code inflate()} to
determine whether a dictionary is required. If so {@code setDictionary()}
should be called with the appropriate dictionary prior to calling {@code
inflate()}.
return needsDictionary;
|
public synchronized boolean | needsInput()Indicates that input has to be passed to the inflater.
return inRead == inLength;
|
private static native void | oneTimeInitialization()
|
public synchronized void | reset()Resets the {@code Inflater}. Should be called prior to inflating a new
set of data.
if (streamHandle == -1) {
throw new NullPointerException();
}
finished = false;
needsDictionary = false;
inLength = inRead = 0;
resetImpl(streamHandle);
|
private native synchronized void | resetImpl(long handle)
|
public synchronized void | setDictionary(byte[] buf)Sets the preset dictionary to be used for inflation to {@code buf}.
{@code needsDictionary()} can be called to determine whether the current
input was deflated using a preset dictionary.
setDictionary(buf, 0, buf.length);
|
public synchronized void | setDictionary(byte[] buf, int off, int nbytes)Like {@code setDictionary(byte[])}, allowing to define a specific region
inside {@code buf} to be used as a dictionary.
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)
|
synchronized int | setFileInput(java.io.FileDescriptor fd, long off, int nbytes)Sets the current input to the region within a file starting at {@code
off} and ending at {@code nbytes - 1}. This method should only be called
if {@code needsInput()} returns {@code true}.
if (streamHandle == -1) {
throw new IllegalStateException();
}
inRead = 0;
inLength = setFileInputImpl(fd, off, nbytes, streamHandle);
return inLength;
|
private native synchronized int | setFileInputImpl(java.io.FileDescriptor fd, long off, int nbytes, long handle)
|
public synchronized void | setInput(byte[] buf)Sets the current input to to be decrompressed. This method should only be
called if {@code needsInput()} returns {@code true}.
setInput(buf, 0, buf.length);
|
public synchronized void | setInput(byte[] buf, int off, int nbytes)Sets the current input to the region of the input buffer starting at
{@code off} and ending at {@code nbytes - 1} where data is written after
decompression. This method should only be called if {@code needsInput()}
returns {@code true}.
if (streamHandle == -1) {
throw new IllegalStateException();
}
// avoid int overflow, check null buf
if (off <= buf.length && nbytes >= 0 && off >= 0
&& buf.length - off >= nbytes) {
inRead = 0;
inLength = nbytes;
setInputImpl(buf, off, nbytes, streamHandle);
} else {
throw new ArrayIndexOutOfBoundsException();
}
// BEGIN android-note
// Note: pass_magic_number_check is set to false when setInput is
// called for the first time and for a single byte.
// Since setInput is called only by InflaterInputStream.fill
// with an arbitrary byte len this check seems quite useless.
// FIXME: We should find out whether the first byte has to be the magic
// number in all cases and correct the check as well as place it
// in setFileInput accordingly.
// And at a first glance it doesn't look like the first byte has
// to be 120.
// END android-note
if(!gotFirstByte && nbytes>0)
{
pass_magic_number_check = (buf[off] == MAGIC_NUMBER || nbytes > 1);
gotFirstByte = true;
}
|
private native synchronized void | setInputImpl(byte[] buf, int off, int nbytes, long handle)
|