Top Description Inners Fields Constructors Methods
org.apache.commons.compress.compressors.lz4

public Class BlockLZ4CompressorInputStream

extends AbstractLZ77CompressorInputStream
Class Inheritance
Imports
java.io.IOException, .InputStream, org.apache.commons.compress.compressors.lz77support.AbstractLZ77CompressorInputStream, org.apache.commons.compress.utils.ByteUtils

CompressorInputStream for the LZ4 block format.
Since
1.14
See Also
LZ4 Block Format Description

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum

Field Summary

Modifier and TypeField and Description
pack-priv static final int
pack-priv static final int
private int
nextBackReferenceSize

Back-Reference-size part of the block starting byte.

pack-priv static final int
private BlockLZ4CompressorInputStream.State
state

Current state of the stream

pack-priv static final int
Inherited from org.apache.commons.compress.compressors.lz77support.AbstractLZ77CompressorInputStream:
supplier

Constructor Summary

AccessConstructor and Description
public
BlockLZ4CompressorInputStream(final InputStream
An InputStream to read compressed data from
is
)

Creates a new LZ4 input stream.

Method Summary

Modifier and TypeMethod and Description
private boolean

Returns:

false if there is no more back-reference - this means this is the last block of the stream.
initializeBackReference
()

public int
read(final byte[]
the buffer into which the data is read.
b
,
final int
the start offset in array b at which the data is written.
off
,
final int
the maximum number of bytes to read.
len
)

Overrides java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes.
private long
private void
Inherited from org.apache.commons.compress.compressors.lz77support.AbstractLZ77CompressorInputStream:
availableclosegetCompressedCountgetSizehasMoreDataInBlockprefillreadreadBackReferencereadLiteralreadOneBytestartBackReferencestartLiteral

Field Detail

BACK_REFERENCE_SIZE_MASKback to summary
pack-priv static final int BACK_REFERENCE_SIZE_MASK
LITERAL_SIZE_MASKback to summary
pack-priv static final int LITERAL_SIZE_MASK
nextBackReferenceSizeback to summary
private int nextBackReferenceSize

Back-Reference-size part of the block starting byte.

SIZE_BITSback to summary
pack-priv static final int SIZE_BITS
stateback to summary
private BlockLZ4CompressorInputStream.State state

Current state of the stream

WINDOW_SIZEback to summary
pack-priv static final int WINDOW_SIZE

Constructor Detail

BlockLZ4CompressorInputStreamback to summary
public BlockLZ4CompressorInputStream(final InputStream is)

Creates a new LZ4 input stream.

Parameters
is:InputStream

An InputStream to read compressed data from

Method Detail

initializeBackReferenceback to summary
private boolean initializeBackReference() throws IOException
Returns:boolean

false if there is no more back-reference - this means this is the last block of the stream.

readback to summary
public int read(final byte[] b, final int off, final int len) throws IOException

Overrides java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes. An attempt is made to read as many as len bytes, but a smaller number may be read. The number of bytes actually read is returned as an integer.

This method blocks until input data is available, end of file is detected, or an exception is thrown.

If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b.

The first byte read is stored into element b[off], the next one into b[off+1], and so on. The number of bytes read is, at most, equal to len. Let k be the number of bytes actually read; these bytes will be stored in elements b[off] through b[off+k-1], leaving elements b[off+k] through b[off+len-1] unaffected.

In every case, elements b[0] through b[off-1] and elements b[off+len] through b[b.length-1] are unaffected.

Parameters
b:byte[]

the buffer into which the data is read.

off:int

the start offset in array b at which the data is written.

len:int

the maximum number of bytes to read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Annotations
@Override
Exceptions
IOException:
If the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs.
readSizeBytesback to summary
private long readSizeBytes() throws IOException
readSizesback to summary
private void readSizes() throws IOException
org.apache.commons.compress.compressors.lz4 back to summary

private final Enum BlockLZ4CompressorInputStream.State

extends Enum<BlockLZ4CompressorInputStream.State>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final BlockLZ4CompressorInputStream.State
public static final BlockLZ4CompressorInputStream.State
public static final BlockLZ4CompressorInputStream.State
public static final BlockLZ4CompressorInputStream.State
public static final BlockLZ4CompressorInputStream.State

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static BlockLZ4CompressorInputStream.State
public static BlockLZ4CompressorInputStream.State[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

EOFback to summary
public static final BlockLZ4CompressorInputStream.State EOF
IN_BACK_REFERENCEback to summary
public static final BlockLZ4CompressorInputStream.State IN_BACK_REFERENCE
IN_LITERALback to summary
public static final BlockLZ4CompressorInputStream.State IN_LITERAL
LOOKING_FOR_BACK_REFERENCEback to summary
public static final BlockLZ4CompressorInputStream.State LOOKING_FOR_BACK_REFERENCE
NO_BLOCKback to summary
public static final BlockLZ4CompressorInputStream.State NO_BLOCK

Constructor Detail

Stateback to summary
private State()

Method Detail

valueOfback to summary
public static BlockLZ4CompressorInputStream.State valueOf(String name)
valuesback to summary
public static BlockLZ4CompressorInputStream.State[] values()