Class ForwardSeekableStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.batik.ext.awt.image.codec.util.SeekableStream
-
- org.apache.batik.ext.awt.image.codec.util.ForwardSeekableStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.DataInput
,java.lang.AutoCloseable
public class ForwardSeekableStream extends SeekableStream
A subclass ofSeekableStream
that may be used to wrap a regularInputStream
efficiently. Seeking backwards is not supported.- Version:
- $Id: ForwardSeekableStream.java 1733416 2016-03-03 07:07:13Z gadams $
-
-
Field Summary
Fields Modifier and Type Field Description (package private) long
pointer
The current position.private java.io.InputStream
src
The sourceInputStream
.-
Fields inherited from class org.apache.batik.ext.awt.image.codec.util.SeekableStream
markPos
-
-
Constructor Summary
Constructors Constructor Description ForwardSeekableStream(java.io.InputStream src)
Constructs aInputStreamForwardSeekableStream
from a regularInputStream
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
Forwards the request to the realInputStream
.boolean
canSeekBackwards()
Returnsfalse
since seking backwards is not supported.void
close()
Forwards the request to the realInputStream
.long
getFilePointer()
Returns the current position in the stream (bytes read).void
mark(int readLimit)
Forwards the request to the realInputStream
.boolean
markSupported()
Forwards the request to the realInputStream
.int
read()
Forwards the request to the realInputStream
.int
read(byte[] b, int off, int len)
Forwards the request to the realInputStream
.void
reset()
Forwards the request to the realInputStream
.void
seek(long pos)
Seeks forward to the given position in the stream.long
skip(long n)
Forwards the request to the realInputStream
.-
Methods inherited from class org.apache.batik.ext.awt.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
-
-
-
-
Method Detail
-
read
public final int read() throws java.io.IOException
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:
java.io.IOException
- if an I/O error occurs.
-
read
public final int read(byte[] b, int off, int len) throws java.io.IOException
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:
java.io.IOException
- if an I/O error occurs.
-
skip
public final long skip(long n) throws java.io.IOException
Forwards the request to the realInputStream
.- Overrides:
skip
in classjava.io.InputStream
- Throws:
java.io.IOException
-
available
public final int available() throws java.io.IOException
Forwards the request to the realInputStream
.- Overrides:
available
in classjava.io.InputStream
- Throws:
java.io.IOException
-
close
public final void close() throws java.io.IOException
Forwards the request to the realInputStream
.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
- Throws:
java.io.IOException
-
mark
public final void mark(int readLimit)
Forwards the request to the realInputStream
. We useSeekableStream.markPos
- Overrides:
mark
in classSeekableStream
-
reset
public final void reset() throws java.io.IOException
Forwards the request to the realInputStream
. We useSeekableStream.markPos
- Overrides:
reset
in classSeekableStream
- Throws:
java.io.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
public final void seek(long pos) throws java.io.IOException
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:
java.io.IOException
- ifpos
is less than0
or if an I/O error occurs.
-
-