/* ImageInputStream.java Copyright (C) 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ package javax.imageio.stream; import java.io.DataInput; import java.io.EOFException; import java.io.IOException; import java.nio.ByteOrder; /** * An input stream for use by {@link javax.imageio.ImageReader * ImageReaders}. * * @since 1.4 * * @author Sascha Brawer (brawer@dandelis.ch) */ public interface ImageInputStream extends DataInput { void setByteOrder(ByteOrder order); ByteOrder getByteOrder(); int read() throws IOException; int read(byte[] b) throws IOException; int read(byte[] b, int offset, int length) throws IOException; /** * Reads up to a specified number of bytes, and modifies a * {@link IIOByteBuffer} to hold the read data. * *
The {@linkplain #getBitOffset() bit offset} is set to zero
* before any data is read.
*
* @param buf an IIOByteBuffer
that will hold the read
* data.
*
* @param numBytes the maximum number of bytes to read.
*
* @throws IndexOutOfBoundsException if numBytes
is
* negative.
*
* @throws NullPointerException if buf
is
* null
.
*
* @throws IOException if some general problem happens with
* accessing data.
*/
void readBytes(IIOByteBuffer buf, int numBytes)
throws IOException;
/**
* Reads a byte and checks whether or not its value is zero.
*
*
The {@linkplain #getBitOffset() bit offset} is set to zero * before the byte is read. * * @throws EOFException if the input stream is at its end. * * @throws IOException if some general problem happens with * accessing data. * * @see #readBit() * @see #readByte() * @see #readFully(byte[], int, int) */ boolean readBoolean() throws IOException; /** * Reads a signed byte. * *
The {@linkplain #getBitOffset() bit offset} is set to zero * before any data is read. * * @throws EOFException if the input stream is at its end. * * @throws IOException if some general problem happens with * accessing data. * * @see #readUnsignedByte() * @see #readFully(byte[], int, int) */ byte readByte() throws IOException; /** * Reads an unsigned byte. * *
The {@linkplain #getBitOffset() bit offset} is set to zero * before any data is read. * * @throws EOFException if the input stream is at its end. * * @throws IOException if some general problem happens with * accessing data. * * @see #readByte() * @see #readFully(byte[], int, int) */ int readUnsignedByte() throws IOException; /** * Reads an signed 16-bit integer. If necessary, the value gets * converted from the stream’s {@linkplain #getByteOrder() * current byte order}. * *
The {@linkplain #getBitOffset() bit offset} is set to zero * before any data is read. * * @throws EOFException if the input stream ends before all two * bytes were read. * * @throws IOException if some general problem happens with * accessing data. * * @see #readUnsignedShort() * @see #readChar() * @see #readFully(short[], int, int) */ short readShort() throws IOException; /** * Reads an unsigned 16-bit integer. If necessary, the value gets * converted from the stream’s {@linkplain #getByteOrder() * current byte order}. * *
The {@linkplain #getBitOffset() bit offset} is set to zero * before any data is read. * *
This method does the same as {@link #readChar()}. * * @throws EOFException if the input stream ends before all two * bytes were read. * * @throws IOException if some general problem happens with * accessing data. * * @see #readShort() * @see #readChar() * @see #readFully(char[], int, int) */ int readUnsignedShort() throws IOException; /** * Reads an unsigned 16-bit integer. If necessary, the value gets * converted from the stream’s {@linkplain #getByteOrder() * current byte order}. * *
The {@linkplain #getBitOffset() bit offset} is set to zero * before any data is read. * *
This method does the same as {@link #readUnsignedShort()}. * * @throws EOFException if the input stream ends before all two * bytes were read. * * @throws IOException if some general problem happens with * accessing data. * * @see #readFully(char[], int, int) */ char readChar() throws IOException; /** * Reads a signed 32-bit integer. If necessary, the value gets * converted from the stream’s {@linkplain #getByteOrder() * current byte order}. * *
The {@linkplain #getBitOffset() bit offset} is set to zero * before any data is read. * * @throws EOFException if the input stream ends before all four * bytes were read. * * @throws IOException if some general problem happens with * accessing data. * * @see #readUnsignedInt() * @see #readFully(int[], int, int) */ int readInt() throws IOException; /** * Reads an unsigned 32-bit integer. If necessary, the value gets * converted from the stream’s {@linkplain #getByteOrder() * current byte order}. * *
The {@linkplain #getBitOffset() bit offset} is set to zero * before any data is read. * * @throws EOFException if the input stream ends before all four * bytes were read. * * @throws IOException if some general problem happens with * accessing data. * * @see #readInt() * @see #readFully(int[], int, int) */ long readUnsignedInt() throws IOException; /** * Reads a signed 64-bit integer. If necessary, the value gets * converted from the stream’s {@linkplain #getByteOrder() * current byte order}. * *
The {@linkplain #getBitOffset() bit offset} is set to zero * before any data is read. * * @throws EOFException if the input stream ends before all eight * bytes were read. * * @throws IOException if some general problem happens with * accessing data. * * @see #readFully(long[], int, int) */ long readLong() throws IOException; /** * Reads an IEEE 32-bit single-precision floating point number. If * necessary, the value gets converted from the stream’s * {@linkplain #getByteOrder() current byte order}. * *
The {@linkplain #getBitOffset() bit offset} is set to zero * before any data is read. * * @throws EOFException if the input stream ends before all four * bytes were read. * * @throws IOException if some general problem happens with * accessing data. * * @see #readFully(float[], int, int) */ float readFloat() throws IOException; /** * Reads an IEEE 64-bit double-precision floating point number. If * necessary, the value gets converted from the stream’s * {@linkplain #getByteOrder() current byte order}. * *
The {@linkplain #getBitOffset() bit offset} is set to zero
* before any data is read.
*
* @throws EOFException if the input stream ends before all eight
* bytes were read.
*
* @throws IOException if some general problem happens with
* accessing data.
*
* @see #readFully(double[], int, int)
*/
double readDouble()
throws IOException;
String readLine()
throws IOException;
String readUTF()
throws IOException;
/**
* Reads a sequence of signed 8-bit integers into a
* byte[]
array.
*
*
The {@linkplain #getBitOffset() bit offset} is set to zero
* before any data is read.
*
* @param b an array for storing the read values.
*
* @param offset the index of the first element in b
* that will hold read data.
*
* @param numBytes the number of bytes to read.
*
* @throws IndexOutOfBoundsException if offset
or
* numBytes
is negative, or if offset +
* numBytes
exceeds b.length
.
*
* @throws NullPointerException if b
is
* null
.
*
* @throws EOFException if the input stream ends before all content
* was read.
*
* @throws IOException if some general problem happens with
* accessing data.
*
* @see #readByte()
*/
void readFully(byte[] b, int offset, int numBytes)
throws IOException;
/**
* Reads a sequence of signed 8-bit integers into a
* byte[]
array.
*
*
The {@linkplain #getBitOffset() bit offset} is set to zero
* before any data is read.
*
* @param b an array for storing the read values.
*
* @throws NullPointerException if b
is
* null
.
*
* @throws EOFException if the input stream ends before all content
* was read.
*
* @throws IOException if some general problem happens with
* accessing data.
*
* @see #readByte()
* @see #readFully(byte[], int, int)
*/
void readFully(byte[] b)
throws IOException;
/**
* Reads a sequence of signed 16-bit integers into a
* short[]
array. If necessary, values are converted
* from the stream’s {@linkplain #getByteOrder() current byte
* order}.
*
*
The {@linkplain #getBitOffset() bit offset} is set to zero
* before any data is read.
*
* @param s an array for storing the read values.
*
* @param offset the index of the first element in s
* that will hold read data.
*
* @param numShorts the number of signed 16-bit integers to read
* (which is one half of the number of bytes).
*
* @throws IndexOutOfBoundsException if offset
or
* numShorts
is negative, or if offset +
* numShorts
exceeds s.length
.
*
* @throws NullPointerException if s
is
* null
.
*
* @throws EOFException if the input stream ends before all content
* was read.
*
* @throws IOException if some general problem happens with
* accessing data.
*
* @see #readShort()
*/
void readFully(short[] s, int offset, int numShorts)
throws IOException;
/**
* Reads a sequence of unsigned 16-bit integers into a
* char[]
array. If necessary, values are converted
* from the stream’s {@linkplain #getByteOrder() current byte
* order}.
*
*
The {@linkplain #getBitOffset() bit offset} is set to zero
* before any data is read.
*
* @param c an array for storing the read values.
*
* @param offset the index of the first element in c
* that will hold read data.
*
* @param numChars the number of unsigned 16-bit integers to read
* (which is one half of the number of bytes).
*
* @throws IndexOutOfBoundsException if offset
or
* numChars
is negative, or if offset +
* numChars
exceeds c.length
.
*
* @throws NullPointerException if c
is
* null
.
*
* @throws EOFException if the input stream ends before all content
* was read.
*
* @throws IOException if some general problem happens with
* accessing data.
*
* @see #readChar()
*/
void readFully(char[] c, int offset, int numChars)
throws IOException;
/**
* Reads a sequence of signed 32-bit integers into a
* long[]
array. If necessary, values are converted
* from the stream’s {@linkplain #getByteOrder() current byte
* order}.
*
*
The {@linkplain #getBitOffset() bit offset} is set to zero
* before any data is read.
*
* @param i an array for storing the read values.
*
* @param offset the index of the first element in i
* that will hold read data.
*
* @param numInts the number of signed 32-bit integers to read
* (which is one fourth of the number of bytes).
*
* @throws IndexOutOfBoundsException if offset
or
* numInts
is negative, or if offset +
* numInts
exceeds i.length
.
*
* @throws NullPointerException if i
is
* null
.
*
* @throws EOFException if the input stream ends before all content
* was read.
*
* @throws IOException if some general problem happens with
* accessing data.
*
* @see #readInt()
*/
void readFully(int[] i, int offset, int numInts)
throws IOException;
/**
* Reads a sequence of signed 64-bit integers into a
* long[]
array. If necessary, values are converted
* from the stream’s {@linkplain #getByteOrder() current byte
* order}.
*
*
The {@linkplain #getBitOffset() bit offset} is set to zero
* before any data is read.
*
* @param l an array for storing the read values.
*
* @param offset the index of the first element in l
* that will hold read data.
*
* @param numLongs the number of signed 64-bit integers to read
* (which is one eight of the number of bytes).
*
* @throws IndexOutOfBoundsException if offset
or
* numLongs
is negative, or if offset +
* numLongs
exceeds l.length
.
*
* @throws NullPointerException if l
is
* null
.
*
* @throws EOFException if the input stream ends before all content
* was read.
*
* @throws IOException if some general problem happens with
* accessing data.
*
* @see #readLong()
*/
void readFully(long[] l, int offset, int numLongs)
throws IOException;
/**
* Reads a sequence of IEEE 32-bit single-precision floating point
* numbers into a float[]
array. If necessary, values
* are converted from the stream’s {@linkplain
* #getByteOrder() current byte order}.
*
*
The {@linkplain #getBitOffset() bit offset} is set to zero
* before any data is read.
*
* @param d an array for storing the read values.
*
* @param offset the index of the first element in d
* that will hold read data.
*
* @param numFloats the number of IEEE 32-bit single-precision
* floating point numbers to read (which is one fourth of the number
* of bytes).
*
* @throws IndexOutOfBoundsException if offset
or
* numFloats
is negative, or if offset +
* numFloats
exceeds f.length
.
*
* @throws NullPointerException if f
is
* null
.
*
* @throws EOFException if the input stream ends before all content
* was read.
*
* @throws IOException if some general problem happens with
* accessing data.
*
* @see #readFloat()
*/
void readFully(float[] f, int offset, int numFloats)
throws IOException;
/**
* Reads a sequence of IEEE 64-bit double-precision floating point
* numbers into a double[]
array. If necessary, values
* are converted from the stream’s {@linkplain
* #getByteOrder() current byte order}.
*
*
The {@linkplain #getBitOffset() bit offset} is set to zero
* before any data is read.
*
* @param d an array for storing the read values.
*
* @param offset the index of the first element in d
* that will hold read data.
*
* @param numDoubles the number of IEEE 64-bit double-precision
* floating point numbers to read (which is one eight of the number
* of bytes).
*
* @throws IndexOutOfBoundsException if offset
or
* numDoubles
is negative, or if offset +
* numDoubles
exceeds d.length
.
*
* @throws NullPointerException if d
is
* null
.
*
* @throws EOFException if the input stream ends before all content
* was read.
*
* @throws IOException if some general problem happens with
* accessing data.
*
* @see #readDouble()
*/
void readFully(double[] d, int offset, int numDoubles)
throws IOException;
long getStreamPosition()
throws IOException;
int getBitOffset()
throws IOException;
void setBitOffset(int bitOffset)
throws IOException;
int readBit()
throws IOException;
long readBits(int numBits)
throws IOException;
long length()
throws IOException;
int skipBytes(int numBytes)
throws IOException;
long skipBytes(long numBytes)
throws IOException;
void seek(long pos)
throws IOException;
void mark();
void reset()
throws IOException;
void flushBefore(long pos)
throws IOException;
void flush()
throws IOException;
long getFlushedPosition();
boolean isCached();
boolean isCachedMemory();
boolean isCachedFile();
void close()
throws IOException;
}