Class LZFCompressingInputStream
java.lang.Object
java.io.InputStream
com.ning.compress.lzf.LZFCompressingInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
Decorator
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).- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intLength of the current uncompressed bytes bufferprotected intThe current position (next char to output) in the uncompressed bytes buffer.protected booleanFlag 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[]Buffer that contains compressed data that is returned to readers.private ChunkEncoderprotected byte[]Buffer in which uncompressed input is first read, before getting encoded in_encodedBytes.protected final InputStreamStream used for reading data to be compressedprotected booleanFlag that indicates if we have already called 'inputStream.close()' (to avoid calling it multiple times)protected intNumber of bytes read from the underlying_inputStreamprivate final BufferRecycler -
Constructor Summary
ConstructorsConstructorDescriptionLZFCompressingInputStream(ChunkEncoder encoder, InputStream in) LZFCompressingInputStream(ChunkEncoder encoder, InputStream in, BufferRecycler bufferRecycler) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidintvoidclose()intread()intread(byte[] buffer) intread(byte[] buffer, int offset, int length) protected booleanFill the uncompressed bytes buffer by reading the underlying inputStream.voidsetUseFullReads(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.longskip(long n) Overridden to just skip at most a single chunk at a timeMethods inherited from class InputStream
mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skipNBytes, transferTo
-
Field Details
-
_recycler
-
_encoder
-
_inputStream
Stream used for reading data to be compressed -
_inputStreamClosed
protected boolean _inputStreamClosedFlag that indicates if we have already called 'inputStream.close()' (to avoid calling it multiple times) -
_cfgFullReads
protected boolean _cfgFullReadsFlag 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. -
_inputBuffer
protected byte[] _inputBufferBuffer in which uncompressed input is first read, before getting encoded in_encodedBytes. -
_encodedBytes
protected byte[] _encodedBytesBuffer that contains compressed data that is returned to readers. -
_bufferPosition
protected int _bufferPositionThe current position (next char to output) in the uncompressed bytes buffer. -
_bufferLength
protected int _bufferLengthLength of the current uncompressed bytes buffer -
_readCount
protected int _readCountNumber of bytes read from the underlying_inputStream
-
-
Constructor Details
-
LZFCompressingInputStream
-
LZFCompressingInputStream
-
LZFCompressingInputStream
public LZFCompressingInputStream(ChunkEncoder encoder, InputStream in, BufferRecycler bufferRecycler)
-
-
Method Details
-
setUseFullReads
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. -
available
public int available()- Overrides:
availablein classInputStream
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
_closeInput
- Throws:
IOException
-
skip
Overridden to just skip at most a single chunk at a time- Overrides:
skipin classInputStream- Throws:
IOException
-
readyBuffer
Fill the uncompressed bytes buffer by reading the underlying inputStream.- Throws:
IOException
-