|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.bigzip.plugin.compression.io.AbstractStream | +--com.bigzip.plugin.compression.io.CompressionStream
This class implements the archive IO stream for compressing data in the "deflate" compression format and decomressing data using the "inflate" decompression scheme. It is also used as the basis for other types of compression filters, such as GZIPOutputStream.
java.util.zip.Deflater
,
java.util.zip.Inflater
,
CheckedStream
Field Summary | |
protected byte[] |
buf
Output buffer for writing compressed data. |
protected Compressor |
comp
Compressor for this stream. |
protected Decompressor |
decomp
Decompressor for this stream. |
protected int |
len
Length of input buffer. |
Fields inherited from class com.bigzip.plugin.compression.io.AbstractStream |
clientStream |
Constructor Summary | |
CompressionStream(AbstractStream clientStream)
Creates a new random access stream with a default buffer size of 512. |
|
CompressionStream(AbstractStream clientStream,
Compressor comp)
Creates a new random access stream with the specified compressor and a default buffer size of 512. |
|
CompressionStream(AbstractStream clientStream,
Compressor comp,
Decompressor decomp)
Creates a new random access stream with the specified compressor and a default buffer size of 512. |
|
CompressionStream(AbstractStream clientStream,
Compressor comp,
Decompressor decomp,
int size)
Creates a new random access stream with the specified compressor and buffer size. |
|
CompressionStream(AbstractStream clientStream,
Decompressor decomp)
Creates a new random access stream with the specified compressor and a default buffer size of 512. |
|
CompressionStream(AbstractStream clientStream,
int size)
Creates a new random access stream with the specified buffer size. |
Method Summary | |
int |
availableCompress()
Returns 0 after EOF has reached, otherwise always return 1. |
void |
deflate()
Writes next block of compressed data to the random access stream. |
protected void |
fill()
Fills input buffer with more data to decompress. |
void |
finish()
Finishes writing compressed data to the random access stream without closing the underlying stream. |
Compressor |
getCompressor()
|
Decompressor |
getDecompressor()
|
int |
read()
Reads a byte of uncompressed data. |
int |
read(byte[] b,
int off,
int len)
Reads uncompressed data into an array of bytes. |
void |
readFully(byte[] b,
int off,
int len)
Reads data that is not compressed into an array of bytes. |
void |
resetEngine()
Retrieves new instances of the compressor and decompressor. |
void |
setCompressor(Compressor comp)
Assigns a new compressing engine. |
void |
setDecompressor(Decompressor decomp)
Assigns a new compressing engine. |
int |
skipBytes(int n)
Skips specified number of bytes of uncompressed data. |
void |
write(byte[] b,
int off,
int len)
Writes an array of bytes to the compressed random access stream. |
void |
write(int b)
Writes a byte to the compressed random access stream. |
Methods inherited from class com.bigzip.plugin.compression.io.AbstractStream |
close, ensureOpen, getFilePointer, isClosed, length, read, readBoolean, readByte, readChar, readDirect, readDirect, readDouble, readFloat, readInt, readInt, readLine, readLong, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, seek, setClientStream, setClosed, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDirect, writeDirect, writeDouble, writeFloat, writeFully, writeInt, writeLong, writeShort, writeUTF |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Compressor comp
protected Decompressor decomp
protected byte[] buf
protected int len
Constructor Detail |
public CompressionStream(AbstractStream clientStream, Compressor comp, Decompressor decomp, int size)
clientStream
- the random access streamcomp
- the compressor ("deflater")decomp
- the decompressor ("inflater")len
- the output buffer sizejava.lang.IllegalArgumentException
- if size is <= 0public CompressionStream(AbstractStream clientStream, Compressor comp, Decompressor decomp)
clientStream
- the random access streamcomp
- the compressor ("deflater")decomp
- the decompressor ("inflater")public CompressionStream(AbstractStream clientStream, Compressor comp)
clientStream
- the random access streamcomp
- the compressor ("deflater")public CompressionStream(AbstractStream clientStream, Decompressor decomp)
clientStream
- the random access streamdecomp
- the decompressor ("inflater")public CompressionStream(AbstractStream clientStream, int size)
clientStream
- the random access streamlen
- the output buffer sizejava.lang.IllegalArgumentException
- if size is <= 0public CompressionStream(AbstractStream clientStream)
clientStream
- the random access streamMethod Detail |
public int read() throws java.io.IOException
read
in class AbstractStream
java.io.IOException
- if an I/O error has occurredpublic int read(byte[] b, int off, int len) throws java.io.IOException
read
in class AbstractStream
b
- the buffer into which the data is readoff
- the start offset of the datalen
- the maximum number of bytes readjava.util.zip.DataFormatException
- if an archive format error has occurredjava.io.IOException
- if an I/O error has occurredpublic void readFully(byte[] b, int off, int len) throws java.io.IOException
readFully
in class AbstractStream
b
- the buffer into which the data is readoff
- the start offset of the datalen
- the maximum number of bytes readZipException
- if a ZIP format error has occurredjava.io.IOException
- if an I/O error has occurredpublic void write(int b) throws java.io.IOException
write
in class AbstractStream
b
- the byte to be writtenjava.io.IOException
- if an I/O error has occurredpublic void write(byte[] b, int off, int len) throws java.io.IOException
write
in class AbstractStream
outputBuffer
- the data to be writtenoff
- the start offset of the datalen
- the length of the datajava.io.IOException
- if an I/O error has occurredpublic int skipBytes(int n) throws java.io.IOException
skipBytes
in class AbstractStream
n
- the number of bytes to skipjava.io.IOException
- if an I/O error has occurredjava.lang.IllegalArgumentException
- if n < 0public void resetEngine()
This should be used where the engines are designed to nolonger function upon the call to finalise.
public Compressor getCompressor()
public void setCompressor(Compressor comp)
Compressor
- the new engine to perform the compression.public Decompressor getDecompressor()
public void setDecompressor(Decompressor decomp)
Compressor
- the new engine to perform the compression.public void finish() throws java.io.IOException
finish
in class AbstractStream
java.io.IOException
- if an I/O error has occurredpublic int availableCompress() throws java.io.IOException
Programs should not count on this method to return the actual number of bytes that could be read without blocking.
java.io.IOException
- if an I/O error occurs.public void deflate() throws java.io.IOException
protected void fill() throws java.io.IOException
java.io.IOException
- if an I/O error has occurred
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |