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) longLocation of the first byte in the buffer with respect to the start of the stream.(package private) longLocation of the last byte in the buffer with respect to the start of the stream.protected final longThe length of the window.protected final longThe position in the wrapped stream at which the window starts.protected final ImageInputStreamFields inherited from class 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 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:
readin interfaceImageInputStream- Specified by:
readin classImageInputStreamImpl- Throws:
IOException
-
read
- Specified by:
readin interfaceImageInputStream- Specified by:
readin classImageInputStreamImpl- Throws:
IOException
-
fillBuffer
Fill the buffer at the current stream position.- Returns:
- Boolean flag.
trueif successful,falseif not. - Throws:
IOException
-
length
public long length()- Specified by:
lengthin interfaceImageInputStream- Overrides:
lengthin classImageInputStreamImpl
-
skipBits
public void skipBits()Skips remaining bits in the current byte.
-