public final class CompressLZF extends java.lang.Object implements Compressor
This class implements the LZF lossless data compression algorithm. LZF is a Lempel-Ziv variant with byte-aligned output, and optimized for speed.
Safety/Use Notes:
The LZF compressed format knows literal runs and back-references:
The first byte of the compressed stream is the control byte. For literal runs, the highest three bits of the control byte are not set, the lower bits are the literal run length, and the next bytes are data to copy directly into the output. For back-references, the highest three bits of the control byte are the back-reference length. If all three bits are set, then the back-reference length is stored in the next byte. The lower bits of the control byte combined with the next byte form the offset for the back-reference.
DEFLATE, LZF, NO
Constructor and Description |
---|
CompressLZF() |
Modifier and Type | Method and Description |
---|---|
int |
compress(byte[] in,
int inPos,
int inLen,
byte[] out,
int outPos)
Compress a number of bytes.
|
int |
compress(java.nio.ByteBuffer in,
int inPos,
byte[] out,
int outPos)
Compress a number of bytes.
|
void |
expand(byte[] in,
int inPos,
int inLen,
byte[] out,
int outPos,
int outLen)
Expand a number of compressed bytes.
|
static void |
expand(java.nio.ByteBuffer in,
java.nio.ByteBuffer out)
Expand a number of compressed bytes.
|
int |
getAlgorithm()
Get the compression algorithm type.
|
void |
setOptions(java.lang.String options)
Set the compression options.
|
public void setOptions(java.lang.String options)
Compressor
setOptions
in interface Compressor
options
- the optionspublic int compress(byte[] in, int inPos, int inLen, byte[] out, int outPos)
Compressor
compress
in interface Compressor
in
- the input datainPos
- the offset at the input arrayinLen
- the number of bytes to compressout
- the output areaoutPos
- the offset at the output arraypublic int compress(java.nio.ByteBuffer in, int inPos, byte[] out, int outPos)
in
- the input datainPos
- the offset at the input bufferout
- the output areaoutPos
- the offset at the output arraypublic void expand(byte[] in, int inPos, int inLen, byte[] out, int outPos, int outLen)
Compressor
expand
in interface Compressor
in
- the compressed datainPos
- the offset at the input arrayinLen
- the number of bytes to readout
- the output areaoutPos
- the offset at the output arrayoutLen
- the size of the uncompressed datapublic static void expand(java.nio.ByteBuffer in, java.nio.ByteBuffer out)
in
- the compressed dataout
- the output areapublic int getAlgorithm()
Compressor
getAlgorithm
in interface Compressor