support.Flight
Class Parser

java.lang.Object
  |
  +--support.Flight.Parser

public class Parser
extends java.lang.Object

The methods in this class take the data stored in the flight databases and parse it, creating containers of AirportSpecs and FlightSpecs. The contents of the containers can be accessed as many times as desired by calling airports() or flights().


Field Summary
private  Dictionary airportdict_
           
private  Sequence flightseq_
           
 
Constructor Summary
Parser(java.lang.String airport_filename, java.lang.String flights_filename)
          Parses the data files into containers, so the Parser object is ready to have airports() or flights() called on it.
 
Method Summary
 java.util.Enumeration airports()
          Get results of parsing the airport database
 java.util.Enumeration flights()
          Get results of parsing the flight database
static void main(java.lang.String[] args)
          A quick and dirty test to see that the above works.
private  Sequence parseFlights(java.lang.String file, Dictionary airports)
          Parse the flights file.
private  Dictionary parseGraph(java.lang.String file)
          Parse the graph (airport) file.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

airportdict_

private Dictionary airportdict_

flightseq_

private Sequence flightseq_
Constructor Detail

Parser

public Parser(java.lang.String airport_filename,
              java.lang.String flights_filename)
Parses the data files into containers, so the Parser object is ready to have airports() or flights() called on it.
Parameters:
airport_filename, - i.e. "/course/cs016/asgn/support/Flight/data/graph.dat"
flights_filename, - i.e. "/course/cs016/asgn/support/Flight/data/flight.dat"
Method Detail

airports

public java.util.Enumeration airports()
Get results of parsing the airport database
Returns:
Enumeration of AirportSpecs, built from the database

flights

public java.util.Enumeration flights()
Get results of parsing the flight database
Returns:
Enumeration of FlightSpecs, built from the database

parseGraph

private Dictionary parseGraph(java.lang.String file)
                       throws FlightException
Parse the graph (airport) file.
Parameters:
file - The filename of the graph description file to parse.
Returns:
A Dictionary of AirportSpecs.
Throws:
FlightException - if the file has invalid format.

parseFlights

private Sequence parseFlights(java.lang.String file,
                              Dictionary airports)
                       throws FlightException
Parse the flights file.
Parameters:
file - The filename of the graph description file to parse.
Returns:
A Sequence of FlightSpecs.
Throws:
FlightException - if the file has invalid format.

main

public static void main(java.lang.String[] args)
A quick and dirty test to see that the above works. Usage:
  java support.Flight.Parser <airports> <flights>
Where "airports" is the file with the list of airports, and "flights" is the file with the list of flights.
See Also: