< prev index next >
src/java.desktop/share/classes/javax/imageio/stream/ImageInputStreamImpl.java
Print this page
*** 31,41 ****
import java.nio.ByteOrder;
import java.util.Stack;
import javax.imageio.IIOException;
/**
! * An abstract class implementing the <code>ImageInputStream</code> interface.
* This class is designed to reduce the number of methods that must
* be implemented by subclasses.
*
* <p> In particular, this class handles most or all of the details of
* byte order interpretation, buffering, mark/reset, discarding,
--- 31,41 ----
import java.nio.ByteOrder;
import java.util.Stack;
import javax.imageio.IIOException;
/**
! * An abstract class implementing the {@code ImageInputStream} interface.
* This class is designed to reduce the number of methods that must
* be implemented by subclasses.
*
* <p> In particular, this class handles most or all of the details of
* byte order interpretation, buffering, mark/reset, discarding,
*** 61,75 ****
*/
byte[] byteBuf = new byte[BYTE_BUF_LENGTH];
/**
* The byte order of the stream as an instance of the enumeration
! * class <code>java.nio.ByteOrder</code>, where
! * <code>ByteOrder.BIG_ENDIAN</code> indicates network byte order
! * and <code>ByteOrder.LITTLE_ENDIAN</code> indicates the reverse
* order. By default, the value is
! * <code>ByteOrder.BIG_ENDIAN</code>.
*/
protected ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
/**
* The current read position within the stream. Subclasses are
--- 61,75 ----
*/
byte[] byteBuf = new byte[BYTE_BUF_LENGTH];
/**
* The byte order of the stream as an instance of the enumeration
! * class {@code java.nio.ByteOrder}, where
! * {@code ByteOrder.BIG_ENDIAN} indicates network byte order
! * and {@code ByteOrder.LITTLE_ENDIAN} indicates the reverse
* order. By default, the value is
! * {@code ByteOrder.BIG_ENDIAN}.
*/
protected ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
/**
* The current read position within the stream. Subclasses are
*** 85,107 ****
*/
protected int bitOffset;
/**
* The position prior to which data may be discarded. Seeking
! * to a smaller position is not allowed. <code>flushedPos</code>
* will always be {@literal >= 0}.
*/
protected long flushedPos = 0;
/**
! * Constructs an <code>ImageInputStreamImpl</code>.
*/
public ImageInputStreamImpl() {
}
/**
! * Throws an <code>IOException</code> if the stream has been closed.
* Subclasses may call this method from any of their methods that
* require the stream not to be closed.
*
* @exception IOException if the stream is closed.
*/
--- 85,107 ----
*/
protected int bitOffset;
/**
* The position prior to which data may be discarded. Seeking
! * to a smaller position is not allowed. {@code flushedPos}
* will always be {@literal >= 0}.
*/
protected long flushedPos = 0;
/**
! * Constructs an {@code ImageInputStreamImpl}.
*/
public ImageInputStreamImpl() {
}
/**
! * Throws an {@code 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.
*
* @exception IOException if the stream is closed.
*/
*** 119,187 ****
return byteOrder;
}
/**
* Reads a single byte from the stream and returns it as an
! * <code>int</code> between 0 and 255. If EOF is reached,
! * <code>-1</code> is returned.
*
* <p> Subclasses must provide an implementation for this method.
* The subclass implementation should update the stream position
* before exiting.
*
* <p> The bit offset within the stream must be reset to zero before
* the read occurs.
*
! * @return the value of the next byte in the stream, or <code>-1</code>
* if EOF is reached.
*
* @exception IOException if the stream has been closed.
*/
public abstract int read() throws IOException;
/**
! * A convenience method that calls <code>read(b, 0, b.length)</code>.
*
* <p> The bit offset within the stream is reset to zero before
* the read occurs.
*
! * @return the number of bytes actually read, or <code>-1</code>
* to indicate EOF.
*
! * @exception NullPointerException if <code>b</code> is
! * <code>null</code>.
* @exception IOException if an I/O error occurs.
*/
public int read(byte[] b) throws IOException {
return read(b, 0, b.length);
}
/**
! * Reads up to <code>len</code> bytes from the stream, and stores
! * them into <code>b</code> starting at index <code>off</code>.
* If no bytes can be read because the end of the stream has been
! * reached, <code>-1</code> is returned.
*
* <p> The bit offset within the stream must be reset to zero before
* the read occurs.
*
* <p> Subclasses must provide an implementation for this method.
* The subclass implementation should update the stream position
* before exiting.
*
* @param b an array of bytes to be written to.
! * @param off the starting position within <code>b</code> to write to.
* @param len the maximum number of bytes to read.
*
! * @return the number of bytes actually read, or <code>-1</code>
* to indicate EOF.
*
! * @exception IndexOutOfBoundsException if <code>off</code> is
! * negative, <code>len</code> is negative, or <code>off +
! * len</code> is greater than <code>b.length</code>.
! * @exception NullPointerException if <code>b</code> is
! * <code>null</code>.
* @exception IOException if an I/O error occurs.
*/
public abstract int read(byte[] b, int off, int len) throws IOException;
public void readBytes(IIOByteBuffer buf, int len) throws IOException {
--- 119,187 ----
return byteOrder;
}
/**
* Reads a single byte from the stream and returns it as an
! * {@code int} between 0 and 255. If EOF is reached,
! * {@code -1} is returned.
*
* <p> Subclasses must provide an implementation for this method.
* The subclass implementation should update the stream position
* before exiting.
*
* <p> The bit offset within the stream must be reset to zero before
* the read occurs.
*
! * @return the value of the next byte in the stream, or {@code -1}
* if EOF is reached.
*
* @exception IOException if the stream has been closed.
*/
public abstract int read() throws IOException;
/**
! * A convenience method that calls {@code read(b, 0, b.length)}.
*
* <p> The bit offset within the stream is reset to zero before
* the read occurs.
*
! * @return the number of bytes actually read, or {@code -1}
* to indicate EOF.
*
! * @exception NullPointerException if {@code b} is
! * {@code null}.
* @exception IOException if an I/O error occurs.
*/
public int read(byte[] b) throws IOException {
return read(b, 0, b.length);
}
/**
! * Reads up to {@code len} bytes from the stream, and stores
! * them into {@code b} starting at index {@code off}.
* If no bytes can be read because the end of the stream has been
! * reached, {@code -1} is returned.
*
* <p> The bit offset within the stream must be reset to zero before
* the read occurs.
*
* <p> Subclasses must provide an implementation for this method.
* The subclass implementation should update the stream position
* before exiting.
*
* @param b an array of bytes to be written to.
! * @param off the starting position within {@code b} to write to.
* @param len the maximum number of bytes to read.
*
! * @return the number of bytes actually read, or {@code -1}
* to indicate EOF.
*
! * @exception IndexOutOfBoundsException if {@code off} is
! * negative, {@code len} is negative, or {@code off + len}
! * is greater than {@code b.length}.
! * @exception NullPointerException if {@code b} is
! * {@code null}.
* @exception IOException if an I/O error occurs.
*/
public abstract int read(byte[] b, int off, int len) throws IOException;
public void readBytes(IIOByteBuffer buf, int len) throws IOException {
*** 706,716 ****
return accum;
}
/**
! * Returns <code>-1L</code> to indicate that the stream has unknown
* length. Subclasses must override this method to provide actual
* length information.
*
* @return -1L to indicate unknown length.
*/
--- 706,716 ----
return accum;
}
/**
! * Returns {@code -1L} to indicate that the stream has unknown
* length. Subclasses must override this method to provide actual
* length information.
*
* @return -1L to indicate unknown length.
*/
*** 718,759 ****
return -1L;
}
/**
* Advances the current stream position by calling
! * <code>seek(getStreamPosition() + n)</code>.
*
* <p> The bit offset is reset to zero.
*
* @param n the number of bytes to seek forward.
*
! * @return an <code>int</code> representing the number of bytes
* skipped.
*
! * @exception IOException if <code>getStreamPosition</code>
! * throws an <code>IOException</code> when computing either
* the starting or ending position.
*/
public int skipBytes(int n) throws IOException {
long pos = getStreamPosition();
seek(pos + n);
return (int)(getStreamPosition() - pos);
}
/**
* Advances the current stream position by calling
! * <code>seek(getStreamPosition() + n)</code>.
*
* <p> The bit offset is reset to zero.
*
* @param n the number of bytes to seek forward.
*
! * @return a <code>long</code> representing the number of bytes
* skipped.
*
! * @exception IOException if <code>getStreamPosition</code>
! * throws an <code>IOException</code> when computing either
* the starting or ending position.
*/
public long skipBytes(long n) throws IOException {
long pos = getStreamPosition();
seek(pos + n);
--- 718,759 ----
return -1L;
}
/**
* Advances the current stream position by calling
! * {@code seek(getStreamPosition() + n)}.
*
* <p> The bit offset is reset to zero.
*
* @param n the number of bytes to seek forward.
*
! * @return an {@code int} representing the number of bytes
* skipped.
*
! * @exception IOException if {@code getStreamPosition}
! * throws an {@code IOException} when computing either
* the starting or ending position.
*/
public int skipBytes(int n) throws IOException {
long pos = getStreamPosition();
seek(pos + n);
return (int)(getStreamPosition() - pos);
}
/**
* Advances the current stream position by calling
! * {@code seek(getStreamPosition() + n)}.
*
* <p> The bit offset is reset to zero.
*
* @param n the number of bytes to seek forward.
*
! * @return a {@code long} representing the number of bytes
* skipped.
*
! * @exception IOException if {@code getStreamPosition}
! * throws an {@code IOException} when computing either
* the starting or ending position.
*/
public long skipBytes(long n) throws IOException {
long pos = getStreamPosition();
seek(pos + n);
*** 786,796 ****
/**
* Resets the current stream byte and bit positions from the stack
* of marked positions.
*
! * <p> An <code>IOException</code> will be thrown if the previous
* marked position lies in the discarded portion of the stream.
*
* @exception IOException if an I/O error occurs.
*/
public void reset() throws IOException {
--- 786,796 ----
/**
* Resets the current stream byte and bit positions from the stack
* of marked positions.
*
! * <p> An {@code IOException} will be thrown if the previous
* marked position lies in the discarded portion of the stream.
*
* @exception IOException if an I/O error occurs.
*/
public void reset() throws IOException {
*** 859,869 ****
isClosed = true;
}
/**
* Finalizes this object prior to garbage collection. The
! * <code>close</code> method is called to close any open input
* source. This method should not be called from application
* code.
*
* @exception Throwable if an error occurs during superclass
* finalization.
--- 859,869 ----
isClosed = true;
}
/**
* Finalizes this object prior to garbage collection. The
! * {@code close} method is called to close any open input
* source. This method should not be called from application
* code.
*
* @exception Throwable if an error occurs during superclass
* finalization.
< prev index next >