This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.imageio.stream
class ImageInputStreamImpl

java.lang.Object extended by javax.imageio.stream.ImageInputStreamImpl
All Implemented Interfaces:
ImageInputStream
Direct Known Subclasses:
FileCacheImageInputStream, FileImageInputStream, ImageOutputStreamImpl, MemoryCacheImageInputStream

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

          
protected void

          Finalizes this object prior to garbage collection.
 void

          
 void
flushBefore(long pos)

          
 int

          
 ByteOrder

          
 long

          
 long

          
 boolean

          Default implementation returns false.
 boolean

          Default implementation returns false.
 boolean

          Default implementation returns false.
 long

          Returns -1L to indicate that the stream has unknown length.
 void

          Pushes the current stream position onto a stack of marked positions.
abstract int

          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

          
 long
readBits(int numBits)

          
 boolean

          
 byte

          
 void
readBytes(IIOByteBuffer buf, int len)

          
 char

          
 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

          
 String

          
 long

          
 short

          
 int

          
 long

          
 int

          
 String

          
 void

          Resets the current stream byte and bit positions from the stack of marked positions.
 void
seek(long pos)

          
 void
setBitOffset(int bitOffset)

          
 void

          
 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

bitOffset

protected int bitOffset
The current bit offset within the stream. Subclasses are responsible for keeping this value current from any method they override that alters the bit offset.

byteOrder

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. By default, the value is ByteOrder.BIG_ENDIAN.

flushedPos

protected long flushedPos
The position prior to which data may be discarded. Seeking to a smaller position is not allowed. flushedPos will always be >= 0.

streamPos

protected long streamPos
The current read position within the stream. Subclasses are responsible for keeping this value current from any method they override that alters the read position.
Constructor Detail

ImageInputStreamImpl

public ImageInputStreamImpl()
Constructs an ImageInputStreamImpl.

Method Detail

checkClosed

protected final void checkClosed()
                          throws IOException
Throws an 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.

Throws:
IOException - if the stream is closed.

close

public void close()
           throws IOException
Throws:
IOException

finalize

protected void finalize()
                 throws Throwable
Finalizes this object prior to garbage collection. The close method is called to close any open input source. This method should not be called from application code.

Overrides:
finalize in class Object
Throws:
Throwable - if an error occurs during superclass finalization.

flush

public void flush()
           throws IOException
Throws:
IOException

flushBefore

public void flushBefore(long pos)
                 throws IOException
Parameters:
pos
Throws:
IOException

getBitOffset

public int getBitOffset()
                 throws IOException
Throws:
IOException

getByteOrder

public ByteOrder getByteOrder()

getFlushedPosition

public long getFlushedPosition()

getStreamPosition

public long getStreamPosition()
                       throws IOException
Throws:
IOException

isCached

public boolean isCached()
Default implementation returns false. Subclasses should override this if they cache data.


isCachedFile

public boolean isCachedFile()
Default implementation returns false. Subclasses should override this if they cache data in a temporary file.


isCachedMemory

public boolean isCachedMemory()
Default implementation returns false. Subclasses should override this if they cache data in main memory.


length

public long length()
Returns -1L to indicate that the stream has unknown length. Subclasses must override this method to provide actual length information.

Returns:
-1L to indicate unknown length.

mark

public void mark()
Pushes the current stream position onto a stack of marked positions.


read

public abstract int read()
                  throws IOException
Reads a single byte from the stream and returns it as an 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.

Returns:
the value of the next byte in the stream, or -1 if EOF is reached.
Throws:
IOException - if the stream has been closed.

read

public int read(byte[] b)
         throws IOException
A convenience method that calls read(b, 0, b.length).

The bit offset within the stream is reset to zero before the read occurs.

Parameters:
b
Returns:
the number of bytes actually read, or -1 to indicate EOF.
Throws:
IOException - if an I/O error occurs.

read

public abstract int read(byte[] b,
                         int off,
                         int len)
                  throws IOException
Reads up to 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.

Parameters:
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.
Returns:
the number of bytes actually read, or -1 to indicate EOF.
Throws:
IOException - if an I/O error occurs.

readBit

public int readBit()
            throws IOException
Throws:
IOException

readBits

public long readBits(int numBits)
              throws IOException
Parameters:
numBits
Throws:
IOException

readBoolean

public boolean readBoolean()
                    throws IOException
Throws:
IOException

readByte

public byte readByte()
              throws IOException
Throws:
IOException

readBytes

public void readBytes(IIOByteBuffer buf,
                      int len)
               throws IOException
Parameters:
buf
len
Throws:
IOException

readChar

public char readChar()
              throws IOException
Throws:
IOException

readDouble

public double readDouble()
                  throws IOException
Throws:
IOException

readFloat

public float readFloat()
                throws IOException
Throws:
IOException

readFully

public void readFully(byte[] b)
               throws IOException
Parameters:
b
Throws:
IOException

readFully

public void readFully(byte[] b,
                      int off,
                      int len)
               throws IOException
Parameters:
b
off
len
Throws:
IOException

readFully

public void readFully(char[] c,
                      int off,
                      int len)
               throws IOException
Parameters:
c
off
len
Throws:
IOException

readFully

public void readFully(double[] d,
                      int off,
                      int len)
               throws IOException
Parameters:
d
off
len
Throws:
IOException

readFully

public void readFully(float[] f,
                      int off,
                      int len)
               throws IOException
Parameters:
f
off
len
Throws:
IOException

readFully

public void readFully(int[] i,
                      int off,
                      int len)
               throws IOException
Parameters:
i
off
len
Throws:
IOException

readFully

public void readFully(long[] l,
                      int off,
                      int len)
               throws IOException
Parameters:
l
off
len
Throws:
IOException

readFully

public void readFully(short[] s,
                      int off,
                      int len)
               throws IOException
Parameters:
s
off
len
Throws:
IOException

readInt

public int readInt()
            throws IOException
Throws:
IOException

readLine

public String readLine()
                throws IOException
Throws:
IOException

readLong

public long readLong()
              throws IOException
Throws:
IOException

readShort

public short readShort()
                throws IOException
Throws:
IOException

readUnsignedByte

public int readUnsignedByte()
                     throws IOException
Throws:
IOException

readUnsignedInt

public long readUnsignedInt()
                     throws IOException
Throws:
IOException

readUnsignedShort

public int readUnsignedShort()
                      throws IOException
Throws:
IOException

readUTF

public String readUTF()
               throws IOException
Throws:
IOException

reset

public void reset()
           throws IOException
Resets the current stream byte and bit positions from the stack of marked positions.

An IOException will be thrown if the previous marked position lies in the discarded portion of the stream.

Throws:
IOException - if an I/O error occurs.

seek

public void seek(long pos)
          throws IOException
Parameters:
pos
Throws:
IOException

setBitOffset

public void setBitOffset(int bitOffset)
                  throws IOException
Parameters:
bitOffset
Throws:
IOException

setByteOrder

public void setByteOrder(ByteOrder byteOrder)
Parameters:
byteOrder

skipBytes

public int skipBytes(int n)
              throws IOException
Advances the current stream position by calling seek(getStreamPosition() + n).

The bit offset is reset to zero.

Parameters:
n - the number of bytes to seek forward.
Returns:
an int representing the number of bytes skipped.
Throws:
IOException - if getStreamPosition throws an IOException when computing either the starting or ending position.

skipBytes

public long skipBytes(long n)
               throws IOException
Advances the current stream position by calling seek(getStreamPosition() + n).

The bit offset is reset to zero.

Parameters:
n - the number of bytes to seek forward.
Returns:
a long representing the number of bytes skipped.
Throws:
IOException - if getStreamPosition throws an IOException when computing either the starting or ending position.


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.