stresstests.datasets
Class TraversalOutFile

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

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

An output iterator for City objects for file output.


Field Summary
protected  javax.swing.JFileChooser chooser
           
protected  City[] cities
          the list of cities to output
protected  boolean closed
          true if the file is closed
protected  int i
          loop counter
protected  java.lang.String s
          a String object to hold file contents
 
Constructor Summary
TraversalOutFile(City[] aCities)
          Select a file where the data will be stored, make sure it can be written.
 
Method Summary
 City getFirst()
          return the most recent city processed - if available
 Traversal<City> getRest()
          process next item, if available
 boolean isEmpty()
          verify that new city is available to add to the file
static void main(java.lang.String[] argv)
           
static void writeFile(java.io.File f, java.lang.String data, boolean overwrite)
          Writes the given data to the given file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cities

protected City[] cities
the list of cities to output


i

protected int i
loop counter


closed

protected boolean closed
true if the file is closed


s

protected java.lang.String s
a String object to hold file contents


chooser

protected javax.swing.JFileChooser chooser
Constructor Detail

TraversalOutFile

public TraversalOutFile(City[] aCities)
Select a file where the data will be stored, make sure it can be written. Save the given data.

Method Detail

getRest

public Traversal<City> getRest()
process next item, if available

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 city processed - 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 city is available to add to the file

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

writeFile

public static void writeFile(java.io.File f,
                             java.lang.String data,
                             boolean overwrite)
                      throws java.io.IOException
Writes the given data to the given file.

Parameters:
f - the file to be written
data - the data to write to the file
overwrite - whether or not to automatically overwrite existing file contents
Throws:
FileExistsException - if the file exists and is not to be automatically overwritten
java.io.IOException - if there is an error writing the file

main

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