stresstests.datasets
Class TraversalInFile

java.lang.Object
  extended by stresstests.datasets.TraversalInFile
All Implemented Interfaces:
Traversal<City>

public class TraversalInFile
extends java.lang.Object
implements Traversal<City>

Functional (External) Iterator Pattern: file reader iterator for a list of cities TraversalInFile 22 March 2006

Author:
Viera K. Proulx

Field Summary
protected  java.io.BufferedReader buffer
          the input reader
protected  City c
          a city object to hold values
protected  boolean closed
          determines whether the general dialog has been closed
protected  java.lang.String line
          one line of input at a time
protected  boolean submitted
          determines whether new city data has been submitted
 
Constructor Summary
TraversalInFile()
          Select a file from which the data will be read, make sure it can be opened.
 
Method Summary
 City getFirst()
          return the most recent submission - if available
 void getnext()
          process next item, if available
 Traversal<City> getRest()
          produce a traversal for the rest of this list
 boolean isEmpty()
          verify that new submission is available
static void main(java.lang.String[] argv)
          Self Test
 void read(java.lang.String s)
          extract next City object from the input string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buffer

protected java.io.BufferedReader buffer
the input reader


line

protected java.lang.String line
one line of input at a time


c

protected City c
a city object to hold values


closed

protected boolean closed
determines whether the general dialog has been closed


submitted

protected boolean submitted
determines whether new city data has been submitted

Constructor Detail

TraversalInFile

public TraversalInFile()
Select a file from which the data will be read, make sure it can be opened.

Method Detail

getnext

public void getnext()
process next item, if available


getRest

public Traversal<City> getRest()
produce a traversal for the rest of this list

Specified by:
getRest in interface Traversal<City>
Returns:
the Traversal for the rest of this dataset if available -- otherwise throws IllegalUseOfTraversalException

getFirst

public City getFirst()
return the most recent submission - if available

Specified by:
getFirst in interface Traversal<City>
Returns:
the first element if available -- otherwise throws IllegalUseOfTraversalException

isEmpty

public boolean isEmpty()
verify that new submission is available

Specified by:
isEmpty in interface Traversal<City>
Returns:
true if the dataset is empty

read

public void read(java.lang.String s)
extract next City object from the input string


main

public static void main(java.lang.String[] argv)
Self Test