public class SeekableLookaheadStream extends SeekableInputStream
Modifier and Type | Class and Description |
---|---|
static class |
SeekableLookaheadStream.MaxLookaheadReachedException |
Modifier and Type | Field and Description |
---|---|
protected static int |
DEFAULT_LOOKAHEAD_BUFFER_SIZE |
bitOffset, byteOrder, flushedPos
Constructor and Description |
---|
SeekableLookaheadStream(SeekableInputStream source) |
SeekableLookaheadStream(SeekableInputStream source,
int maxLookahead) |
Modifier and Type | Method and Description |
---|---|
void |
consume(int count)
consume the specified number of characters looked ahead.
|
protected boolean |
fill() |
protected int |
getBufSize() |
protected int |
getInBufPos() |
long |
getSizeEstimate()
A rough estimated size for this stream instance, which is used for internal cache management.
|
protected SeekableInputStream |
getSource() |
protected long |
getSourceStreamPosition() |
long |
getStreamPosition() |
long |
length()
Returns the length of this stream contents, if available.
|
int |
lookahead(int index)
Looks up the data in the stream at the given index.
|
int |
read()
Reads a single byte from the stream and returns it as an
int between 0 and 255. |
int |
read(byte[] b,
int off,
int len)
Reads up to
len bytes from the stream, and stores them into b
starting at index off . |
protected void |
resetBuffer() |
void |
seek(long offset)
Sets the current stream position, measured from the beginning of this data stream, at which the
next read occurs.
|
protected void |
sourceSeek(long offset) |
checkClosed, close, flush, flushBefore, getBitOffset, getByteOrder, getFlushedPosition, isCached, isCachedFile, isCachedMemory, mark, mark, read, readBit, readBits, readBoolean, readByte, readBytes, readChar, readDouble, readFloat, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readInt, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedInt, readUnsignedInt, readUnsignedShort, readUTF, reset, resetToInitialState, setBitOffset, setByteOrder, skip, skipBytes, skipBytes
available, markSupported
protected static final int DEFAULT_LOOKAHEAD_BUFFER_SIZE
public SeekableLookaheadStream(SeekableInputStream source, int maxLookahead)
public SeekableLookaheadStream(SeekableInputStream source)
public int read(byte[] b, int off, int len) throws IOException
SeekableInputStream
len
bytes from the stream, and stores them into b
starting at index off
. If no bytes can be read because the end of the stream has
been reached, -1
is returned.
The bit offset within the stream must be reset to zero before the read occurs.
Subclasses must provide an implementation for this method. The subclass implementation should update the stream position before exiting.
read
in interface ImageInputStream
read
in class SeekableInputStream
b
- an array of bytes to be written to.off
- the starting position within b
to write to.len
- the maximum number of bytes to read.-1
to indicate EOF.IOException
- if an I/O error occurs.public int read() throws IOException
SeekableInputStream
int
between 0 and 255. If
EOF is reached, -1
is returned.
Subclasses must provide an implementation for this method. The subclass implementation should update the stream position before exiting.
The bit offset within the stream must be reset to zero before the read occurs.
read
in interface ImageInputStream
read
in class SeekableInputStream
-1
if EOF is reached.IOException
- if the stream has been closed.public long length() throws IOException
SeekableInputStream
length
in interface ImageInputStream
length
in class SeekableInputStream
IOException
- if an I/O error occurs.public int lookahead(int index) throws IOException
index
- The index of the data that shall be looked up in the stream. It has to be a positive
integer, which is between 1 and maxLookaheadIOException
public void seek(long offset) throws IOException
SeekableInputStream
EOFException
will be thrown
only if a read is performed. The bit offset is set to 0.
An IndexOutOfBoundsException
will be thrown if pos
is smaller than
the flushed position (as returned by getflushedPosition
).
It is legal to seek past the end of the file; an EOFException
will be thrown only
if a read is performed.
seek
in interface ImageInputStream
seek
in class SeekableInputStream
offset
- a long
containing the desired file pointer position.IOException
- if any other I/O error occurs.protected void sourceSeek(long offset) throws IOException
IOException
protected void resetBuffer()
protected long getSourceStreamPosition() throws IOException
IOException
protected SeekableInputStream getSource()
public void consume(int count) throws IOException
count
- count of lookahead characters to consumeIOException
public long getStreamPosition() throws IOException
IOException
protected int getInBufPos()
protected int getBufSize()
protected boolean fill() throws IOException
IOException
public long getSizeEstimate()
SeekableInputStream
getSizeEstimate
in class SeekableInputStream
Copyright © 2024 levigo holding gmbh. All rights reserved.