Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

ClassLib.Common.java.util.zip
Class Inflater  view Inflater download Inflater.java

java.lang.Object
  extended byClassLib.Common.java.util.zip.Inflater

public class Inflater
extends java.lang.Object

Inflater

Version:
$Id: Inflater.java,v 1.10 2003/08/09 11:32:20 joewhaley Exp $

Field Summary
private  Adler32 adler
           
private static int[] CPDEXT
           
private static int[] CPDIST
           
private static int[] CPLENS
           
private static int[] CPLEXT
           
private static int DECODE_BLOCKS
           
private static int DECODE_CHKSUM
           
private static int DECODE_DICT
           
private static int DECODE_DYN_HEADER
           
private static int DECODE_HEADER
           
private static int DECODE_HUFFMAN
           
private static int DECODE_HUFFMAN_DIST
           
private static int DECODE_HUFFMAN_DISTBITS
           
private static int DECODE_HUFFMAN_LENBITS
           
private static int DECODE_STORED
           
private static int DECODE_STORED_LEN1
           
private static int DECODE_STORED_LEN2
           
private  InflaterHuffmanTree distTree
           
private  InflaterDynHeader dynHeader
           
private static int FINISHED
           
private  StreamManipulator input
           
private  boolean isLastBlock
          True, if the last block flag was set in the last block of the inflated stream.
private  InflaterHuffmanTree litlenTree
           
private  int mode
          This variable contains the current state.
private  int neededBits
          The number of bits needed to complete the current state.
private  boolean nowrap
          This variable stores the nowrap flag that was given to the constructor.
private  OutputWindow outputWindow
           
private  int readAdler
          The adler checksum of the dictionary or of the decompressed stream, as it is written in the header resp.
private  int repDist
           
private  int repLength
           
private  int totalIn
          The total number of bytes set with setInput().
private  int totalOut
          The total number of inflated bytes.
private  int uncomprLen
           
 
Constructor Summary
Inflater()
          Creates a new inflater.
Inflater(boolean nowrap)
          Creates a new inflater.
 
Method Summary
 void __init__(boolean nowrap)
           
private  boolean decode()
          Decodes the deflated stream.
private  boolean decodeChksum()
          Decodes the adler checksum after the deflate stream.
private  boolean decodeDict()
          Decodes the dictionary checksum after the deflate header.
private  boolean decodeHeader()
          Decodes the deflate header.
private  boolean decodeHuffman()
          Decodes the huffman encoded symbols in the input stream.
 void end()
          Deprecated. Just clear all references to inflater instead.
protected  void finalize()
          Finalizes this object.
 boolean finished()
          Returns true, if the inflater has finished.
 int getAdler()
          Gets the adler checksum.
 int getRemaining()
          Gets the number of unprocessed input.
 int getTotalIn()
          Gets the total number of processed compressed input bytes.
 int getTotalOut()
          Gets the total number of output bytes returned by inflate().
 int inflate(byte[] buf)
          Inflates the compressed stream to the output buffer.
 int inflate(byte[] buf, int off, int len)
          Inflates the compressed stream to the output buffer.
private static void initIDs()
           
 boolean needsDictionary()
          Returns true, if a preset dictionary is needed to inflate the input.
 boolean needsInput()
          Returns true, if the input buffer is empty.
 void reset()
          Resets the inflater so that a new stream can be decompressed.
 void setDictionary(byte[] buffer)
          Sets the preset dictionary.
 void setDictionary(byte[] buffer, int off, int len)
          Sets the preset dictionary.
 void setInput(byte[] buf)
          Sets the input.
 void setInput(byte[] buf, int off, int len)
          Sets the input.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CPLENS

private static final int[] CPLENS

CPLEXT

private static final int[] CPLEXT

CPDIST

private static final int[] CPDIST

CPDEXT

private static final int[] CPDEXT

DECODE_HEADER

private static final int DECODE_HEADER
See Also:
Constant Field Values

DECODE_DICT

private static final int DECODE_DICT
See Also:
Constant Field Values

DECODE_BLOCKS

private static final int DECODE_BLOCKS
See Also:
Constant Field Values

DECODE_STORED_LEN1

private static final int DECODE_STORED_LEN1
See Also:
Constant Field Values

DECODE_STORED_LEN2

private static final int DECODE_STORED_LEN2
See Also:
Constant Field Values

DECODE_STORED

private static final int DECODE_STORED
See Also:
Constant Field Values

DECODE_DYN_HEADER

private static final int DECODE_DYN_HEADER
See Also:
Constant Field Values

DECODE_HUFFMAN

private static final int DECODE_HUFFMAN
See Also:
Constant Field Values

DECODE_HUFFMAN_LENBITS

private static final int DECODE_HUFFMAN_LENBITS
See Also:
Constant Field Values

DECODE_HUFFMAN_DIST

private static final int DECODE_HUFFMAN_DIST
See Also:
Constant Field Values

DECODE_HUFFMAN_DISTBITS

private static final int DECODE_HUFFMAN_DISTBITS
See Also:
Constant Field Values

DECODE_CHKSUM

private static final int DECODE_CHKSUM
See Also:
Constant Field Values

FINISHED

private static final int FINISHED
See Also:
Constant Field Values

mode

private int mode
This variable contains the current state.


readAdler

private int readAdler
The adler checksum of the dictionary or of the decompressed stream, as it is written in the header resp. footer of the compressed stream.
Only valid if mode is DECODE_DICT or DECODE_CHKSUM.


neededBits

private int neededBits
The number of bits needed to complete the current state. This is valid, if mode is DECODE_DICT, DECODE_CHKSUM, DECODE_HUFFMAN_LENBITS or DECODE_HUFFMAN_DISTBITS.


repLength

private int repLength

repDist

private int repDist

uncomprLen

private int uncomprLen

isLastBlock

private boolean isLastBlock
True, if the last block flag was set in the last block of the inflated stream. This means that the stream ends after the current block.


totalOut

private int totalOut
The total number of inflated bytes.


totalIn

private int totalIn
The total number of bytes set with setInput(). This is not the value returned by getTotalIn(), since this also includes the unprocessed input.


nowrap

private boolean nowrap
This variable stores the nowrap flag that was given to the constructor. True means, that the inflated stream doesn't contain a header nor the checksum in the footer.


input

private StreamManipulator input

outputWindow

private OutputWindow outputWindow

dynHeader

private InflaterDynHeader dynHeader

litlenTree

private InflaterHuffmanTree litlenTree

distTree

private InflaterHuffmanTree distTree

adler

private Adler32 adler
Constructor Detail

Inflater

public Inflater()
Creates a new inflater.


Inflater

public Inflater(boolean nowrap)
Creates a new inflater.

Method Detail

initIDs

private static void initIDs()

__init__

public void __init__(boolean nowrap)

reset

public void reset()
Resets the inflater so that a new stream can be decompressed. All pending input and output will be discarded.


decodeHeader

private boolean decodeHeader()
                      throws java.util.zip.DataFormatException
Decodes the deflate header.


decodeDict

private boolean decodeDict()
Decodes the dictionary checksum after the deflate header.


decodeHuffman

private boolean decodeHuffman()
                       throws java.util.zip.DataFormatException
Decodes the huffman encoded symbols in the input stream.


decodeChksum

private boolean decodeChksum()
                      throws java.util.zip.DataFormatException
Decodes the adler checksum after the deflate stream.


decode

private boolean decode()
                throws java.util.zip.DataFormatException
Decodes the deflated stream.


setDictionary

public void setDictionary(byte[] buffer)
Sets the preset dictionary. This should only be called, if needsDictionary() returns true and it should set the same dictionary, that was used for deflating. The getAdler() function returns the checksum of the dictionary needed.


setDictionary

public void setDictionary(byte[] buffer,
                          int off,
                          int len)
Sets the preset dictionary. This should only be called, if needsDictionary() returns true and it should set the same dictionary, that was used for deflating. The getAdler() function returns the checksum of the dictionary needed.


setInput

public void setInput(byte[] buf)
Sets the input. This should only be called, if needsInput() returns true.


setInput

public void setInput(byte[] buf,
                     int off,
                     int len)
Sets the input. This should only be called, if needsInput() returns true.


inflate

public int inflate(byte[] buf)
            throws java.util.zip.DataFormatException
Inflates the compressed stream to the output buffer. If this returns 0, you should check, whether needsDictionary(), needsInput() or finished() returns true, to determine why no further output is produced.


inflate

public int inflate(byte[] buf,
                   int off,
                   int len)
            throws java.util.zip.DataFormatException
Inflates the compressed stream to the output buffer. If this returns 0, you should check, whether needsDictionary(), needsInput() or finished() returns true, to determine why no further output is produced.


needsInput

public boolean needsInput()
Returns true, if the input buffer is empty. You should then call setInput().
NOTE: This method also returns true when the stream is finished.


needsDictionary

public boolean needsDictionary()
Returns true, if a preset dictionary is needed to inflate the input.


finished

public boolean finished()
Returns true, if the inflater has finished. This means, that no input is needed and no output can be produced.


getAdler

public int getAdler()
Gets the adler checksum. This is either the checksum of all uncompressed bytes returned by inflate(), or if needsDictionary() returns true (and thus no output was yet produced) this is the adler checksum of the expected dictionary.


getTotalOut

public int getTotalOut()
Gets the total number of output bytes returned by inflate().


getTotalIn

public int getTotalIn()
Gets the total number of processed compressed input bytes.


getRemaining

public int getRemaining()
Gets the number of unprocessed input. Useful, if the end of the stream is reached and you want to further process the bytes after the deflate stream.


end

public void end()
Deprecated. Just clear all references to inflater instead.

Frees all objects allocated by the inflater. There's no reason to call this, since you can just rely on garbage collection (even for the Sun implementation). Exists only for compatibility with Sun's JDK, where the compressor allocates native memory. If you call any method (even reset) afterwards the behaviour is undefined.


finalize

protected void finalize()
                 throws java.lang.Throwable
Finalizes this object.