InputStream implementation used for
reading uncompressed data
and compressing it on the fly, such that reads return compressed
data.
It is reverse of LZFInputStream (which instead uncompresses data).
com.ning.compress.lzf.LZFInputStream
| Modifier and Type | Field and Description |
|---|---|
| protected int | _bufferLength
Length of the current uncompressed bytes buffer |
| protected int | _bufferPosition
The current position (next char to output) in the uncompressed bytes buffer. |
| protected boolean | _cfgFullReads
Flag that indicates whether we force full reads (reading of as many bytes as requested), or 'optimal' reads (up to as many as available, but at least one). |
| protected byte[] | _encodedBytes
Buffer that contains compressed data that is returned to readers. |
| private ChunkEncoder | |
| protected byte[] | _inputBuffer
Buffer in which uncompressed input is first read, before getting
encoded in |
| protected final InputStream | _inputStream
Stream used for reading data to be compressed |
| protected boolean | _inputStreamClosed
Flag that indicates if we have already called 'inputStream.close()' (to avoid calling it multiple times) |
| protected int | _readCount
Number of bytes read from the underlying |
| private final BufferRecycler |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | LZFCompressingInputStream(final ChunkEncoder encoder, InputStream in, BufferRecycler bufferRecycler)
|
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public int | available()
Overrides java. |
| public void | close()
Overrides java. Implements java. |
| public int | read()
Implements abstract java. |
| public int | read(final byte[]
the buffer into which the data is read. buffer)Overrides java. b.
|
| public int | read(final byte[]
the buffer into which the data is read. buffer, int the start offset in array offset, int b
at which the data is written.the maximum number of bytes to read. length)Overrides java. len bytes of data from the input stream into
an array of bytes.
|
| protected boolean | |
| public void | setUseFullReads(boolean b)
Method that can be used define whether reads should be "full" or "optimal": former means that full compressed blocks are read right away as needed, optimal that only smaller chunks are read at a time, more being read as needed. |
| public long | skip(long
the number of bytes to be skipped. n)Overrides java. |
| _bufferLength | back to summary |
|---|---|
| protected int _bufferLength Length of the current uncompressed bytes buffer | |
| _bufferPosition | back to summary |
|---|---|
| protected int _bufferPosition The current position (next char to output) in the uncompressed bytes buffer. | |
| _cfgFullReads | back to summary |
|---|---|
| protected boolean _cfgFullReads Flag that indicates whether we force full reads (reading of as many bytes as requested), or 'optimal' reads (up to as many as available, but at least one). Default is false, meaning that 'optimal' read is used. | |
| _encodedBytes | back to summary |
|---|---|
| protected byte[] _encodedBytes Buffer that contains compressed data that is returned to readers. | |
| _encoder | back to summary |
|---|---|
| private ChunkEncoder _encoder | |
| _inputBuffer | back to summary |
|---|---|
| protected byte[] _inputBuffer Buffer in which uncompressed input is first read, before getting
encoded in | |
| _inputStream | back to summary |
|---|---|
| protected final InputStream _inputStream Stream used for reading data to be compressed | |
| _inputStreamClosed | back to summary |
|---|---|
| protected boolean _inputStreamClosed Flag that indicates if we have already called 'inputStream.close()' (to avoid calling it multiple times) | |
| _readCount | back to summary |
|---|---|
| protected int _readCount Number of bytes read from the underlying | |
| _recycler | back to summary |
|---|---|
| private final BufferRecycler _recycler | |
| LZFCompressingInputStream | back to summary |
|---|---|
| public LZFCompressingInputStream(InputStream in) | |
| LZFCompressingInputStream | back to summary |
|---|---|
| public LZFCompressingInputStream(final ChunkEncoder encoder, InputStream in) | |
| LZFCompressingInputStream | back to summary |
|---|---|
| public LZFCompressingInputStream(final ChunkEncoder encoder, InputStream in, BufferRecycler bufferRecycler) | |
| _closeInput | back to summary |
|---|---|
| private void _closeInput() throws IOException | |
| available | back to summary |
|---|---|
| public int available() Overrides java. Doc from java. Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. The read might be on the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes. Note that while some implementations of A subclass's implementation of this method may choose to throw an
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this input stream and releases any system resources associated with the stream.
| |
| read | back to summary |
|---|---|
| public int read() throws IOException Implements abstract java. Doc from java. Reads the next byte of data from the input stream. The value byte is
returned as an
| |
| read | back to summary |
|---|---|
| public int read(final byte[] buffer) throws IOException Overrides java. Doc from java. Reads some number of bytes from the input stream and stores them into
the buffer array If the length of The first byte read is stored into element
| |
| read | back to summary |
|---|---|
| public int read(final byte[] buffer, int offset, int length) throws IOException Overrides java. Doc from java. Reads up to This method blocks until input data is available, end of file is detected, or an exception is thrown. If The first byte read is stored into element In every case, elements
| |
| readyBuffer | back to summary |
|---|---|
| protected boolean readyBuffer() throws IOException Fill the uncompressed bytes buffer by reading the underlying inputStream. | |
| setUseFullReads | back to summary |
|---|---|
| public void setUseFullReads(boolean b) Method that can be used define whether reads should be "full" or "optimal": former means that full compressed blocks are read right away as needed, optimal that only smaller chunks are read at a time, more being read as needed. | |
| skip | back to summary |
|---|---|
| public long skip(long n) throws IOException Overrides java. Overridden to just skip at most a single chunk at a time
| |