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

Quick Search    Search Deep

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

java.lang.Object
  extended byClassLib.Common.java.util.zip.DeflaterEngine
All Implemented Interfaces:
DeflaterConstants

class DeflaterEngine
extends java.lang.Object
implements DeflaterConstants

DeflaterEngine

Version:
$Id: DeflaterEngine.java,v 1.7 2003/05/12 10:04:53 joewhaley Exp $

Field Summary
private  Adler32 adler
          The adler checksum
private  int blockStart
           
private  byte[] buffer
           
static int[] COMPR_FUNC
           
private  int comprFunc
          The current compression function.
static boolean DEBUGGING
           
static int DEFAULT_MEM_LEVEL
           
static int DEFLATE_FAST
           
static int DEFLATE_SLOW
           
static int DEFLATE_STORED
           
static int DYN_TREES
           
static int[] GOOD_LENGTH
           
private  int goodLength
           
static int HASH_BITS
           
static int HASH_MASK
           
static int HASH_SHIFT
           
static int HASH_SIZE
           
private  short[] head
          Hashtable, hashing three characters to an index for window, so that window[index]..window[index+2] have this hash code.
private  DeflaterHuffman huffman
           
private  byte[] inputBuf
          The input data for compression.
private  int inputEnd
          The end offset of the input data.
private  int inputOff
          The offset into inputBuf, where input data starts.
private  int ins_h
           
private  int lookahead
          lookahead is the number of characters starting at strstart in window that are valid.
private  int matchLen
           
private  int matchStart
           
static int MAX_BLOCK_SIZE
           
private  int max_chain
           
static int[] MAX_CHAIN
           
static int MAX_DIST
           
private  int max_lazy
           
static int[] MAX_LAZY
           
static int MAX_MATCH
           
static int MAX_WBITS
           
static int MIN_LOOKAHEAD
           
static int MIN_MATCH
           
static int[] NICE_LENGTH
           
private  int niceLength
           
private  DeflaterPending pending
           
static int PENDING_BUF_SIZE
           
static int PRESET_DICT
           
private  short[] prev
          prev[index & WMASK] points to the previous index that has the same hash code as the string starting at index.
private  boolean prevAvailable
           
static int STATIC_TREES
           
static int STORED_BLOCK
           
private  int strategy
           
private  int strstart
          strstart points to the current character in window.
private static int TOO_FAR
           
private  int totalIn
          The total bytes of input read.
private  byte[] window
          This array contains the part of the uncompressed stream that is of relevance.
static int WMASK
           
static int WSIZE
           
 
Constructor Summary
(package private) DeflaterEngine(DeflaterPending pending)
           
 
Method Summary
 boolean deflate(boolean flush, boolean finish)
           
private  boolean deflateFast(boolean flush, boolean finish)
           
private  boolean deflateSlow(boolean flush, boolean finish)
           
private  boolean deflateStored(boolean flush, boolean finish)
           
private  void fillWindow()
          Fill the window when the lookahead becomes insufficient.
private  boolean findLongestMatch(int curMatch)
          Find the best (longest) string in the window matching the string starting at strstart.
 int getAdler()
           
 int getTotalIn()
           
private  int insertString()
          Inserts the current string in the head hash and returns the previous value for this hash.
 boolean needsInput()
           
 void reset()
           
 void resetAdler()
           
(package private)  void setDictionary(byte[] buffer, int offset, int length)
           
 void setInput(byte[] buf, int off, int len)
           
 void setLevel(int lvl)
           
 void setStrategy(int strat)
           
private  void slideWindow()
           
private  void updateHash()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TOO_FAR

private static final int TOO_FAR
See Also:
Constant Field Values

ins_h

private int ins_h

buffer

private byte[] buffer

head

private short[] head
Hashtable, hashing three characters to an index for window, so that window[index]..window[index+2] have this hash code. Note that the array should really be unsigned short, so you need to and the values with 0xffff.


prev

private short[] prev
prev[index & WMASK] points to the previous index that has the same hash code as the string starting at index. This way entries with the same hash code are in a linked list. Note that the array should really be unsigned short, so you need to and the values with 0xffff.


matchStart

private int matchStart

matchLen

private int matchLen

prevAvailable

private boolean prevAvailable

blockStart

private int blockStart

strstart

private int strstart
strstart points to the current character in window.


lookahead

private int lookahead
lookahead is the number of characters starting at strstart in window that are valid. So window[strstart] until window[strstart+lookahead-1] are valid characters.


window

private byte[] window
This array contains the part of the uncompressed stream that is of relevance. The current character is indexed by strstart.


strategy

private int strategy

max_chain

private int max_chain

max_lazy

private int max_lazy

niceLength

private int niceLength

goodLength

private int goodLength

comprFunc

private int comprFunc
The current compression function.


inputBuf

private byte[] inputBuf
The input data for compression.


totalIn

private int totalIn
The total bytes of input read.


inputOff

private int inputOff
The offset into inputBuf, where input data starts.


inputEnd

private int inputEnd
The end offset of the input data.


pending

private DeflaterPending pending

huffman

private DeflaterHuffman huffman

adler

private Adler32 adler
The adler checksum


DEBUGGING

public static final boolean DEBUGGING
See Also:
Constant Field Values

STORED_BLOCK

public static final int STORED_BLOCK
See Also:
Constant Field Values

STATIC_TREES

public static final int STATIC_TREES
See Also:
Constant Field Values

DYN_TREES

public static final int DYN_TREES
See Also:
Constant Field Values

PRESET_DICT

public static final int PRESET_DICT
See Also:
Constant Field Values

DEFAULT_MEM_LEVEL

public static final int DEFAULT_MEM_LEVEL
See Also:
Constant Field Values

MAX_MATCH

public static final int MAX_MATCH
See Also:
Constant Field Values

MIN_MATCH

public static final int MIN_MATCH
See Also:
Constant Field Values

MAX_WBITS

public static final int MAX_WBITS
See Also:
Constant Field Values

WSIZE

public static final int WSIZE
See Also:
Constant Field Values

WMASK

public static final int WMASK
See Also:
Constant Field Values

HASH_BITS

public static final int HASH_BITS
See Also:
Constant Field Values

HASH_SIZE

public static final int HASH_SIZE
See Also:
Constant Field Values

HASH_MASK

public static final int HASH_MASK
See Also:
Constant Field Values

HASH_SHIFT

public static final int HASH_SHIFT
See Also:
Constant Field Values

MIN_LOOKAHEAD

public static final int MIN_LOOKAHEAD
See Also:
Constant Field Values

MAX_DIST

public static final int MAX_DIST
See Also:
Constant Field Values

PENDING_BUF_SIZE

public static final int PENDING_BUF_SIZE
See Also:
Constant Field Values

MAX_BLOCK_SIZE

public static final int MAX_BLOCK_SIZE

DEFLATE_STORED

public static final int DEFLATE_STORED
See Also:
Constant Field Values

DEFLATE_FAST

public static final int DEFLATE_FAST
See Also:
Constant Field Values

DEFLATE_SLOW

public static final int DEFLATE_SLOW
See Also:
Constant Field Values

GOOD_LENGTH

public static final int[] GOOD_LENGTH

MAX_LAZY

public static final int[] MAX_LAZY

NICE_LENGTH

public static final int[] NICE_LENGTH

MAX_CHAIN

public static final int[] MAX_CHAIN

COMPR_FUNC

public static final int[] COMPR_FUNC
Constructor Detail

DeflaterEngine

DeflaterEngine(DeflaterPending pending)
Method Detail

reset

public void reset()

resetAdler

public final void resetAdler()

getAdler

public final int getAdler()

getTotalIn

public final int getTotalIn()

setStrategy

public final void setStrategy(int strat)

setLevel

public void setLevel(int lvl)

updateHash

private final void updateHash()

insertString

private final int insertString()
Inserts the current string in the head hash and returns the previous value for this hash.


slideWindow

private void slideWindow()

fillWindow

private void fillWindow()
Fill the window when the lookahead becomes insufficient. Updates strstart and lookahead. OUT assertions: strstart + lookahead <= 2*WSIZE lookahead >= MIN_LOOKAHEAD or inputOff == inputEnd


findLongestMatch

private boolean findLongestMatch(int curMatch)
Find the best (longest) string in the window matching the string starting at strstart. Preconditions: strstart + MAX_MATCH <= window.length.


setDictionary

void setDictionary(byte[] buffer,
                   int offset,
                   int length)

deflateStored

private boolean deflateStored(boolean flush,
                              boolean finish)

deflateFast

private boolean deflateFast(boolean flush,
                            boolean finish)

deflateSlow

private boolean deflateSlow(boolean flush,
                            boolean finish)

deflate

public boolean deflate(boolean flush,
                       boolean finish)

setInput

public void setInput(byte[] buf,
                     int off,
                     int len)

needsInput

public final boolean needsInput()