public abstract class ChunkDecoder extends Object
Note that instances have no state, so they are fully thread-safe and reusable.
Modifier and Type | Field and Description |
---|---|
protected static byte |
BYTE_NULL |
protected static int |
HEADER_BYTES |
Constructor and Description |
---|
ChunkDecoder() |
Modifier and Type | Method and Description |
---|---|
protected void |
_reportArrayOverflow(byte[] targetBuffer,
int outPtr,
int dataLen)
Helper method called when it is determined that the target buffer can not
hold all data to copy or uncompress
|
protected void |
_reportCorruptHeader() |
static int |
calculateUncompressedSize(byte[] data,
int ptr,
int length)
Helper method that will calculate total uncompressed size, for sequence of
one or more LZF blocks stored in given byte array.
|
byte[] |
decode(byte[] inputBuffer)
Method for decompressing a block of input data encoded in LZF
block structure (compatible with lzf command line utility),
and can consist of any number of blocks.
|
int |
decode(byte[] inputBuffer,
byte[] targetBuffer)
Method for decompressing a block of input data encoded in LZF
block structure (compatible with lzf command line utility),
and can consist of any number of blocks.
|
byte[] |
decode(byte[] inputBuffer,
int inputPtr,
int inputLen)
Method for decompressing a block of input data encoded in LZF
block structure (compatible with lzf command line utility),
and can consist of any number of blocks.
|
int |
decode(byte[] sourceBuffer,
int inPtr,
int inLength,
byte[] targetBuffer)
Method for decompressing a block of input data encoded in LZF
block structure (compatible with LZF command line utility),
and can consist of any number of blocks.
|
abstract void |
decodeChunk(byte[] in,
int inPos,
byte[] out,
int outPos,
int outEnd)
Main decode method for individual chunks.
|
abstract int |
decodeChunk(InputStream is,
byte[] inputBuffer,
byte[] outputBuffer)
Main decode from a stream.
|
protected static void |
readFully(InputStream is,
boolean compressed,
byte[] outputBuffer,
int offset,
int len) |
protected static int |
readHeader(InputStream is,
byte[] inputBuffer)
Helper method to forcibly load header bytes that must be read before
chunk can be handled.
|
protected static void |
skipFully(InputStream is,
int amount) |
abstract int |
skipOrDecodeChunk(InputStream is,
byte[] inputBuffer,
byte[] outputBuffer,
long maxToSkip) |
protected static int |
uint16(byte[] data,
int ptr) |
protected static final byte BYTE_NULL
protected static final int HEADER_BYTES
public final byte[] decode(byte[] inputBuffer) throws LZFException
LZFException
public final byte[] decode(byte[] inputBuffer, int inputPtr, int inputLen) throws LZFException
LZFException
public final int decode(byte[] inputBuffer, byte[] targetBuffer) throws LZFException
LZFException
public int decode(byte[] sourceBuffer, int inPtr, int inLength, byte[] targetBuffer) throws LZFException
LZFException
public abstract int decodeChunk(InputStream is, byte[] inputBuffer, byte[] outputBuffer) throws IOException
is
- An input stream of LZF compressed bytesinputBuffer
- A byte array used as a scratch area.outputBuffer
- A byte array in which the result is returnedIOException
public abstract void decodeChunk(byte[] in, int inPos, byte[] out, int outPos, int outEnd) throws LZFException
LZFException
public abstract int skipOrDecodeChunk(InputStream is, byte[] inputBuffer, byte[] outputBuffer, long maxToSkip) throws IOException
returnValue = -(decodedAmount + 2)
)IOException
public static int calculateUncompressedSize(byte[] data, int ptr, int length) throws LZFException
LZFException
protected static final int uint16(byte[] data, int ptr)
protected static final int readHeader(InputStream is, byte[] inputBuffer) throws IOException
IOException
protected static final void readFully(InputStream is, boolean compressed, byte[] outputBuffer, int offset, int len) throws IOException
IOException
protected static final void skipFully(InputStream is, int amount) throws IOException
IOException
protected void _reportCorruptHeader() throws LZFException
LZFException
protected void _reportArrayOverflow(byte[] targetBuffer, int outPtr, int dataLen) throws LZFException
LZFException
Copyright © 2017. All Rights Reserved.