| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public abstract class ImageInputStreamImpl extends Object implements ImageInputStream
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 | |
---|---|
Constructs an ImageInputStreamImpl .
|
Method Summary | |
---|---|
protected void |
Throws an IOException if the stream has been closed.
|
void |
close() |
protected void |
finalize() Finalizes this object prior to garbage collection. |
void |
flush() |
void |
flushBefore(long pos) |
int |
|
ByteOrder |
|
long |
|
long |
|
boolean |
isCached() Default implementation returns false. |
boolean |
Default implementation returns false. |
boolean |
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 int between 0 and 255.
|
int |
read(byte[] b) A convenience method that calls read(b, 0, b.length) .
|
abstract 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 .
|
int |
readBit() |
long |
readBits(int numBits) |
boolean |
|
byte |
readByte() |
void |
readBytes(IIOByteBuffer buf, int len) |
char |
readChar() |
double |
|
float |
|
void |
readFully(byte[] b) |
void |
readFully(byte[] b, int off, int len) |
void |
readFully(char[] c, int off, int len) |
void |
readFully(double[] d, int off, int len) |
void |
readFully(float[] f, int off, int len) |
void |
readFully(int[] i, int off, int len) |
void |
readFully(long[] l, int off, int len) |
void |
readFully(short[] s, int off, int len) |
int |
readInt() |
String |
readLine() |
long |
readLong() |
short |
|
int |
|
long |
|
int |
|
String |
readUTF() |
void |
reset() Resets the current stream byte and bit positions from the stack of marked positions. |
void |
seek(long pos) |
void |
setBitOffset(int bitOffset) |
void |
setByteOrder(ByteOrder byteOrder) |
int |
skipBytes(int n) Advances the current stream position by calling seek(getStreamPosition() + n) .
|
long |
skipBytes(long n) Advances the current stream position by calling seek(getStreamPosition() + n) .
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int bitOffset
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 flushedPos
flushedPos
will always be >= 0.
protected long streamPos
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 close() throws IOException
IOException
protected void finalize() throws Throwable
close
method is called to close any open input
source. This method should not be called from application
code.
finalize
in class Object
Throwable
- if an error occurs during superclass
finalization.public void flush() throws IOException
IOException
public void flushBefore(long pos) throws IOException
pos
IOException
public int getBitOffset() throws IOException
IOException
public ByteOrder getByteOrder()
public long getFlushedPosition()
public long getStreamPosition() throws IOException
IOException
public boolean isCached()
public boolean isCachedFile()
public boolean isCachedMemory()
public long length()
-1L
to indicate that the stream has unknown
length. Subclasses must override this method to provide actual
length information.
public void mark()
public abstract int read() throws IOException
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.
-1
if EOF is reached.IOException
- if the stream has been closed.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.
b
-1
to indicate EOF.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.
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.IOException
- if an I/O error occurs.public int readBit() throws IOException
IOException
public long readBits(int numBits) throws IOException
numBits
IOException
public boolean readBoolean() throws IOException
IOException
public byte readByte() throws IOException
IOException
public void readBytes(IIOByteBuffer buf, int len) throws IOException
buf
len
IOException
public char readChar() throws IOException
IOException
public double readDouble() throws IOException
IOException
public float readFloat() throws IOException
IOException
public void readFully(byte[] b) throws IOException
b
IOException
public void readFully(byte[] b, int off, int len) throws IOException
b
off
len
IOException
public void readFully(char[] c, int off, int len) throws IOException
c
off
len
IOException
public void readFully(double[] d, int off, int len) throws IOException
d
off
len
IOException
public void readFully(float[] f, int off, int len) throws IOException
f
off
len
IOException
public void readFully(int[] i, int off, int len) throws IOException
i
off
len
IOException
public void readFully(long[] l, int off, int len) throws IOException
l
off
len
IOException
public void readFully(short[] s, int off, int len) throws IOException
s
off
len
IOException
public int readInt() throws IOException
IOException
public String readLine() throws IOException
IOException
public long readLong() throws IOException
IOException
public short readShort() throws IOException
IOException
public int readUnsignedByte() throws IOException
IOException
public long readUnsignedInt() throws IOException
IOException
public int readUnsignedShort() throws IOException
IOException
public String readUTF() throws IOException
IOException
public void reset() throws IOException
An IOException
will be thrown if the previous
marked position lies in the discarded portion of the stream.
IOException
- if an I/O error occurs.public void seek(long pos) throws IOException
pos
IOException
public void setBitOffset(int bitOffset) throws IOException
bitOffset
IOException
public void setByteOrder(ByteOrder byteOrder)
byteOrder
public int skipBytes(int n) throws IOException
seek(getStreamPosition() + n)
.
The bit offset is reset to zero.
n
- the number of bytes to seek forward.int
representing the number of bytes
skipped.IOException
- if getStreamPosition
throws an IOException
when computing either
the starting or ending position.public long skipBytes(long n) throws IOException
seek(getStreamPosition() + n)
.
The bit offset is reset to zero.
n
- the number of bytes to seek forward.long
representing the number of bytes
skipped.IOException
- if getStreamPosition
throws an IOException
when computing either
the starting or ending position.
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |