|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.bolet.jgz.Deflater
public final class Deflater
This class implements the core DEFLATE process, i.e. the compression of data into DEFLATE blocks.
| Field Summary | |
|---|---|
static int |
COMPACT
Compression level 4: try to achieve best compression ratio, possibly at the expense of compression speed. |
static int |
HUFF
Compression level 1: do not apply LZ77; only Huffman codes are computed. |
static int |
MEDIUM
Compression level 3: compromise between speed and compression ratio. |
static int |
SPEED
Compression level 2: optimize for speed. |
| Constructor Summary | |
|---|---|
Deflater()
Build a deflater with the default parameters ( MEDIUM
level, 15-bit window). |
|
Deflater(int level)
Build a deflater with the provided compression strategy (either SPEED, MEDIUM or
COMPACT). |
|
Deflater(int level,
int windowBits)
Build a deflater with the provided compression strategy (either SPEED, MEDIUM or
COMPACT) and the provided window size. |
|
| Method Summary | |
|---|---|
void |
flush()
If there is pending buffered data, compress it now, and write the block on the transport stream. |
void |
flushFull(boolean withData)
Perform a "full flush". |
void |
flushPartial()
Perform a "partial flush" in a way similar to what is done by zlib with option Z_PARTIAL_FLUSH. |
void |
flushSync(boolean withData)
Perform a "sync flush" in a way similar to what is done by zlib with option Z_SYNC_FLUSH. |
java.io.OutputStream |
getOut()
Get the current output transport stream. |
void |
process(byte[] buf,
int off,
int len)
Process some more data. |
void |
processDictionary(byte[] dict)
Process a dictionary. |
void |
processDictionary(byte[] dict,
int off,
int len)
Process a dictionary. |
void |
processDictionary(java.io.InputStream dict)
Process a dictionary. |
void |
reset()
Reset the internal tables. |
void |
setOut(java.io.OutputStream out)
Set the current output transport stream. |
void |
terminate()
Terminate the current compression run. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int HUFF
SPEED
but with a degraded compression ratio.
public static final int SPEED
public static final int MEDIUM
public static final int COMPACT
MEDIUM level.
| Constructor Detail |
|---|
public Deflater()
MEDIUM
level, 15-bit window).
public Deflater(int level)
SPEED, MEDIUM or
COMPACT). A standard 15-bit window is used.
If the compression level is 0, then the default compression
level is selected.
level - the compression strategy
public Deflater(int level,
int windowBits)
SPEED, MEDIUM or
COMPACT) and the provided window size. The
window size is expressed in bits and may range from 9 to 15
(inclusive). The DEFLATE format uses a 15-bit window; by
using a smaller window, the produced stream can be inflated
with less memory (but compression ratio is lowered). If the
compression level is 0, then the default compression level is
selected.
level - the compression strategywindowBits - the window bit size (9 to 15)| Method Detail |
|---|
public void reset()
Deflater instance for a new compression run.
This method aborts the current compression, if any, without
flushing any buffered data.
public java.io.OutputStream getOut()
public void setOut(java.io.OutputStream out)
out - the new transport stream
public void processDictionary(java.io.InputStream dict)
throws java.io.IOException
Process a dictionary. The provided stream is read, and all bytes are used for subsequent LZ77 compression. The dictionary stream is read until its end.
A dictionary may be input only before processing any real
data (or immediately after a reset()).
dict - the dictionary stream
java.io.IOException - on I/O error with the dictionary streampublic void processDictionary(byte[] dict)
Process a dictionary. The dictionary is a bunch of bytes which are considered as previously encountered input data bytes, and can be used for further LZ77 compression.
A dictionary may be input only before processing any real
data (or immediately after a reset()).
dict - the dictionary
public void processDictionary(byte[] dict,
int off,
int len)
Process a dictionary. The dictionary is a bunch of bytes which are considered as previously encountered input data bytes, and can be used for further LZ77 compression.
A dictionary may be input only before processing any real
data (or immediately after a reset()).
dict - the dictionaryoff - the dictionary offsetlen - the dictionary length
public void process(byte[] buf,
int off,
int len)
throws java.io.IOException
buf - the data bufferoff - the data offsetlen - the data length (in bytes)
java.io.IOException - on I/O error with the transport stream
public void flush()
throws java.io.IOException
java.io.IOException - on I/O error with the transport stream
public void terminate()
throws java.io.IOException
java.io.IOException - on I/O error with the transport stream
public void flushPartial()
throws java.io.IOException
Z_PARTIAL_FLUSH. The current
block, if any, is closed, and one or two empty type 1 blocks
are added. All complete bytes are sent on the transport
stream. The transport stream is NOT flushed.
java.io.IOException - on I/O error with the transport stream
public void flushSync(boolean withData)
throws java.io.IOException
Z_SYNC_FLUSH. The current
block, if any, is closed, and one empty type 0 block is
added. After this call, the stream is byte-aligned. The type
0 block ends with the aligned four-byte sequence 00 00 FF FF;
these four bytes are omitted if withData is
false. The transport stream is NOT flushed.
withData - false to omit the 00 00 FF FF bytes
java.io.IOException - on I/O error with the transport stream
public void flushFull(boolean withData)
throws java.io.IOException
Z_FULL_FLUSH. The transport stream is
NOT flushed.
withData - false to omit the 00 00 FF FF bytes
java.io.IOException - on I/O error with the transport stream
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||