Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.ydp.jai
Class FileSeekableStream  view FileSeekableStream download FileSeekableStream.java

java.lang.Object
  extended byjava.io.InputStream
      extended byorg.ydp.jai.SeekableStream
          extended byorg.ydp.jai.FileSeekableStream
All Implemented Interfaces:
java.io.Closeable, java.io.DataInput

public class FileSeekableStream
extends SeekableStream

A subclass of SeekableStream that takes its input from a File or RandomAccessFile. Backwards seeking is supported. The mark() and resest() methods are supported.

This class is not a committed part of the JAI API. It may be removed or changed in future releases of JAI.


Field Summary
private  int[] currentPage
           
private  java.io.RandomAccessFile file
           
private  long length
           
private  long markPos
           
private static int NUM_PAGES
           
private static int PAGE_MASK
           
private static int PAGE_SHIFT
           
private static int PAGE_SIZE
           
private  byte[][] pageBuf
           
private  long pointer
           
private static int READ_CACHE_LIMIT
           
 
Fields inherited from class org.ydp.jai.SeekableStream
 
Constructor Summary
FileSeekableStream(java.io.File file)
          Constructs a FileSeekableStream from a File.
FileSeekableStream(java.io.RandomAccessFile file)
          Constructs a FileSeekableStream from a RandomAccessFile.
FileSeekableStream(java.lang.String name)
          Constructs a FileSeekableStream from a String path name.
 
Method Summary
 boolean canSeekBackwards()
          Returns true since seeking backwards is supported.
 void close()
          Forwards the request to the real File.
 long getFilePointer()
          Returns the current offset in this stream.
 void mark(int readLimit)
          Marks the current file position for later return using the reset() method.
 boolean markSupported()
          Returns true since marking is supported.
 int read()
          Forwards the request to the real File.
 int read(byte[] b, int off, int len)
          Forwards the request to the real File.
private  byte[] readPage(long pointer)
           
 void reset()
          Returns the file position to its position at the time of the immediately previous call to the mark() method.
 void seek(long pos)
          Sets the offset, measured from the beginning of this stream, at which the next read occurs.
 int skip(int n)
           
 
Methods inherited from class org.ydp.jai.SeekableStream
finalize, readBoolean, readByte, readChar, readCharLE, readDouble, readDoubleLE, readFloat, readFloatLE, readFully, readFully, readInt, readIntLE, readLine, readLong, readLongLE, readShort, readShortLE, readUnsignedByte, readUnsignedInt, readUnsignedIntLE, readUnsignedShort, readUnsignedShortLE, readUTF, skipBytes, wrapInputStream
 
Methods inherited from class java.io.InputStream
available, read, skip
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

file

private java.io.RandomAccessFile file

markPos

private long markPos

PAGE_SHIFT

private static final int PAGE_SHIFT
See Also:
Constant Field Values

PAGE_SIZE

private static final int PAGE_SIZE
See Also:
Constant Field Values

PAGE_MASK

private static final int PAGE_MASK
See Also:
Constant Field Values

NUM_PAGES

private static final int NUM_PAGES
See Also:
Constant Field Values

READ_CACHE_LIMIT

private static final int READ_CACHE_LIMIT
See Also:
Constant Field Values

pageBuf

private byte[][] pageBuf

currentPage

private int[] currentPage

length

private long length

pointer

private long pointer
Constructor Detail

FileSeekableStream

public FileSeekableStream(java.io.RandomAccessFile file)
                   throws java.io.IOException
Constructs a FileSeekableStream from a RandomAccessFile.


FileSeekableStream

public FileSeekableStream(java.io.File file)
                   throws java.io.IOException
Constructs a FileSeekableStream from a File.


FileSeekableStream

public FileSeekableStream(java.lang.String name)
                   throws java.io.IOException
Constructs a FileSeekableStream from a String path name.

Method Detail

canSeekBackwards

public final boolean canSeekBackwards()
Returns true since seeking backwards is supported.

Overrides:
canSeekBackwards in class SeekableStream

getFilePointer

public final long getFilePointer()
                          throws java.io.IOException
Returns the current offset in this stream.

Specified by:
getFilePointer in class SeekableStream

seek

public final void seek(long pos)
                throws java.io.IOException
Description copied from class: SeekableStream
Sets the offset, measured from the beginning of this stream, at which the next read occurs.

If canSeekBackwards() returns false, then setting pos to an offset smaller than the current value of getFilePointer() will have no effect.

Specified by:
seek in class SeekableStream

skip

public final int skip(int n)
               throws java.io.IOException

readPage

private byte[] readPage(long pointer)
                 throws java.io.IOException

read

public final int read()
               throws java.io.IOException
Forwards the request to the real File.

Specified by:
read in class SeekableStream

read

public final int read(byte[] b,
                      int off,
                      int len)
               throws java.io.IOException
Forwards the request to the real File.

Specified by:
read in class SeekableStream

close

public final void close()
                 throws java.io.IOException
Forwards the request to the real File.


mark

public final void mark(int readLimit)
Marks the current file position for later return using the reset() method.

Overrides:
mark in class SeekableStream

reset

public final void reset()
                 throws java.io.IOException
Returns the file position to its position at the time of the immediately previous call to the mark() method.

Overrides:
reset in class SeekableStream

markSupported

public boolean markSupported()
Returns true since marking is supported.

Overrides:
markSupported in class SeekableStream