class Zlib
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
COMPRESSION_DEFAULT
Default compression
|
static int |
COMPRESSION_MAX
Try o get the best possible compression
|
static int |
COMPRESSION_MIN
Favor speed over compression ratio
|
static int |
COMPRESSION_NONE
No compression
|
private int |
compressionLevel
The requested compression level
|
private int |
mode
The selected operation mode : INFLATE or DEFLATE
|
static int |
MODE_DEFLATER
Compression mode
|
static int |
MODE_INFLATER
Uncompress mode
|
private com.jcraft.jzlib.ZStream |
zStream
The inner stream used to inflate or deflate the data
|
| Constructor and Description |
|---|
Zlib(int compressionLevel,
int mode)
Creates an instance of the ZLib class.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cleanUp()
Cleans up the resources used by the compression library.
|
IoBuffer |
deflate(IoBuffer inBuffer)
Compress the input.
|
IoBuffer |
inflate(IoBuffer inBuffer)
Uncompress the given buffer, returning it in a new buffer.
|
public static final int COMPRESSION_MAX
public static final int COMPRESSION_MIN
public static final int COMPRESSION_NONE
public static final int COMPRESSION_DEFAULT
public static final int MODE_DEFLATER
public static final int MODE_INFLATER
private int compressionLevel
private com.jcraft.jzlib.ZStream zStream
private int mode
public Zlib(int compressionLevel,
int mode)
compressionLevel - the level of compression that should be used. One of
COMPRESSION_MAX, COMPRESSION_MIN,
COMPRESSION_NONE or COMPRESSION_DEFAULTmode - the mode in which the instance will operate. Can be either
of MODE_DEFLATER or MODE_INFLATERjava.lang.IllegalArgumentException - if the mode is incorrectpublic IoBuffer inflate(IoBuffer inBuffer) throws java.io.IOException
inBuffer - the IoBuffer to be decompressed. The contents
of the buffer are transferred into a local byte array and the buffer is
flipped and returned intact.java.io.IOException - if the decompression of the data failed for some reason.java.lang.IllegalArgumentException - if the mode is not MODE_DEFLATERpublic IoBuffer deflate(IoBuffer inBuffer) throws java.io.IOException
inBuffer - the buffer to be compressed. The contents are transferred
into a local byte array and the buffer is flipped and returned intact.java.io.IOException - if the compression of teh buffer failed for some reasonjava.lang.IllegalStateException - if the mode is not MODE_DEFLATERpublic void cleanUp()