|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object![]()
![]()
![]()
javax.imageio.stream.ImageInputStreamImpl
, ImageInputStream

, FileImageInputStream
, ImageOutputStreamImpl
, MemoryCacheImageInputStream

public abstract class ImageInputStreamImpl


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. |
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. |
| Constructor Summary | |
|---|---|
ImageInputStreamImpl
Constructs an ImageInputStreamImpl. |
|
| Method Summary | |
|---|---|
protected void |
checkClosed
Throws an IOException if the stream has been closed. |
void |
close
Closes the stream. |
protected void |
finalize
Finalizes this object prior to garbage collection. |
void |
flush
Discards the initial position of the stream prior to the current stream position. |
void |
flushBefore
Discards the initial portion of the stream prior to the indicated postion. |
int |
getBitOffset
Returns the current bit offset, as an integer between 0 and 7, inclusive. |
ByteOrder |
getByteOrder
Returns the byte order with which data values will be read from this stream as an instance of the java.nio.ByteOrder enumeration. |
long |
getFlushedPosition
Returns the earliest position in the stream to which seeking may be performed. |
long |
getStreamPosition
Returns the current byte position of the stream. |
boolean |
isCached
Default implementation returns false. |
boolean |
isCachedFile
Default implementation returns false. |
boolean |
isCachedMemory
Default implementation returns false. |
long |
length
Returns -1L to indicate that the stream has unknown
length. |
void |
mark
Pushes the current stream position onto a stack of marked positions. |
abstract int |
read
Reads a single byte from the stream and returns it as an integer between 0 and 255. |
int |
read
A convenience method that calls read(b, 0, b.length). |
abstract int |
read
Reads up to len bytes from the stream, and stores
them into b starting at index off. |
int |
readBit
Reads a single bit from the stream and returns it as an int with the value 0 or
1. |
long |
readBits
Reads a bitstring from the stream and returns it as a long, with the first bit read becoming the most
significant bit of the output. |
boolean |
readBoolean
Reads one input byte and returns true if that byte is nonzero,
false if that byte is zero. |
byte |
readByte
Reads and returns one input byte. |
void |
readBytes
Reads up to len bytes from the stream, and
modifies the supplied IIOByteBuffer to indicate
the byte array, offset, and length where the data may be found. |
char |
readChar
Reads an input char and returns the char value. |
double |
readDouble
Reads eight input bytes and returns a double value. |
float |
readFloat
Reads four input bytes and returns a float value. |
void |
readFully
Reads some bytes from an input stream and stores them into the buffer array b. |
void |
readFully
Reads len
bytes from
an input stream. |
void |
readFully
Reads len chars (unsigned 16-bit integers) from the
stream according to the current byte order, and
stores them into c starting at index
off. |
void |
readFully
Reads len doubles (64-bit IEEE double-precision
floats) from the stream according to the current byte order,
and stores them into d starting at
index off. |
void |
readFully
Reads len floats (32-bit IEEE single-precision
floats) from the stream according to the current byte order,
and stores them into f starting at
index off. |
void |
readFully
Reads len ints (signed 32-bit integers) from the
stream according to the current byte order, and
stores them into i starting at index
off. |
void |
readFully
Reads len longs (signed 64-bit integers) from the
stream according to the current byte order, and
stores them into l starting at index
off. |
void |
readFully
Reads len shorts (signed 16-bit integers) from the
stream according to the current byte order, and
stores them into s starting at index
off. |
int |
readInt
Reads four input bytes and returns an int value. |
String |
readLine
Reads the next line of text from the input stream. |
long |
readLong
Reads eight input bytes and returns a long value. |
short |
readShort
Reads two input bytes and returns a short value. |
int |
readUnsignedByte
Reads one input byte, zero-extends it to type int, and returns
the result, which is therefore in the range
0
through 255. |
long |
readUnsignedInt
Reads 4 bytes from the stream, and (conceptually) concatenates them according to the current byte order, converts the result to a long, masks it with 0xffffffffL in order to
strip off any sign-extension bits, and returns the result as an
unsigned long value. |
int |
readUnsignedShort
Reads two input bytes and returns an int value in the range 0
through 65535. |
String |
readUTF
Reads in a string that has been encoded using a modified UTF-8 format. |
void |
reset
Resets the current stream byte and bit positions from the stack of marked positions. |
void |
seek
Sets the current stream position to the desired location. |
void |
setBitOffset
Sets the bit offset to an integer between 0 and 7, inclusive. |
void |
setByteOrder
Sets the desired byte order for future reads of data values from this stream. |
int |
skipBytes
Advances the current stream position by calling seek(getStreamPosition() + n). |
long |
skipBytes
Advances the current stream position by calling seek(getStreamPosition() + n). |
Methods inherited from class java.lang.Object ![]() |
|---|
clone |
| Field Detail |
|---|

protected ByteOrder![]()
![]()
byteOrder
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.

protected long streamPos

protected int bitOffset

protected long flushedPos
flushedPos
will always be >= 0.
| Constructor Detail |
|---|

public ImageInputStreamImpl()
ImageInputStreamImpl.
| Method Detail |
|---|

protected final void checkClosed()
throws IOException

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.
IOException

- if the stream is closed.

public void setByteOrder(ByteOrder![]()
![]()
byteOrder)
ImageInputStream

The enumeration class java.nio.ByteOrder is
used to specify the byte order. A value of
ByteOrder.BIG_ENDIAN specifies so-called
big-endian or network byte order, in which the high-order byte
comes first. Motorola and Sparc processors store data in this
format, while Intel processors store data in the reverse
ByteOrder.LITTLE_ENDIAN order.
The byte order has no effect on the results returned from
the readBits method (or the value written by
ImageOutputStream.writeBits).
setByteOrder

in interface ImageInputStream

byteOrder - one of ByteOrder.BIG_ENDIAN or
java.nio.ByteOrder.LITTLE_ENDIAN, indicating whether
network byte order or its reverse will be used for future
reads.ByteOrder
,
ImageInputStream.getByteOrder()
,
ImageInputStream.readBits(int)


public ByteOrder![]()
![]()
getByteOrder()
ImageInputStream

java.nio.ByteOrder enumeration.
getByteOrder

in interface ImageInputStream

ByteOrder.BIG_ENDIAN or
ByteOrder.LITTLE_ENDIAN, indicating which byte
order is being used.ByteOrder
,
ImageInputStream.setByteOrder(java.nio.ByteOrder)


public abstract int read()
throws IOException

ImageInputStream

The bit offset within the stream is reset to zero before the read occurs.
read

in interface ImageInputStream

IOException

- if an I/O error occurs.

public int read(byte[] b)
throws IOException

read(b, 0, b.length).
The bit offset within the stream is reset to zero before the read occurs.
read

in interface ImageInputStream

b - an array of bytes to be written to.
-1
to indicate EOF.
NullPointerException

- if b is
null.
IOException

- if an I/O error occurs.

public abstract int read(byte[] b,
int off,
int len)
throws IOException

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.
read

in interface ImageInputStream

b - an array of bytes to be written to.off - the starting position within b to write to.len - the maximum number of bytes to read.
-1
to indicate EOF.
IndexOutOfBoundsException

- if off is
negative, len is negative, or off +
len is greater than b.length.
NullPointerException

- if b is
null.
IOException

- if an I/O error occurs.

public void readBytes(IIOByteBuffer![]()
![]()
buf, int len) throws IOException
![]()
![]()
ImageInputStream

len bytes from the stream, and
modifies the supplied IIOByteBuffer to indicate
the byte array, offset, and length where the data may be found.
The caller should not attempt to modify the data found in the
IIOByteBuffer.
The bit offset within the stream is reset to zero before the read occurs.
readBytes

in interface ImageInputStream

buf - an IIOByteBuffer object to be modified.len - the maximum number of bytes to read.
IOException

- if an I/O error occurs.

public boolean readBoolean()
throws IOException

DataInput

true if that byte is nonzero,
false if that byte is zero.
This method is suitable for reading
the byte written by the writeBoolean
method of interface DataOutput.
readBoolean

in interface DataInput

readBoolean

in interface ImageInputStream

boolean value read.
EOFException