Class ForwardSeekableStream
java.lang.Object
java.io.InputStream
org.apache.xmlgraphics.image.codec.util.SeekableStream
org.apache.xmlgraphics.image.codec.util.ForwardSeekableStream
- All Implemented Interfaces:
Closeable
,DataInput
,AutoCloseable
A subclass of
SeekableStream
that may be used
to wrap a regular InputStream
efficiently.
Seeking backwards is not supported.-
Field Summary
Fields inherited from class org.apache.xmlgraphics.image.codec.util.SeekableStream
markPos
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs aInputStreamForwardSeekableStream
from a regularInputStream
. -
Method Summary
Modifier and TypeMethodDescriptionfinal int
Forwards the request to the realInputStream
.final boolean
Returnsfalse
since seking backwards is not supported.final void
close()
Forwards the request to the realInputStream
.final long
Returns the current position in the stream (bytes read).final void
mark
(int readLimit) Forwards the request to the realInputStream
.boolean
Forwards the request to the realInputStream
.final int
read()
Forwards the request to the realInputStream
.final int
read
(byte[] b, int off, int len) Forwards the request to the realInputStream
.final void
reset()
Forwards the request to the realInputStream
.final void
seek
(long pos) Seeks forward to the given position in the stream.final long
skip
(long n) Forwards the request to the realInputStream
.Methods inherited from class org.apache.xmlgraphics.image.codec.util.SeekableStream
finalize, readBoolean, readByte, readChar, readCharLE, readDouble, readDoubleLE, readFloat, readFloatLE, readFully, readFully, readInt, readIntLE, readLine, readLong, readLongLE, readShort, readShortLE, readUnsignedByte, readUnsignedInt, readUnsignedIntLE, readUnsignedShort, readUnsignedShortLE, readUTF, skipBytes, wrapInputStream
Methods inherited from class java.io.InputStream
nullInputStream, read, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
ForwardSeekableStream
Constructs aInputStreamForwardSeekableStream
from a regularInputStream
.
-
-
Method Details
-
read
Forwards the request to the realInputStream
.- Specified by:
read
in classSeekableStream
- Returns:
- the next byte of data, or
-1
if the end of the stream is reached. - Throws:
IOException
- if an I/O error occurs.
-
read
Forwards the request to the realInputStream
.- Specified by:
read
in classSeekableStream
- Parameters:
b
- the buffer into which the data is read.off
- the start offset in arrayb
at which the data is written.len
- the maximum number of bytes to read.- Returns:
- 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. - Throws:
IOException
- if an I/O error occurs.
-
skip
Forwards the request to the realInputStream
.- Overrides:
skip
in classInputStream
- Throws:
IOException
-
available
Forwards the request to the realInputStream
.- Overrides:
available
in classInputStream
- Throws:
IOException
-
close
Forwards the request to the realInputStream
.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
mark
public final void mark(int readLimit) Forwards the request to the realInputStream
. We useSeekableStream.markPos
- Overrides:
mark
in classSeekableStream
-
reset
Forwards the request to the realInputStream
. We useSeekableStream.markPos
- Overrides:
reset
in classSeekableStream
- Throws:
IOException
-
markSupported
public boolean markSupported()Forwards the request to the realInputStream
.- Overrides:
markSupported
in classSeekableStream
-
canSeekBackwards
public final boolean canSeekBackwards()Returnsfalse
since seking backwards is not supported.- Overrides:
canSeekBackwards
in classSeekableStream
-
getFilePointer
public final long getFilePointer()Returns the current position in the stream (bytes read).- Specified by:
getFilePointer
in classSeekableStream
- Returns:
- the offset from the beginning of the stream, in bytes, at which the next read occurs.
-
seek
Seeks forward to the given position in the stream. Ifpos
is smaller than the current position as returned bygetFilePointer()
, nothing happens.- Specified by:
seek
in classSeekableStream
- Parameters:
pos
- the offset position, measured in bytes from the beginning of the stream, at which to set the stream pointer.- Throws:
IOException
- ifpos
is less than0
or if an I/O error occurs.
-