|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.imageio.stream.ImageInputStreamImpl
public abstract class ImageInputStreamImpl
Field Summary | |
---|---|
protected int |
bitOffset
|
protected ByteOrder |
byteOrder
|
protected long |
flushedPos
|
protected long |
streamPos
|
Constructor Summary | |
---|---|
ImageInputStreamImpl()
|
Method Summary | |
---|---|
protected void |
checkClosed()
|
void |
close()
|
protected void |
finalize()
Called on an object by the Virtual Machine at most once, at some point after the Object is determined unreachable but before it is destroyed. |
void |
flush()
|
void |
flushBefore(long position)
|
int |
getBitOffset()
|
ByteOrder |
getByteOrder()
|
long |
getFlushedPosition()
|
long |
getStreamPosition()
|
boolean |
isCached()
|
boolean |
isCachedFile()
|
boolean |
isCachedMemory()
|
long |
length()
|
void |
mark()
|
abstract int |
read()
|
int |
read(byte[] data)
|
abstract int |
read(byte[] data,
int offset,
int len)
|
int |
readBit()
|
long |
readBits(int numBits)
|
boolean |
readBoolean()
Reads a byte and checks whether or not its value is zero. |
byte |
readByte()
Reads a signed byte. |
void |
readBytes(IIOByteBuffer buffer,
int len)
Reads up to a specified number of bytes, and modifies a IIOByteBuffer to hold the read data. |
char |
readChar()
Reads an unsigned 16-bit integer. |
double |
readDouble()
Reads an IEEE 64-bit double-precision floating point number. |
float |
readFloat()
Reads an IEEE 32-bit single-precision floating point number. |
void |
readFully(byte[] data)
Reads a sequence of signed 8-bit integers into a byte[] array. |
void |
readFully(byte[] data,
int offset,
int len)
Reads a sequence of signed 8-bit integers into a byte[] array. |
void |
readFully(char[] data,
int offset,
int len)
Reads a sequence of unsigned 16-bit integers into a char[] array. |
void |
readFully(double[] data,
int offset,
int len)
Reads a sequence of IEEE 64-bit double-precision floating point numbers into a double[] array. |
void |
readFully(float[] data,
int offset,
int len)
Reads a sequence of IEEE 32-bit single-precision floating point numbers into a float[] array. |
void |
readFully(int[] data,
int offset,
int len)
Reads a sequence of signed 32-bit integers into a long[] array. |
void |
readFully(long[] data,
int offset,
int len)
Reads a sequence of signed 64-bit integers into a long[] array. |
void |
readFully(short[] data,
int offset,
int len)
Reads a sequence of signed 16-bit integers into a short[] array. |
int |
readInt()
Reads a signed 32-bit integer. |
String |
readLine()
This method reads the next line of text data from an input stream. |
long |
readLong()
Reads a signed 64-bit integer. |
short |
readShort()
Reads an signed 16-bit integer. |
int |
readUnsignedByte()
Reads an unsigned byte. |
long |
readUnsignedInt()
Reads an unsigned 32-bit integer. |
int |
readUnsignedShort()
Reads an unsigned 16-bit integer. |
String |
readUTF()
This method reads a String from an input stream that is
encoded in a modified UTF-8 format. |
void |
reset()
|
void |
seek(long position)
|
void |
setBitOffset(int bitOffset)
|
void |
setByteOrder(ByteOrder byteOrder)
|
int |
skipBytes(int num)
This method skips and discards the specified number of bytes in an input stream. |
long |
skipBytes(long num)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int bitOffset
protected ByteOrder byteOrder
protected long flushedPos
protected long streamPos
Constructor Detail |
---|
public ImageInputStreamImpl()
Method Detail |
---|
protected final void checkClosed() throws IOException
IOException
public void close() throws IOException
close
in interface ImageInputStream
IOException
protected void finalize() throws Throwable
Object
java.lang.ref
package.
Virtual Machines are free to not call this method if
they can determine that it does nothing important; for
example, if your class extends Object and overrides
finalize to do simply super.finalize()
.
finalize() will be called by a Thread
that has no
locks on any Objects, and may be called concurrently.
There are no guarantees on the order in which multiple
objects are finalized. This means that finalize() is
usually unsuited for performing actions that must be
thread-safe, and that your implementation must be
use defensive programming if it is to always work.
If an Exception is thrown from finalize() during garbage collection, it will be patently ignored and the Object will still be destroyed.
It is allowed, although not typical, for user code to call finalize() directly. User invocation does not affect whether automatic invocation will occur. It is also permitted, although not recommended, for a finalize() method to "revive" an object by making it reachable from normal code again.
Unlike constructors, finalize() does not get called
for an object's superclass unless the implementation
specifically calls super.finalize()
.
The default implementation does nothing.
finalize
in class Object
Throwable
- permits a subclass to throw anything in an
overridden version; but the default throws nothingSystem.gc()
,
System.runFinalizersOnExit(boolean)
,
java.lang.ref
public void flush() throws IOException
flush
in interface ImageInputStream
IOException
public void flushBefore(long position) throws IOException
flushBefore
in interface ImageInputStream
IOException
public int getBitOffset() throws IOException
getBitOffset
in interface ImageInputStream
IOException
public ByteOrder getByteOrder()
getByteOrder
in interface ImageInputStream
public long getFlushedPosition()
getFlushedPosition
in interface ImageInputStream
public long getStreamPosition() throws IOException
getStreamPosition
in interface ImageInputStream
IOException
public boolean isCached()
isCached
in interface ImageInputStream
public boolean isCachedFile()
isCachedFile
in interface ImageInputStream
public boolean isCachedMemory()
isCachedMemory
in interface ImageInputStream
public long length()
length
in interface ImageInputStream
public void mark()
mark
in interface ImageInputStream
public abstract int read() throws IOException
read
in interface ImageInputStream
IOException
public abstract int read(byte[] data, int offset, int len) throws IOException
read
in interface ImageInputStream
IOException
public int read(byte[] data) throws IOException
read
in interface ImageInputStream
IOException
public int readBit() throws IOException
readBit
in interface ImageInputStream
IOException
public long readBits(int numBits) throws IOException
readBits
in interface ImageInputStream
IOException
public boolean readBoolean() throws IOException
ImageInputStream
The bit offset is set to zero before the byte is read.
readBoolean
in interface DataInput
readBoolean
in interface ImageInputStream
boolean
value read
EOFException
- if the input stream is at its end.
IOException
- if some general problem happens with
accessing data.ImageInputStream.readBit()
,
ImageInputStream.readByte()
,
ImageInputStream.readFully(byte[], int, int)
public byte readByte() throws IOException
ImageInputStream
The bit offset is set to zero before any data is read.
readByte
in interface DataInput
readByte
in interface ImageInputStream
byte
value read
EOFException
- if the input stream is at its end.
IOException
- if some general problem happens with
accessing data.ImageInputStream.readUnsignedByte()
,
ImageInputStream.readFully(byte[], int, int)
public void readBytes(IIOByteBuffer buffer, int len) throws IOException
ImageInputStream
IIOByteBuffer
to hold the read data.
The bit offset is set to zero before any data is read.
readBytes
in interface ImageInputStream
buffer
- an IIOByteBuffer
that will hold the read
data.len
- the maximum number of bytes to read.
IOException
- if some general problem happens with
accessing data.public char readChar() throws IOException
ImageInputStream
The bit offset is set to zero before any data is read.
This method does the same as ImageInputStream.readUnsignedShort()
.
readChar
in interface DataInput
readChar
in interface ImageInputStream
char
value read
EOFException
- if the input stream ends before all two
bytes were read.
IOException
- if some general problem happens with
accessing data.ImageInputStream.readFully(char[], int, int)
public double readDouble() throws IOException
ImageInputStream
The bit offset is set to zero before any data is read.
readDouble
in interface DataInput
readDouble
in interface ImageInputStream
double
value read
EOFException
- if the input stream ends before all eight
bytes were read.
IOException
- if some general problem happens with
accessing data.ImageInputStream.readFully(double[], int, int)
public float readFloat() throws IOException
ImageInputStream
The bit offset is set to zero before any data is read.
readFloat
in interface DataInput
readFloat
in interface ImageInputStream
float
value read
EOFException
- if the input stream ends before all four
bytes were read.
IOException
- if some general problem happens with
accessing data.ImageInputStream.readFully(float[], int, int)
public void readFully(byte[] data) throws IOException
ImageInputStream
byte[]
array.
The bit offset is set to zero before any data is read.
readFully
in interface DataInput
readFully
in interface ImageInputStream
data
- an array for storing the read values.
EOFException
- if the input stream ends before all content
was read.
IOException
- if some general problem happens with
accessing data.ImageInputStream.readByte()
,
ImageInputStream.readFully(byte[], int, int)
public void readFully(byte[] data, int offset, int len) throws IOException
ImageInputStream
byte[]
array.
The bit offset is set to zero before any data is read.
readFully
in interface DataInput
readFully
in interface ImageInputStream
data
- an array for storing the read values.offset
- the index of the first element in b
that will hold read data.len
- the number of bytes to read.
EOFException
- if the input stream ends before all content
was read.
IOException
- if some general problem happens with
accessing data.ImageInputStream.readByte()
public void readFully(char[] data, int offset, int len) throws IOException
ImageInputStream
char[]
array. If necessary, values are converted
from the stream’s current byte
order.
The bit offset is set to zero before any data is read.
readFully
in interface ImageInputStream
data
- an array for storing the read values.offset
- the index of the first element in c
that will hold read data.len
- the number of unsigned 16-bit integers to read
(which is one half of the number of bytes).
EOFException
- if the input stream ends before all content
was read.
IOException
- if some general problem happens with
accessing data.ImageInputStream.readChar()
public void readFully(double[] data, int offset, int len) throws IOException
ImageInputStream
double[]
array. If necessary, values
are converted from the stream’s current byte order.
The bit offset is set to zero before any data is read.
readFully
in interface ImageInputStream
data
- an array for storing the read values.offset
- the index of the first element in d
that will hold read data.len
- the number of IEEE 64-bit double-precision
floating point numbers to read (which is one eight of the number
of bytes).
EOFException
- if the input stream ends before all content
was read.
IOException
- if some general problem happens with
accessing data.ImageInputStream.readDouble()
public void readFully(float[] data, int offset, int len) throws IOException
ImageInputStream
float[]
array. If necessary, values
are converted from the stream’s current byte order.
The bit offset is set to zero before any data is read.
readFully
in interface ImageInputStream
offset
- the index of the first element in d
that will hold read data.len
- the number of IEEE 32-bit single-precision
floating point numbers to read (which is one fourth of the number
of bytes).
EOFException
- if the input stream ends before all content
was read.
IOException
- if some general problem happens with
accessing data.ImageInputStream.readFloat()
public void readFully(int[] data, int offset, int len) throws IOException
ImageInputStream
long[]
array. If necessary, values are converted
from the stream’s current byte
order.
The bit offset is set to zero before any data is read.
readFully
in interface ImageInputStream
data
- an array for storing the read values.offset
- the index of the first element in i
that will hold read data.
EOFException
- if the input stream ends before all content
was read.
IOException
- if some general problem happens with
accessing data.ImageInputStream.readInt()
public void readFully(long[] data, int offset, int len) throws IOException
ImageInputStream
long[]
array. If necessary, values are converted
from the stream’s current byte
order.
The bit offset is set to zero before any data is read.
readFully
in interface ImageInputStream
data
- an array for storing the read values.offset
- the index of the first element in l
that will hold read data.len
- the number of signed 64-bit integers to read
(which is one eight of the number of bytes).
EOFException
- if the input stream ends before all content
was read.
IOException
- if some general problem happens with
accessing data.ImageInputStream.readLong()
public void readFully(short[] data, int offset, int len) throws IOException
ImageInputStream
short[]
array. If necessary, values are converted
from the stream’s current byte
order.
The bit offset is set to zero before any data is read.
readFully
in interface ImageInputStream
data
- an array for storing the read values.offset
- the index of the first element in s
that will hold read data.len
- the number of signed 16-bit integers to read
(which is one half of the number of bytes).
EOFException
- if the input stream ends before all content
was read.
IOException
- if some general problem happens with
accessing data.ImageInputStream.readShort()
public int readInt() throws IOException
ImageInputStream
The bit offset is set to zero before any data is read.
readInt
in interface DataInput
readInt
in interface ImageInputStream
int
value read
EOFException
- if the input stream ends before all four
bytes were read.
IOException
- if some general problem happens with
accessing data.ImageInputStream.readUnsignedInt()
,
ImageInputStream.readFully(int[], int, int)
public String readLine() throws IOException
DataInput
char
values by treating the byte read as the low eight bits of the
char
and using 0 as the high eight bits. Because of this,
it does not support the full 16-bit Unicode character set.
The reading of bytes ends when either the end of file or a line terminator
is encountered. The bytes read are then returned as a
String
.
A line terminator is a byte sequence consisting of either
\r
, \n
or \r\n
. These termination
charaters are discarded and are not returned as part of the string.
A line is also terminated by an end of file condition.
readLine
in interface DataInput
readLine
in interface ImageInputStream
String
IOException
- If an error occurspublic long readLong() throws IOException
ImageInputStream
The bit offset is set to zero before any data is read.
readLong
in interface DataInput
readLong
in interface ImageInputStream
long
value read
EOFException
- if the input stream ends before all eight
bytes were read.
IOException
- if some general problem happens with
accessing data.ImageInputStream.readFully(long[], int, int)
public short readShort() throws IOException
ImageInputStream
The bit offset is set to zero before any data is read.
readShort
in interface DataInput
readShort
in interface ImageInputStream
short
value read
EOFException
- if the input stream ends before all two
bytes were read.
IOException
- if some general problem happens with
accessing data.ImageInputStream.readUnsignedShort()
,
ImageInputStream.readChar()
,
ImageInputStream.readFully(short[], int, int)
public int readUnsignedByte() throws IOException
ImageInputStream
The bit offset is set to zero before any data is read.
readUnsignedByte
in interface DataInput
readUnsignedByte
in interface ImageInputStream
int
.
EOFException
- if the input stream is at its end.
IOException
- if some general problem happens with
accessing data.ImageInputStream.readByte()
,
ImageInputStream.readFully(byte[], int, int)
public long readUnsignedInt() throws IOException
ImageInputStream
The bit offset is set to zero before any data is read.
readUnsignedInt
in interface ImageInputStream
EOFException
- if the input stream ends before all four
bytes were read.
IOException
- if some general problem happens with
accessing data.ImageInputStream.readInt()
,
ImageInputStream.readFully(int[], int, int)
public int readUnsignedShort() throws IOException
ImageInputStream
The bit offset is set to zero before any data is read.
This method does the same as ImageInputStream.readChar()
.
readUnsignedShort
in interface DataInput
readUnsignedShort
in interface ImageInputStream
int
.
EOFException
- if the input stream ends before all two
bytes were read.
IOException
- if some general problem happens with
accessing data.ImageInputStream.readShort()
,
ImageInputStream.readChar()
,
ImageInputStream.readFully(char[], int, int)
public String readUTF() throws IOException
DataInput
String
from an input stream that is
encoded in a modified UTF-8 format. This format has a leading two byte
sequence that contains the remaining number of bytes to read.
This two byte
sequence is read using the readUnsignedShort()
method of this
interface.
After the number of remaining bytes have been determined, these bytes
are read an transformed into char
values. These
char
values are encoded in the stream using either a one,
two, or three byte format.
The particular format in use can be determined by examining the first
byte read.
If the first byte has a high order bit of 0, then
that character consists on only one byte. This character value consists
of seven bits that are at positions 0 through 6 of the byte. As an
example, if byte1
is the byte read from the stream, it would
be converted to a char
like so:
(char)byte1
If the first byte has 110 as its high order bits, then the character consists of two bytes. The bits that make up the character value are in positions 0 through 4 of the first byte and bit positions 0 through 5 of the second byte. (The second byte should have 10 as its high order bits). These values are in most significant byte first (i.e., "big endian") order.
As an example, if byte1
and byte2
are the first
two bytes read respectively, and the high order bits of them match the
patterns which indicate a two byte character encoding, then they would be
converted to a Java char
like so:
(char)(((byte1 & 0x1F) << 6) + (byte2 & 0x3F))
If the first byte has a 1110 as its high order bits, then the character consists of three bytes. The bits that make up the character value are in positions 0 through 3 of the first byte and bit positions 0 through 5 of the other two bytes. (The second and third bytes should have 10 as their high order bits). These values are in most significant byte first (i.e., "big endian") order.
As an example, if byte1
, byte2
, and
byte3
are the three bytes read, and the high order bits of
them match the patterns which indicate a three byte character encoding,
then they would be converted to a Java char
like so:
(char)(((byte1 & 0x0F) << 12) + ((byte2 & 0x3F) + (byte3 & 0x3F))
Note that all characters are encoded in the method that requires the
fewest number of bytes with the exception of the character with the
value of \<llll>u0000
which is encoded as two bytes.
This is a modification of the UTF standard used to prevent C language
style NUL
values from appearing in the byte stream.
This method can read data that was written by an object implementing the
writeUTF()
method in DataOutput
.
readUTF
in interface DataInput
readUTF
in interface ImageInputStream
String
read
EOFException
- If end of file is reached before reading the
String
UTFDataFormatException
- If the data is not in UTF-8 format
IOException
- If any other error occursDataOutput.writeUTF(java.lang.String)
public void reset() throws IOException
reset
in interface ImageInputStream
IOException
public void seek(long position) throws IOException
seek
in interface ImageInputStream
IOException
public void setBitOffset(int bitOffset) throws IOException
setBitOffset
in interface ImageInputStream
IOException
public void setByteOrder(ByteOrder byteOrder)
setByteOrder
in interface ImageInputStream
public int skipBytes(int num) throws IOException
DataInput
skipBytes
in interface DataInput
skipBytes
in interface ImageInputStream
num
- The number of bytes to skip
numBytes
EOFException
- If end of file is reached before all bytes can be
skipped
IOException
- If any other error occurspublic long skipBytes(long num) throws IOException
skipBytes
in interface ImageInputStream
IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |