| Method from java.util.zip.DeflaterEngine Detail: |
public boolean deflate(boolean flush,
boolean finish) {
boolean progress;
do
{
fillWindow();
boolean canFlush = flush && inputOff == inputEnd;
if (DeflaterConstants.DEBUGGING)
System.err.println("window: ["+blockStart+","+strstart+","
+lookahead+"], "+comprFunc+","+canFlush);
switch (comprFunc)
{
case DEFLATE_STORED:
progress = deflateStored(canFlush, finish);
break;
case DEFLATE_FAST:
progress = deflateFast(canFlush, finish);
break;
case DEFLATE_SLOW:
progress = deflateSlow(canFlush, finish);
break;
default:
throw new InternalError();
}
}
while (pending.isFlushed() /* repeat while we have no pending output */
&& progress); /* and progress was made */
return progress;
}
|
public final int getAdler() {
int chksum = (int) adler.getValue();
return chksum;
}
|
public final int getTotalIn() {
return totalIn;
}
|
public final boolean needsInput() {
return inputEnd == inputOff;
}
|
public void reset() {
huffman.reset();
adler.reset();
blockStart = strstart = 1;
lookahead = 0;
totalIn = 0;
prevAvailable = false;
matchLen = MIN_MATCH - 1;
for (int i = 0; i < HASH_SIZE; i++)
head[i] = 0;
for (int i = 0; i < WSIZE; i++)
prev[i] = 0;
}
|
public final void resetAdler() {
adler.reset();
}
|
void setDictionary(byte[] buffer,
int offset,
int length) {
if (DeflaterConstants.DEBUGGING && strstart != 1)
throw new IllegalStateException("strstart not 1");
adler.update(buffer, offset, length);
if (length < MIN_MATCH)
return;
if (length > MAX_DIST) {
offset += length - MAX_DIST;
length = MAX_DIST;
}
System.arraycopy(buffer, offset, window, strstart, length);
updateHash();
length--;
while (--length > 0)
{
insertString();
strstart++;
}
strstart += 2;
blockStart = strstart;
}
|
public void setInput(byte[] buf,
int off,
int len) {
if (inputOff < inputEnd)
throw new IllegalStateException
("Old input was not completely processed");
int end = off + len;
/* We want to throw an ArrayIndexOutOfBoundsException early. The
* check is very tricky: it also handles integer wrap around.
*/
if (0 > off || off > end || end > buf.length)
throw new ArrayIndexOutOfBoundsException();
inputBuf = buf;
inputOff = off;
inputEnd = end;
}
|
public void setLevel(int lvl) {
goodLength = DeflaterConstants.GOOD_LENGTH[lvl];
max_lazy = DeflaterConstants.MAX_LAZY[lvl];
niceLength = DeflaterConstants.NICE_LENGTH[lvl];
max_chain = DeflaterConstants.MAX_CHAIN[lvl];
if (DeflaterConstants.COMPR_FUNC[lvl] != comprFunc)
{
if (DeflaterConstants.DEBUGGING)
System.err.println("Change from "+comprFunc +" to "
+ DeflaterConstants.COMPR_FUNC[lvl]);
switch (comprFunc)
{
case DEFLATE_STORED:
if (strstart > blockStart)
{
huffman.flushStoredBlock(window, blockStart,
strstart - blockStart, false);
blockStart = strstart;
}
updateHash();
break;
case DEFLATE_FAST:
if (strstart > blockStart)
{
huffman.flushBlock(window, blockStart, strstart - blockStart,
false);
blockStart = strstart;
}
break;
case DEFLATE_SLOW:
if (prevAvailable)
huffman.tallyLit(window[strstart-1] & 0xff);
if (strstart > blockStart)
{
huffman.flushBlock(window, blockStart, strstart - blockStart,
false);
blockStart = strstart;
}
prevAvailable = false;
matchLen = MIN_MATCH - 1;
break;
}
comprFunc = COMPR_FUNC[lvl];
}
}
|
public final void setStrategy(int strat) {
strategy = strat;
}
|