public class ZlibCompressor extends Object implements Compressor
Compressor based on the popular
zlib compression algorithm.
http://www.zlib.net/| 限定符和类型 | 类和说明 |
|---|---|
static class |
ZlibCompressor.CompressionHeader
The type of header for compressed data.
|
static class |
ZlibCompressor.CompressionLevel
The compression level for zlib library.
|
static class |
ZlibCompressor.CompressionStrategy
The compression level for zlib library.
|
| 构造器和说明 |
|---|
ZlibCompressor()
Creates a new compressor with the default compression level.
|
ZlibCompressor(Configuration conf)
Creates a new compressor, taking settings from the configuration.
|
ZlibCompressor(ZlibCompressor.CompressionLevel level,
ZlibCompressor.CompressionStrategy strategy,
ZlibCompressor.CompressionHeader header,
int directBufferSize)
Creates a new compressor using the specified compression level.
|
| 限定符和类型 | 方法和说明 |
|---|---|
int |
compress(byte[] b,
int off,
int len)
Fills specified buffer with compressed data.
|
protected void |
construct(ZlibCompressor.CompressionLevel level,
ZlibCompressor.CompressionStrategy strategy,
ZlibCompressor.CompressionHeader header,
int directBufferSize) |
void |
end()
Closes the compressor and discards any unprocessed input.
|
void |
finish()
When called, indicates that compression should end
with the current contents of the input buffer.
|
boolean |
finished()
Returns true if the end of the compressed
data output stream has been reached.
|
long |
getBytesRead()
Returns the total number of uncompressed bytes input so far.
|
long |
getBytesWritten()
Returns the total number of compressed bytes output so far.
|
boolean |
needsInput()
Returns true if the input data buffer is empty and
#setInput() should be called to provide more input.
|
void |
reinit(Configuration conf)
Prepare the compressor to be used in a new stream with settings defined in
the given Configuration.
|
void |
reset()
Resets compressor so that a new set of input data can be processed.
|
void |
setDictionary(byte[] b,
int off,
int len)
Sets preset dictionary for compression.
|
void |
setInput(byte[] b,
int off,
int len)
Sets input data for compression.
|
public ZlibCompressor()
public ZlibCompressor(Configuration conf)
public ZlibCompressor(ZlibCompressor.CompressionLevel level, ZlibCompressor.CompressionStrategy strategy, ZlibCompressor.CompressionHeader header, int directBufferSize)
level - Compression level #CompressionLevelstrategy - Compression strategy #CompressionStrategyheader - Compression header #CompressionHeaderdirectBufferSize - Size of the direct buffer to be used.protected final void construct(ZlibCompressor.CompressionLevel level, ZlibCompressor.CompressionStrategy strategy, ZlibCompressor.CompressionHeader header, int directBufferSize)
public void reinit(Configuration conf)
reinit 在接口中 Compressorconf - Configuration storing new settingspublic void setInput(byte[] b,
int off,
int len)
Compressortrue indicating that more input data is required.setInput 在接口中 Compressorb - Input dataoff - Start offsetlen - Lengthpublic void setDictionary(byte[] b,
int off,
int len)
CompressorsetDictionary 在接口中 Compressorb - Dictionary data bytesoff - Start offsetlen - Lengthpublic boolean needsInput()
CompressorneedsInput 在接口中 Compressortrue if the input data buffer is empty and
#setInput() should be called in order to provide more input.public void finish()
Compressorfinish 在接口中 Compressorpublic boolean finished()
Compressorfinished 在接口中 Compressortrue if the end of the compressed
data output stream has been reached.public int compress(byte[] b,
int off,
int len)
throws IOException
Compressorcompress 在接口中 Compressorb - Buffer for the compressed dataoff - Start offset of the datalen - Size of the bufferIOExceptionpublic long getBytesWritten()
getBytesWritten 在接口中 Compressorpublic long getBytesRead()
getBytesRead 在接口中 Compressorpublic void reset()
Compressorreset 在接口中 Compressorpublic void end()
Compressorend 在接口中 CompressorCopyright © 2009 The Apache Software Foundation