Package org.apache.pdfbox.jbig2.io
Class SubInputStream
- java.lang.Object
-
- javax.imageio.stream.ImageInputStreamImpl
-
- org.apache.pdfbox.jbig2.io.SubInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.DataInput,java.lang.AutoCloseable,javax.imageio.stream.ImageInputStream
public class SubInputStream extends javax.imageio.stream.ImageInputStreamImplA wrapper for anImageInputStreamwhich 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
Fields Modifier and Type Field Description private byte[]bufferA buffer which is used to improve read performance.(package private) longbufferBaseLocation of the first byte in the buffer with respect to the start of the stream.(package private) longbufferTopLocation of the last byte in the buffer with respect to the start of the stream.protected longlengthThe length of the window.protected longoffsetThe position in the wrapped stream at which the window starts.protected javax.imageio.stream.ImageInputStreamwrappedStream
-
Constructor Summary
Constructors Constructor Description SubInputStream(javax.imageio.stream.ImageInputStream iis, long offset, long length)Construct a new SubInputStream which provides a view of the wrapped stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleanfillBuffer()Fill the buffer at the current stream position.longlength()intread()intread(byte[] b, int off, int len)voidskipBits()Skips remaining bits in the current byte.-
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 Detail
-
wrappedStream
protected final javax.imageio.stream.ImageInputStream wrappedStream
-
offset
protected final long offset
The position in the wrapped stream at which the window starts. Offset is an absolut value.
-
length
protected final long length
The length of the window. Length is an relative value.
-
buffer
private final byte[] buffer
A buffer which is used to improve read performance.
-
bufferBase
long bufferBase
Location of the first byte in the buffer with respect to the start of the stream.
-
bufferTop
long bufferTop
Location of the last byte in the buffer with respect to the start of the stream.
-
-
Constructor Detail
-
SubInputStream
public SubInputStream(javax.imageio.stream.ImageInputStream iis, long offset, long length)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 Detail
-
read
public int read() throws java.io.IOException- Specified by:
readin interfacejavax.imageio.stream.ImageInputStream- Specified by:
readin classjavax.imageio.stream.ImageInputStreamImpl- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Specified by:
readin interfacejavax.imageio.stream.ImageInputStream- Specified by:
readin classjavax.imageio.stream.ImageInputStreamImpl- Throws:
java.io.IOException
-
fillBuffer
private boolean fillBuffer() throws java.io.IOExceptionFill the buffer at the current stream position.- Returns:
- Boolean flag.
trueif successful,falseif not. - Throws:
java.io.IOException
-
length
public long length()
- Specified by:
lengthin interfacejavax.imageio.stream.ImageInputStream- Overrides:
lengthin classjavax.imageio.stream.ImageInputStreamImpl
-
skipBits
public void skipBits()
Skips remaining bits in the current byte.
-
-