com.mot.iden.zip
Class Inflater

java.lang.Object
  extended bycom.mot.iden.zip.Inflater

public class Inflater
extends java.lang.Object

This class provides support for general purpose decompression using popular ZLIB compression library. The ZLIB compression library was initially developed as part of the PNG graphics standard and is not protected by patents. It is fully described in the specifications at the java.util.zip package description.


MOTOROLA and the Stylized M Logo are registered trademarks of Motorola, Inc. Reg. U.S. Pat. & Tm. Off.
© Copyright 2001-2003 Motorola, Inc. All Rights Reserved.

See Also:
Deflater

Constructor Summary
Inflater()
          Creates a new decompressor.
Inflater(boolean nowrap)
          Creates a new decompressor.
 
Method Summary
 void end()
          Closes the decompressor and discards any unprocessed input.
 boolean finished()
          Return true if the end of the compressed data stream has been reached.
 int getAdler()
          Returns the ADLER-32 value of the uncompressed data.
 int getRemaining()
          Returns the total number of bytes remaining in the input buffer.
 int getTotalIn()
          Returns the total number of bytes input so far.
 int getTotalOut()
          Returns the total number of bytes output so far.
 int inflate(byte[] b)
          Uncompresses bytes into specified buffer.
 int inflate(byte[] b, int off, int len)
          Uncompresses bytes into specified buffer.
 boolean needsInput()
          Returns true if no data remains in the input buffer.
 void reset()
          Resets inflater so that a new set of input data can be processed.
 void setInput(byte[] b)
          Sets input data for decompression.
 void setInput(byte[] b, int off, int len)
          Sets input data for decompression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Inflater

public Inflater(boolean nowrap)
Creates a new decompressor. If the parameter 'nowrap' is true then the ZLIB header and checksum fields will not be used. This provides compatibility with the compression format used by both GZIP and PKZIP.

Note: When using the 'nowrap' option it is also necessary to provide an extra "dummy" byte as input. This is required by the ZLIB native library in order to support certain optimizations.

Parameters:
nowrap - if true then support GZIP compatible compression

Inflater

public Inflater()
Creates a new decompressor.

Method Detail

setInput

public void setInput(byte[] b,
                     int off,
                     int len)
Sets input data for decompression. Should be called whenever needsInput() returns true indicating that more input data is required.

Parameters:
b - the input data bytes
off - the start offset of the input data
len - the length of the input data
Throws:
java.lang.NullPointerException - if b == null.
ArrayIndexOutofBoundsException - if (off < 0 || len < 0 || off + len > b.length).
See Also:
needsInput()

setInput

public void setInput(byte[] b)
Sets input data for decompression. Should be called whenever needsInput() returns true indicating that more input data is required.

Parameters:
b - the input data bytes
See Also:
needsInput()

getRemaining

public int getRemaining()
Returns the total number of bytes remaining in the input buffer. This can be used to find out what bytes still remain in the input buffer after decompression has finished.

Returns:
the total number of bytes remaining in the input buffer

needsInput

public boolean needsInput()
Returns true if no data remains in the input buffer. This can be used to determine if #setInput should be called in order to provide more input.

Returns:
true if no data remains in the input buffer

finished

public boolean finished()
Return true if the end of the compressed data stream has been reached.

Returns:
true if the end of the compressed data stream has been reached

inflate

public int inflate(byte[] b,
                   int off,
                   int len)
            throws DataFormatException
Uncompresses bytes into specified buffer. Returns actual number of bytes uncompressed. A return value of 0 indicates that needsInput() should be called in order to determine if more input data or a preset dictionary is required. In the later case, getAdler() can be used to get the Adler-32 value of the dictionary required.

Parameters:
b - the buffer for the uncompressed data
off - the start offset of the data
len - the maximum number of uncompressed bytes
Returns:
the actual number of uncompressed bytes
Throws:
DataFormatException - if the compressed data format is invalid
java.lang.NullPointerException - if b == null.
ArrayIndexOutofBoundsException - if (off < 0 || len < 0 || off + len > b.length).
See Also:
needsInput()

inflate

public int inflate(byte[] b)
            throws DataFormatException
Uncompresses bytes into specified buffer. Returns actual number of bytes uncompressed. A return value of 0 indicates that needsInput() or needsDictionary() should be called in order to determine if more input data or a preset dictionary is required. In the later case, getAdler() can be used to get the Adler-32 value of the dictionary required.

Parameters:
b - the buffer for the uncompressed data
Returns:
the actual number of uncompressed bytes
Throws:
DataFormatException - if the compressed data format is invalid
See Also:
needsInput(), Inflater#needsDictionary

getAdler

public int getAdler()
Returns the ADLER-32 value of the uncompressed data.

Returns:
the ADLER-32 value of the uncompressed data
Throws:
java.lang.NullPointerException - if strm == 0.

getTotalIn

public int getTotalIn()
Returns the total number of bytes input so far.

Returns:
the total number of bytes input so far
Throws:
java.lang.NullPointerException - if strm == 0.

getTotalOut

public int getTotalOut()
Returns the total number of bytes output so far.

Returns:
the total number of bytes output so far
Throws:
java.lang.NullPointerException - if strm == 0.

reset

public void reset()
Resets inflater so that a new set of input data can be processed.

Throws:
java.lang.NullPointerException - if strm == 0.

end

public void end()
Closes the decompressor and discards any unprocessed input. This method should be called when the decompressor is no longer being used, but will also be called automatically by the finalize() method. Once this method is called, the behavior of the Inflater object is undefined.