org.globus.wsrf.utils.io
Class IndexedObjectFileReader

java.lang.Object
  extended byorg.globus.wsrf.utils.io.IndexedObjectFileReader

public class IndexedObjectFileReader
extends java.lang.Object

Reads Java objects from an indexed file. The indexing allows for random access to any object in the file.

Note: This class is not thread-safe.

See Also:
ObjectInputStream

Field Summary
private  byte[] buffer
           
private  java.util.List index
           
private  long indexPointer
           
private  java.io.RandomAccessFile raf
           
 
Constructor Summary
IndexedObjectFileReader(java.lang.String file)
           
 
Method Summary
 void close()
          Closes the file.
 int getIndexSize()
          Gets the size of the index (the number of objects in the file).
private  void init()
           
 void jumpTo(int index)
          Jumps to the object at the specified position in the file.
 java.lang.Object readObject()
          Reads a Java object from the file.
private  java.lang.Object readObjectSub()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

raf

private java.io.RandomAccessFile raf

buffer

private byte[] buffer

indexPointer

private long indexPointer

index

private java.util.List index
Constructor Detail

IndexedObjectFileReader

public IndexedObjectFileReader(java.lang.String file)
                        throws java.io.IOException,
                               java.io.FileNotFoundException
Method Detail

init

private void init()
           throws java.io.IOException,
                  java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException

readObjectSub

private java.lang.Object readObjectSub()
                                throws java.io.IOException,
                                       java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException

readObject

public java.lang.Object readObject()
                            throws java.io.IOException,
                                   java.lang.ClassNotFoundException
Reads a Java object from the file.

Returns:
the object read from the file.
Throws:
java.io.IOException - if any error occurs.
java.lang.ClassNotFoundException - if cannot find the class for the object in the file.
java.io.EOFException - if end of the file is reached.
See Also:
ObjectInputStream.readObject()

getIndexSize

public int getIndexSize()
Gets the size of the index (the number of objects in the file).

Returns:
the size of the index.

jumpTo

public void jumpTo(int index)
            throws java.io.IOException
Jumps to the object at the specified position in the file.

Parameters:
index - the position to jump to.
Throws:
java.io.IOException - if the position specified is invalid or any other error occurs.

close

public void close()
           throws java.io.IOException
Closes the file.

Throws:
java.io.IOException - if any error occurs.