sbrt.shell.io
Class SerializedFileIterator<E>

java.lang.Object
  extended by sbrt.shell.io.FileLineIterator<E>
      extended by sbrt.shell.io.SerializedFileIterator<E>
Type Parameters:
E - the returned type.
All Implemented Interfaces:
java.util.Iterator<E>

public final class SerializedFileIterator<E>
extends FileLineIterator<E>

This class is used to iterate over the objects in a serialized input file.

Author:
This class was written and documented by Jeremiah Wright while in the Wagner lab.

Constructor Summary
SerializedFileIterator(SerializedInputFile<E> file)
          Constructs a new serialized file iterator using the provided serialized input file.
 
Method Summary
 void close()
          Closes this file iterator.
protected  void finalize()
          Disposes of system resources associated with this file iterator when called by the garbage collector.
 boolean hasNext()
          Indicates if the file has more serialized objects.
 boolean isClosed()
          Indicates if this iterator has been closed.
static boolean isValidFormat(FileFormat fileFormat)
          Indicates if the provided file format is valid for this type of file iterator.
 E next()
          Returns the next object in the file.
protected  java.lang.Object nextObject()
          Returns the next object in the file.
 void remove()
          Throws UnsupportedOperationException.
 
Methods inherited from class sbrt.shell.io.FileLineIterator
checkFile
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerializedFileIterator

public SerializedFileIterator(SerializedInputFile<E> file)
Constructs a new serialized file iterator using the provided serialized input file.

Parameters:
file - the file to be iterated over.
Method Detail

isValidFormat

public static boolean isValidFormat(FileFormat fileFormat)
Indicates if the provided file format is valid for this type of file iterator.

Parameters:
fileFormat - the file format to test.
Returns:
true if the provided file format is valid for a serialized input file; false otherwise.

hasNext

public boolean hasNext()
Indicates if the file has more serialized objects.

Returns:
true if the file has more objects; false otherwise.

next

public E next()
Returns the next object in the file.

Returns:
the next object in the file.
Throws:
java.util.NoSuchElementException - if the file has no more objects.

nextObject

protected final java.lang.Object nextObject()
Returns the next object in the file.

Returns:
the next object in the file.
Throws:
ApplicationException - if an error occurs while the file is being read.
java.util.NoSuchElementException - if the file has no more objects.

remove

public void remove()
Throws UnsupportedOperationException.

Throws:
java.lang.UnsupportedOperationException

isClosed

public boolean isClosed()
Indicates if this iterator has been closed.

Returns:
true if close() has been called; false otherwise.

close

public void close()
Closes this file iterator. If this file iterator is already closed, then invoking this method has no effect.

Throws:
ApplicationException - if an I/O error occurred while closing this file iterator.

finalize

protected void finalize()
                 throws java.lang.Throwable
Disposes of system resources associated with this file iterator when called by the garbage collector.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable - the Exception raised by this method.
See Also:
Object.finalize()