Package org.apache.pdfbox.jbig2.io
Class SubInputStream
java.lang.Object
javax.imageio.stream.ImageInputStreamImpl
org.apache.pdfbox.jbig2.io.SubInputStream
- All Implemented Interfaces:
Closeable
,DataInput
,AutoCloseable
,ImageInputStream
A wrapper for an
ImageInputStream
which is able to provide a view of a specific part of the wrapped stream.
Read accesses to the wrapped stream are synchronized, so that users of this stream need to deal with synchronization
against other users of the same instance, but not against other users of the wrapped stream.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final byte[]
A buffer which is used to improve read performance.(package private) long
Location of the first byte in the buffer with respect to the start of the stream.(package private) long
Location of the last byte in the buffer with respect to the start of the stream.protected final long
The length of the window.protected final long
The position in the wrapped stream at which the window starts.protected final ImageInputStream
Fields inherited from class javax.imageio.stream.ImageInputStreamImpl
bitOffset, byteOrder, flushedPos, streamPos
-
Constructor Summary
ConstructorsConstructorDescriptionSubInputStream
(ImageInputStream iis, long offset, long length) Construct a new SubInputStream which provides a view of the wrapped stream. -
Method Summary
Methods inherited from class javax.imageio.stream.ImageInputStreamImpl
checkClosed, close, finalize, flush, flushBefore, getBitOffset, getByteOrder, getFlushedPosition, getStreamPosition, isCached, isCachedFile, isCachedMemory, mark, read, readBit, readBits, readBoolean, readByte, readBytes, readChar, readDouble, readFloat, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedInt, readUnsignedShort, readUTF, reset, seek, setBitOffset, setByteOrder, skipBytes, skipBytes
-
Field Details
-
wrappedStream
-
offset
protected final long offsetThe position in the wrapped stream at which the window starts. Offset is an absolut value. -
length
protected final long lengthThe length of the window. Length is an relative value. -
buffer
private final byte[] bufferA buffer which is used to improve read performance. -
bufferBase
long bufferBaseLocation of the first byte in the buffer with respect to the start of the stream. -
bufferTop
long bufferTopLocation of the last byte in the buffer with respect to the start of the stream.
-
-
Constructor Details
-
SubInputStream
Construct a new SubInputStream which provides a view of the wrapped stream.- Parameters:
iis
- - The stream to be wrapped.offset
- - The absolute position in the wrapped stream at which the sub-stream starts.length
- - The length of the sub-stream.
-
-
Method Details
-
read
- Specified by:
read
in interfaceImageInputStream
- Specified by:
read
in classImageInputStreamImpl
- Throws:
IOException
-
read
- Specified by:
read
in interfaceImageInputStream
- Specified by:
read
in classImageInputStreamImpl
- Throws:
IOException
-
fillBuffer
Fill the buffer at the current stream position.- Returns:
- Boolean flag.
true
if successful,false
if not. - Throws:
IOException
-
length
public long length()- Specified by:
length
in interfaceImageInputStream
- Overrides:
length
in classImageInputStreamImpl
-
skipBits
public void skipBits()Skips remaining bits in the current byte.
-