|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.bolet.jgz.DeflaterStateMachine
public final class DeflaterStateMachine
This class implements a DEFLATE engine as a state machine (deflation process). The machine consumes uncompressed data and outputs compressed data; none of the calls to this class ever blocks.
At any time, the machine has some input data to process, and
an optional scheduled flush or terminate action, to be performed
when the current input data is completely processed. Only a single
action may be scheduled at a time. When the current input data is
finished, new data can be input with setInput()
. The
provided input data is NOT copied internally, hence there is no
problem in using large buffers.
Constructor Summary | |
---|---|
DeflaterStateMachine(boolean raw)
Build the state machine instance with default compression parameters. |
|
DeflaterStateMachine(int level,
int windowBits,
boolean raw)
Build the state machine instance with the provided compression parameters. |
Method Summary | |
---|---|
int |
deflate(byte[] buf)
Get some compressed data bytes. |
int |
deflate(byte[] buf,
int off,
int len)
Get some compressed data bytes. |
int |
deflate(java.io.OutputStream out)
Get some compressed data bytes. |
void |
finish()
Finish the stream: the output will be marked as closed at the end of the currently provided input. |
boolean |
finished()
Test whether the compression run is finished. |
void |
flushFull(boolean withData)
Flush the stream: the output will be flushed (full flush) at the end of the currently provided input. |
void |
flushPartial()
Flush the stream: the output will be flushed (partial flush) at the end of the currently provided input. |
void |
flushSync(boolean withData)
Flush the stream: the output will be flushed (sync flush) at the end of the currently provided input. |
boolean |
needsInput()
Test whether some fresh input data is necessary. |
void |
reset()
Reset the machine to its initial state. |
void |
setDictionary(byte[] dict)
Set the dictionary. |
void |
setDictionary(byte[] dict,
int off,
int len)
Set the dictionary. |
void |
setInput(byte[] buf)
Insert new input data. |
void |
setInput(byte[] buf,
int off,
int len)
Insert new input data. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DeflaterStateMachine(boolean raw)
raw
is false
, then
the output data will use the zlib format (RFC 1950);
otherwise, it will consist of only the raw sequence of
compressed blocks.
raw
- true
to omit zlib header and footerpublic DeflaterStateMachine(int level, int windowBits, boolean raw)
raw
is false
, then
the output data will use the zlib format (RFC 1950);
otherwise, it will consist of only the raw sequence of
compressed blocks.
level
- the compression strategy (1 to 4)windowBits
- the DEFLATE window bit size (9 to 15)raw
- true
to omit zlib header and footerMethod Detail |
---|
public void reset()
public boolean needsInput()
true
, then it is guaranteed that
deflate()
will return 0 until some new input
data is added. When true
is returned, it is
guaranteed that all previously input data has been processed,
which means that setInput()
can be called safely.
true
when some input is neededpublic void setDictionary(byte[] dict)
deflate()
.
dict
- the dictionarypublic void setDictionary(byte[] dict, int off, int len)
deflate()
.
dict
- the dictionaryoff
- the dictionary offsetlen
- the dictionary lengthpublic void setInput(byte[] buf)
buf
- the new input datapublic void setInput(byte[] buf, int off, int len)
buf
- the new input dataoff
- the new input data offsetlen
- the new input data lengthpublic void finish()
public void flushPartial()
public void flushSync(boolean withData)
withData
- false
to omit the 00 00 FF FF bytespublic void flushFull(boolean withData)
withData
- false
to omit the 00 00 FF FF bytespublic boolean finished()
true
, then the machine will not require
any new input and will not output bytes anymore.
true
on a finished machinepublic int deflate(byte[] buf)
buf
- the compressed data buffer
public int deflate(byte[] buf, int off, int len)
buf
- the compressed data bufferoff
- the compressed data buffer offsetlen
- the compressed data buffer length
public int deflate(java.io.OutputStream out) throws java.io.IOException
out
stream.
out
- the compressed data destination
java.io.IOException
- on I/O error with the output stream
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |