public abstract class AbstractLZ77CompressorInputStream extends CompressorInputStream
Assumes the stream consists of blocks of literal data and
back-references (called copies) in any order. Of course the first
block must be a literal block for the scheme to work - unless the
prefill method has been used to provide initial
data that is never returned by read but only used for
back-references.
Subclasses must override the three-arg read method
as the no-arg version delegates to it and the default
implementation delegates to the no-arg version, leading to infinite
mutual recursion and a StackOverflowError otherwise.
The contract for subclasses' read implementation is:
readOneByte() to access the underlying stream
directly.startLiteral(long) to
tell this class about it and read the literal data using readLiteral(byte[], int, int) until it returns 0. hasMoreDataInBlock() will return false before the next
call to readLiteral(byte[], int, int) would return 0.startBackReference(int, long) to
tell this class about it and read the literal data using readBackReference(byte[], int, int) until it returns 0. hasMoreDataInBlock() will return false before the next
call to readBackReference(byte[], int, int) would return 0.-1
as this class' methods will never do so themselves.readOneByte() and readLiteral(byte[], int, int) update the counter
for bytes read.
| Constructor and Description |
|---|
AbstractLZ77CompressorInputStream(java.io.InputStream is,
int windowSize)
Creates a new LZ77 input stream.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
void |
close() |
int |
getSize()
Get the uncompressed size of the stream
|
void |
prefill(byte[] data)
Adds some initial data to fill the window with.
|
int |
read() |
getBytesRead, getCountpublic AbstractLZ77CompressorInputStream(java.io.InputStream is,
int windowSize)
throws java.io.IOException
is - An InputStream to read compressed data fromwindowSize - Size of the window kept for back-references, must be bigger than the biggest offset expected.java.io.IOException - if reading failspublic int read()
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.InputStreamjava.io.IOExceptionpublic int available()
available in class java.io.InputStreampublic int getSize()
public void prefill(byte[] data)
This is used if the stream has been cut into blocks and back-references of one block may refer to data of the previous block(s). One such example is the LZ4 frame format using block dependency.
data - the data to fill the window with.java.lang.IllegalStateException - if the stream has already started to read data"Copyright © 2010 - 2018 Adobe Systems Incorporated. All Rights Reserved"