LocationAware
, Closeable
, AutoCloseable
AsyncBlockCompressedInputStream
public class BlockCompressedInputStream extends InputStream implements LocationAware
Modifier and Type | Class | Description |
---|---|---|
protected static class |
BlockCompressedInputStream.DecompressedBlock |
|
static class |
BlockCompressedInputStream.FileTermination |
Modifier and Type | Field | Description |
---|---|---|
static String |
CANNOT_SEEK_CLOSED_STREAM_MSG |
|
static String |
CANNOT_SEEK_STREAM_MSG |
|
static String |
INCORRECT_HEADER_SIZE_MSG |
|
static String |
INVALID_FILE_PTR_MSG |
|
static String |
PREMATURE_END_MSG |
|
static String |
UNEXPECTED_BLOCK_LENGTH_MSG |
Constructor | Description |
---|---|
BlockCompressedInputStream(SeekableStream strm) |
For providing some arbitrary data source.
|
BlockCompressedInputStream(SeekableStream strm,
InflaterFactory inflaterFactory) |
For providing some arbitrary data source.
|
BlockCompressedInputStream(File file) |
Use this ctor if you wish to call seek()
|
BlockCompressedInputStream(File file,
InflaterFactory inflaterFactory) |
Use this ctor if you wish to call seek()
|
BlockCompressedInputStream(InputStream stream) |
Note that seek() is not supported if this ctor is used.
|
BlockCompressedInputStream(InputStream stream,
boolean allowBuffering) |
Note that seek() is not supported if this ctor is used.
|
BlockCompressedInputStream(InputStream stream,
boolean allowBuffering,
InflaterFactory inflaterFactory) |
Note that seek() is not supported if this ctor is used.
|
BlockCompressedInputStream(InputStream stream,
InflaterFactory inflaterFactory) |
Note that seek() is not supported if this ctor is used.
|
BlockCompressedInputStream(URL url) |
|
BlockCompressedInputStream(URL url,
InflaterFactory inflaterFactory) |
Modifier and Type | Method | Description |
---|---|---|
static void |
assertNonDefectiveFile(File file) |
|
int |
available() |
|
static BlockCompressedInputStream.FileTermination |
checkTermination(File file) |
|
static BlockCompressedInputStream.FileTermination |
checkTermination(SeekableByteChannel channel) |
check the status of the final bzgipped block for the given bgzipped resource
|
static BlockCompressedInputStream.FileTermination |
checkTermination(Path path) |
|
void |
close() |
Closes the underlying InputStream or RandomAccessFile
|
boolean |
endOfBlock() |
|
static long |
getFileBlock(long bgzfOffset) |
|
long |
getFilePointer() |
|
long |
getPosition() |
The current offset, in bytes, of this stream/writer/file.
|
static boolean |
isValidFile(InputStream stream) |
|
protected BlockCompressedInputStream.DecompressedBlock |
nextBlock(byte[] bufferAvailableForReuse) |
Reads and decompresses the next block
|
protected void |
prepareForSeek() |
Performs cleanup required before seek is called on the underlying stream
|
protected BlockCompressedInputStream.DecompressedBlock |
processNextBlock(byte[] bufferAvailableForReuse) |
Decompress the next block from the input stream.
|
int |
read() |
Reads the next byte of data from the input stream.
|
int |
read(byte[] buffer) |
Reads some number of bytes from the input stream and stores them into the buffer array b.
|
int |
read(byte[] buffer,
int offset,
int length) |
Reads up to len bytes of data from the input stream into an array of bytes.
|
String |
readLine() |
Reads a whole line.
|
void |
seek(long pos) |
Seek to the given position in the file.
|
void |
setCheckCrcs(boolean check) |
Determines whether or not the inflater will re-calculated the CRC on the decompressed data
and check it against the value stored in the GZIP header.
|
mark, markSupported, readAllBytes, readNBytes, reset, skip, transferTo
public static final String INCORRECT_HEADER_SIZE_MSG
public static final String UNEXPECTED_BLOCK_LENGTH_MSG
public static final String PREMATURE_END_MSG
public static final String CANNOT_SEEK_STREAM_MSG
public static final String CANNOT_SEEK_CLOSED_STREAM_MSG
public static final String INVALID_FILE_PTR_MSG
public BlockCompressedInputStream(InputStream stream)
stream
- source of bytespublic BlockCompressedInputStream(InputStream stream, InflaterFactory inflaterFactory)
stream
- source of bytesinflaterFactory
- InflaterFactory
used by BlockGunzipper
public BlockCompressedInputStream(InputStream stream, boolean allowBuffering)
stream
- source of bytesallowBuffering
- if true, allow bufferingpublic BlockCompressedInputStream(InputStream stream, boolean allowBuffering, InflaterFactory inflaterFactory)
stream
- source of bytesallowBuffering
- if true, allow bufferinginflaterFactory
- InflaterFactory
used by BlockGunzipper
public BlockCompressedInputStream(File file) throws IOException
file
- source of bytesIOException
public BlockCompressedInputStream(File file, InflaterFactory inflaterFactory) throws IOException
file
- source of bytesinflaterFactory
- InflaterFactory
used by BlockGunzipper
IOException
public BlockCompressedInputStream(URL url)
url
- source of bytespublic BlockCompressedInputStream(URL url, InflaterFactory inflaterFactory)
url
- source of bytesinflaterFactory
- InflaterFactory
used by BlockGunzipper
public BlockCompressedInputStream(SeekableStream strm)
strm
- source of bytespublic BlockCompressedInputStream(SeekableStream strm, InflaterFactory inflaterFactory)
strm
- source of bytesinflaterFactory
- InflaterFactory
used by BlockGunzipper
public void setCheckCrcs(boolean check)
public int available() throws IOException
available
in class InputStream
IOException
public boolean endOfBlock()
true
if the stream is at the end of a BGZF block,
false
otherwise.public void close() throws IOException
close
in interface AutoCloseable
close
in interface Closeable
close
in class InputStream
IOException
public int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] buffer) throws IOException
read
in class InputStream
buffer
- the buffer into which the data is read.IOException
public String readLine() throws IOException
IOException
- If an I/O error occurspublic int read(byte[] buffer, int offset, int length) throws IOException
read
in class InputStream
buffer
- buffer into which data is read.offset
- the start offset in array b at which the data is written.length
- the maximum number of bytes to read.IOException
public void seek(long pos) throws IOException
pos
- virtual file pointer positionIOException
- if stream is closed or not a file based streamprotected void prepareForSeek()
public long getFilePointer()
public long getPosition()
LocationAware
getPosition
in interface LocationAware
public static long getFileBlock(long bgzfOffset)
public static boolean isValidFile(InputStream stream) throws IOException
stream
- Must be at start of file. Throws RuntimeException if !stream.markSupported().IOException
protected BlockCompressedInputStream.DecompressedBlock nextBlock(byte[] bufferAvailableForReuse)
bufferAvailableForReuse
- decompression buffer available for reuseprotected BlockCompressedInputStream.DecompressedBlock processNextBlock(byte[] bufferAvailableForReuse)
bufferAvailableForReuse
- buffer in which to place decompressed block. A null or
incorrectly sized buffer will result in the buffer being ignored and
a new buffer allocated for decompression.public static BlockCompressedInputStream.FileTermination checkTermination(File file) throws IOException
file
- the file to checkIOException
public static BlockCompressedInputStream.FileTermination checkTermination(Path path) throws IOException
path
- to the file to checkIOException
public static BlockCompressedInputStream.FileTermination checkTermination(SeekableByteChannel channel) throws IOException
channel
- an open channel to read from,
the channel will remain open and the initial position will be restored when the operation completes
this makes no guarantee about the state of the channel if an exception is thrown during readingIOException
public static void assertNonDefectiveFile(File file) throws IOException
IOException