| java.lang.Object javax.imageio.stream.ImageInputStreamImpl
All known Subclasses: javax.imageio.stream.ImageOutputStreamImpl, javax.imageio.stream.FileCacheImageInputStream, javax.imageio.stream.MemoryCacheImageInputStream, javax.imageio.stream.FileImageInputStream,
ImageInputStreamImpl | abstract public class ImageInputStreamImpl implements ImageInputStream(Code) | | An abstract class implementing the ImageInputStream interface.
This class is designed to reduce the number of methods that must
be implemented by subclasses.
In particular, this class handles most or all of the details of
byte order interpretation, buffering, mark/reset, discarding,
closing, and disposing.
|
Field Summary | |
protected int | bitOffset The current bit offset within the stream. | byte[] | byteBuf Byte buffer used for readFully(type[], int, int). | protected ByteOrder | byteOrder The byte order of the stream as an instance of the enumeration
class java.nio.ByteOrder , where
ByteOrder.BIG_ENDIAN indicates network byte order
and ByteOrder.LITTLE_ENDIAN indicates the reverse
order. | protected long | flushedPos The position prior to which data may be discarded. | protected long | streamPos The current read position within the stream. |
Method Summary | |
final protected void | checkClosed() Throws an IOException if the stream has been closed. | public void | close() | protected void | finalize() Finalizes this object prior to garbage collection. | public void | flush() | public void | flushBefore(long pos) | public int | getBitOffset() | public ByteOrder | getByteOrder() | public long | getFlushedPosition() | public long | getStreamPosition() | public boolean | isCached() Default implementation returns false. | public boolean | isCachedFile() Default implementation returns false. | public boolean | isCachedMemory() Default implementation returns false. | public long | length() Returns -1L to indicate that the stream has unknown
length. | public void | mark() Pushes the current stream position onto a stack of marked
positions. | abstract public int | read() Reads a single byte from the stream and returns it as an
int between 0 and 255. | public int | read(byte[] b) A convenience method that calls read(b, 0, b.length) . | abstract public int | read(byte[] b, int off, int len) Reads up to len bytes from the stream, and stores
them into b starting at index off .
If no bytes can be read because the end of the stream has been
reached, -1 is returned.
The bit offset within the stream must be reset to zero before
the read occurs.
Subclasses must provide an implementation for this method.
The subclass implementation should update the stream position
before exiting. | public int | readBit() | public long | readBits(int numBits) | public boolean | readBoolean() | public byte | readByte() | public void | readBytes(IIOByteBuffer buf, int len) | public char | readChar() | public double | readDouble() | public float | readFloat() | public void | readFully(byte[] b, int off, int len) | public void | readFully(byte[] b) | public void | readFully(short[] s, int off, int len) | public void | readFully(char[] c, int off, int len) | public void | readFully(int[] i, int off, int len) | public void | readFully(long[] l, int off, int len) | public void | readFully(float[] f, int off, int len) | public void | readFully(double[] d, int off, int len) | public int | readInt() | public String | readLine() | public long | readLong() | public short | readShort() | public String | readUTF() | public int | readUnsignedByte() | public long | readUnsignedInt() | public int | readUnsignedShort() | public void | reset() Resets the current stream byte and bit positions from the stack
of marked positions. | public void | seek(long pos) | public void | setBitOffset(int bitOffset) | public void | setByteOrder(ByteOrder byteOrder) | public int | skipBytes(int n) Advances the current stream position by calling
seek(getStreamPosition() + n) .
The bit offset is reset to zero.
Parameters: n - the number of bytes to seek forward. | public long | skipBytes(long n) Advances the current stream position by calling
seek(getStreamPosition() + n) .
The bit offset is reset to zero.
Parameters: n - the number of bytes to seek forward. |
bitOffset | protected int bitOffset(Code) | | The current bit offset within the stream. Subclasses are
responsible for keeping this value current from any method they
override that alters the bit offset.
|
byteBuf | byte[] byteBuf(Code) | | Byte buffer used for readFully(type[], int, int). Note that this
array is also used for bulk reads in readShort(), readInt(), etc, so
it should be large enough to hold a primitive value (i.e. >= 8 bytes).
Also note that this array is package protected, so that it can be
used by ImageOutputStreamImpl in a similar manner.
|
byteOrder | protected ByteOrder byteOrder(Code) | | The byte order of the stream as an instance of the enumeration
class java.nio.ByteOrder , where
ByteOrder.BIG_ENDIAN indicates network byte order
and ByteOrder.LITTLE_ENDIAN indicates the reverse
order. By default, the value is
ByteOrder.BIG_ENDIAN .
|
flushedPos | protected long flushedPos(Code) | | The position prior to which data may be discarded. Seeking
to a smaller position is not allowed. flushedPos
will always be >= 0.
|
streamPos | protected long streamPos(Code) | | The current read position within the stream. Subclasses are
responsible for keeping this value current from any method they
override that alters the read position.
|
ImageInputStreamImpl | public ImageInputStreamImpl()(Code) | | Constructs an ImageInputStreamImpl .
|
checkClosed | final protected void checkClosed() throws IOException(Code) | | Throws an IOException if the stream has been closed.
Subclasses may call this method from any of their methods that
require the stream not to be closed.
exception: IOException - if the stream is closed. |
finalize | protected void finalize() throws Throwable(Code) | | Finalizes this object prior to garbage collection. The
close method is called to close any open input
source. This method should not be called from application
code.
exception: Throwable - if an error occurs during superclassfinalization. |
getFlushedPosition | public long getFlushedPosition()(Code) | | |
isCached | public boolean isCached()(Code) | | Default implementation returns false. Subclasses should
override this if they cache data.
|
isCachedFile | public boolean isCachedFile()(Code) | | Default implementation returns false. Subclasses should
override this if they cache data in a temporary file.
|
isCachedMemory | public boolean isCachedMemory()(Code) | | Default implementation returns false. Subclasses should
override this if they cache data in main memory.
|
length | public long length()(Code) | | Returns -1L to indicate that the stream has unknown
length. Subclasses must override this method to provide actual
length information.
-1L to indicate unknown length. |
mark | public void mark()(Code) | | Pushes the current stream position onto a stack of marked
positions.
|
read | abstract public int read() throws IOException(Code) | | Reads a single byte from the stream and returns it as an
int between 0 and 255. If EOF is reached,
-1 is returned.
Subclasses must provide an implementation for this method.
The subclass implementation should update the stream position
before exiting.
The bit offset within the stream must be reset to zero before
the read occurs.
the value of the next byte in the stream, or -1 if EOF is reached. exception: IOException - if the stream has been closed. |
read | public int read(byte[] b) throws IOException(Code) | | A convenience method that calls read(b, 0, b.length) .
The bit offset within the stream is reset to zero before
the read occurs.
the number of bytes actually read, or -1 to indicate EOF. exception: NullPointerException - if b isnull . exception: IOException - if an I/O error occurs. |
read | abstract public int read(byte[] b, int off, int len) throws IOException(Code) | | Reads up to len bytes from the stream, and stores
them into b starting at index off .
If no bytes can be read because the end of the stream has been
reached, -1 is returned.
The bit offset within the stream must be reset to zero before
the read occurs.
Subclasses must provide an implementation for this method.
The subclass implementation should update the stream position
before exiting.
Parameters: b - an array of bytes to be written to. Parameters: off - the starting position within b to write to. Parameters: len - the maximum number of bytes to read. the number of bytes actually read, or -1 to indicate EOF. exception: IndexOutOfBoundsException - if off isnegative, len is negative, or off +len is greater than b.length . exception: NullPointerException - if b isnull . exception: IOException - if an I/O error occurs. |
readFully | public void readFully(double[] d, int off, int len) throws IOException(Code) | | |
reset | public void reset() throws IOException(Code) | | Resets the current stream byte and bit positions from the stack
of marked positions.
An IOException will be thrown if the previous
marked position lies in the discarded portion of the stream.
exception: IOException - if an I/O error occurs. |
skipBytes | public int skipBytes(int n) throws IOException(Code) | | Advances the current stream position by calling
seek(getStreamPosition() + n) .
The bit offset is reset to zero.
Parameters: n - the number of bytes to seek forward. an int representing the number of bytesskipped. exception: IOException - if getStreamPosition throws an IOException when computing eitherthe starting or ending position. |
skipBytes | public long skipBytes(long n) throws IOException(Code) | | Advances the current stream position by calling
seek(getStreamPosition() + n) .
The bit offset is reset to zero.
Parameters: n - the number of bytes to seek forward. a long representing the number of bytesskipped. exception: IOException - if getStreamPosition throws an IOException when computing eitherthe starting or ending position. |
|
|