1 /* ImageInputStream.java
2 Copyright (C) 2004, 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax
.imageio
.stream
;
41 import java
.io
.DataInput
;
42 import java
.io
.EOFException
;
43 import java
.io
.IOException
;
44 import java
.nio
.ByteOrder
;
48 * An input stream for use by {@link javax.imageio.ImageReader
53 * @author Sascha Brawer (brawer@dandelis.ch)
55 public interface ImageInputStream
58 void setByteOrder(ByteOrder order
);
60 ByteOrder
getByteOrder();
68 int read(byte[] b
, int offset
, int length
)
73 * Reads up to a specified number of bytes, and modifies a
74 * {@link IIOByteBuffer} to hold the read data.
76 * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
77 * before any data is read.
79 * @param buf an <code>IIOByteBuffer</code> that will hold the read
82 * @param numBytes the maximum number of bytes to read.
84 * @throws IndexOutOfBoundsException if <code>numBytes</code> is
87 * @throws NullPointerException if <code>buf</code> is
90 * @throws IOException if some general problem happens with
93 void readBytes(IIOByteBuffer buf
, int numBytes
)
98 * Reads a byte and checks whether or not its value is zero.
100 * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
101 * before the byte is read.
103 * @throws EOFException if the input stream is at its end.
105 * @throws IOException if some general problem happens with
110 * @see #readFully(byte[], int, int)
112 boolean readBoolean()
117 * Reads a signed byte.
119 * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
120 * before any data is read.
122 * @throws EOFException if the input stream is at its end.
124 * @throws IOException if some general problem happens with
127 * @see #readUnsignedByte()
128 * @see #readFully(byte[], int, int)
135 * Reads an unsigned byte.
137 * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
138 * before any data is read.
140 * @throws EOFException if the input stream is at its end.
142 * @throws IOException if some general problem happens with
146 * @see #readFully(byte[], int, int)
148 int readUnsignedByte()
153 * Reads an signed 16-bit integer. If necessary, the value gets
154 * converted from the stream’s {@linkplain #getByteOrder()
155 * current byte order}.
157 * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
158 * before any data is read.
160 * @throws EOFException if the input stream ends before all two
163 * @throws IOException if some general problem happens with
166 * @see #readUnsignedShort()
168 * @see #readFully(short[], int, int)
175 * Reads an unsigned 16-bit integer. If necessary, the value gets
176 * converted from the stream’s {@linkplain #getByteOrder()
177 * current byte order}.
179 * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
180 * before any data is read.
182 * <p>This method does the same as {@link #readChar()}.
184 * @throws EOFException if the input stream ends before all two
187 * @throws IOException if some general problem happens with
192 * @see #readFully(char[], int, int)
194 int readUnsignedShort()
199 * Reads an unsigned 16-bit integer. If necessary, the value gets
200 * converted from the stream’s {@linkplain #getByteOrder()
201 * current byte order}.
203 * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
204 * before any data is read.
206 * <p>This method does the same as {@link #readUnsignedShort()}.
208 * @throws EOFException if the input stream ends before all two
211 * @throws IOException if some general problem happens with
214 * @see #readFully(char[], int, int)
221 * Reads a signed 32-bit integer. If necessary, the value gets
222 * converted from the stream’s {@linkplain #getByteOrder()
223 * current byte order}.
225 * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
226 * before any data is read.
228 * @throws EOFException if the input stream ends before all four
231 * @throws IOException if some general problem happens with
234 * @see #readUnsignedInt()
235 * @see #readFully(int[], int, int)
242 * Reads an unsigned 32-bit integer. If necessary, the value gets
243 * converted from the stream’s {@linkplain #getByteOrder()
244 * current byte order}.
246 * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
247 * before any data is read.
249 * @throws EOFException if the input stream ends before all four
252 * @throws IOException if some general problem happens with
256 * @see #readFully(int[], int, int)
258 long readUnsignedInt()
263 * Reads a signed 64-bit integer. If necessary, the value gets
264 * converted from the stream’s {@linkplain #getByteOrder()
265 * current byte order}.
267 * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
268 * before any data is read.
270 * @throws EOFException if the input stream ends before all eight
273 * @throws IOException if some general problem happens with
276 * @see #readFully(long[], int, int)
283 * Reads an IEEE 32-bit single-precision floating point number. If
284 * necessary, the value gets converted from the stream’s
285 * {@linkplain #getByteOrder() current byte order}.
287 * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
288 * before any data is read.
290 * @throws EOFException if the input stream ends before all four
293 * @throws IOException if some general problem happens with
296 * @see #readFully(float[], int, int)
303 * Reads an IEEE 64-bit double-precision floating point number. If
304 * necessary, the value gets converted from the stream’s
305 * {@linkplain #getByteOrder() current byte order}.
307 * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
308 * before any data is read.
310 * @throws EOFException if the input stream ends before all eight
313 * @throws IOException if some general problem happens with
316 * @see #readFully(double[], int, int)
329 * Reads a sequence of signed 8-bit integers into a
330 * <code>byte[]</code> array.
332 * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
333 * before any data is read.
335 * @param b an array for storing the read values.
337 * @param offset the index of the first element in <code>b</code>
338 * that will hold read data.
340 * @param numBytes the number of bytes to read.
342 * @throws IndexOutOfBoundsException if <code>offset</code> or
343 * <code>numBytes</code> is negative, or if <code>offset +
344 * numBytes</code> exceeds <code>b.length</code>.
346 * @throws NullPointerException if <code>b</code> is
349 * @throws EOFException if the input stream ends before all content
352 * @throws IOException if some general problem happens with
357 void readFully(byte[] b
, int offset
, int numBytes
)
362 * Reads a sequence of signed 8-bit integers into a
363 * <code>byte[]</code> array.
365 * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
366 * before any data is read.
368 * @param b an array for storing the read values.
370 * @throws NullPointerException if <code>b</code> is
373 * @throws EOFException if the input stream ends before all content
376 * @throws IOException if some general problem happens with
380 * @see #readFully(byte[], int, int)
382 void readFully(byte[] b
)
387 * Reads a sequence of signed 16-bit integers into a
388 * <code>short[]</code> array. If necessary, values are converted
389 * from the stream’s {@linkplain #getByteOrder() current byte
392 * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
393 * before any data is read.
395 * @param s an array for storing the read values.
397 * @param offset the index of the first element in <code>s</code>
398 * that will hold read data.
400 * @param numShorts the number of signed 16-bit integers to read
401 * (which is one half of the number of bytes).
403 * @throws IndexOutOfBoundsException if <code>offset</code> or
404 * <code>numShorts</code> is negative, or if <code>offset +
405 * numShorts</code> exceeds <code>s.length</code>.
407 * @throws NullPointerException if <code>s</code> is
410 * @throws EOFException if the input stream ends before all content
413 * @throws IOException if some general problem happens with
418 void readFully(short[] s
, int offset
, int numShorts
)
423 * Reads a sequence of unsigned 16-bit integers into a
424 * <code>char[]</code> array. If necessary, values are converted
425 * from the stream’s {@linkplain #getByteOrder() current byte
428 * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
429 * before any data is read.
431 * @param c an array for storing the read values.
433 * @param offset the index of the first element in <code>c</code>
434 * that will hold read data.
436 * @param numChars the number of unsigned 16-bit integers to read
437 * (which is one half of the number of bytes).
439 * @throws IndexOutOfBoundsException if <code>offset</code> or
440 * <code>numChars</code> is negative, or if <code>offset +
441 * numChars</code> exceeds <code>c.length</code>.
443 * @throws NullPointerException if <code>c</code> is
446 * @throws EOFException if the input stream ends before all content
449 * @throws IOException if some general problem happens with
454 void readFully(char[] c
, int offset
, int numChars
)
459 * Reads a sequence of signed 32-bit integers into a
460 * <code>long[]</code> array. If necessary, values are converted
461 * from the stream’s {@linkplain #getByteOrder() current byte
464 * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
465 * before any data is read.
467 * @param i an array for storing the read values.
469 * @param offset the index of the first element in <code>i</code>
470 * that will hold read data.
472 * @param numLongs the number of signed 32-bit integers to read
473 * (which is one fourth of the number of bytes).
475 * @throws IndexOutOfBoundsException if <code>offset</code> or
476 * <code>numInts</code> is negative, or if <code>offset +
477 * numInts</code> exceeds <code>i.length</code>.
479 * @throws NullPointerException if <code>i</code> is
482 * @throws EOFException if the input stream ends before all content
485 * @throws IOException if some general problem happens with
490 void readFully(int[] i
, int offset
, int numInts
)
495 * Reads a sequence of signed 64-bit integers into a
496 * <code>long[]</code> array. If necessary, values are converted
497 * from the stream’s {@linkplain #getByteOrder() current byte
500 * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
501 * before any data is read.
503 * @param l an array for storing the read values.
505 * @param offset the index of the first element in <code>l</code>
506 * that will hold read data.
508 * @param numLongs the number of signed 64-bit integers to read
509 * (which is one eight of the number of bytes).
511 * @throws IndexOutOfBoundsException if <code>offset</code> or
512 * <code>numLongs</code> is negative, or if <code>offset +
513 * numLongs</code> exceeds <code>l.length</code>.
515 * @throws NullPointerException if <code>l</code> is
518 * @throws EOFException if the input stream ends before all content
521 * @throws IOException if some general problem happens with
526 void readFully(long[] l
, int offset
, int numLongs
)
531 * Reads a sequence of IEEE 32-bit single-precision floating point
532 * numbers into a <code>float[]</code> array. If necessary, values
533 * are converted from the stream’s {@linkplain
534 * #getByteOrder() current byte order}.
536 * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
537 * before any data is read.
539 * @param d an array for storing the read values.
541 * @param offset the index of the first element in <code>d</code>
542 * that will hold read data.
544 * @param numFloats the number of IEEE 32-bit single-precision
545 * floating point numbers to read (which is one fourth of the number
548 * @throws IndexOutOfBoundsException if <code>offset</code> or
549 * <code>numFloats</code> is negative, or if <code>offset +
550 * numFloats</code> exceeds <code>f.length</code>.
552 * @throws NullPointerException if <code>f</code> is
555 * @throws EOFException if the input stream ends before all content
558 * @throws IOException if some general problem happens with
563 void readFully(float[] f
, int offset
, int numFloats
)
568 * Reads a sequence of IEEE 64-bit double-precision floating point
569 * numbers into a <code>double[]</code> array. If necessary, values
570 * are converted from the stream’s {@linkplain
571 * #getByteOrder() current byte order}.
573 * <p>The {@linkplain #getBitOffset() bit offset} is set to zero
574 * before any data is read.
576 * @param d an array for storing the read values.
578 * @param offset the index of the first element in <code>d</code>
579 * that will hold read data.
581 * @param numDoubles the number of IEEE 64-bit double-precision
582 * floating point numbers to read (which is one eight of the number
585 * @throws IndexOutOfBoundsException if <code>offset</code> or
586 * <code>numDoubles</code> is negative, or if <code>offset +
587 * numDoubles</code> exceeds <code>d.length</code>.
589 * @throws NullPointerException if <code>d</code> is
592 * @throws EOFException if the input stream ends before all content
595 * @throws IOException if some general problem happens with
600 void readFully(double[] d
, int offset
, int numDoubles
)
603 long getStreamPosition()
609 void setBitOffset(int bitOffset
)
615 long readBits(int numBits
)
621 int skipBytes(int numBytes
)
624 long skipBytes(long numBytes
)
635 void flushBefore(long pos
)
641 long getFlushedPosition();
645 boolean isCachedMemory();
647 boolean isCachedFile();