Added LOts of Brief Javadocs

main
YaFedImYaEatIm 9 years ago
parent 0672dfe86b
commit bb535a74bf

Binary file not shown.

@ -164,6 +164,7 @@ public class AirlineFilter extends Filter{
for (Airline airline: arrayList){ for (Airline airline: arrayList){
baseArray.add(airline); baseArray.add(airline);
} }
reset();
} }
/** /**

@ -7,15 +7,27 @@ import seng202.group9.Core.Airline;
import java.io.*; import java.io.*;
import java.util.ArrayList; import java.util.ArrayList;
/**
* Created By Fan-Wu Yang (fwy13)
*/
public class AirlineParser extends Parser { public class AirlineParser extends Parser {
String filePath = ""; String filePath = "";
ArrayList<Airline> parsedAirline; ArrayList<Airline> parsedAirline;
/**
* Constructor takes in a filepath and waits for the parse() call.
* @param filePath
*/
public AirlineParser(String filePath){ public AirlineParser(String filePath){
this.filePath = filePath; this.filePath = filePath;
parsedAirline = new ArrayList<Airline>(); parsedAirline = new ArrayList<Airline>();
} }
/**
* Parses data and then returns a message of number of successful parses.
* @return
* @throws DataException
*/
public String parse() throws DataException{ public String parse() throws DataException{
int successful = 0; int successful = 0;
int error = 0; int error = 0;
@ -122,6 +134,10 @@ public class AirlineParser extends Parser {
"Airlines With Errors: %2$d", successful, error); "Airlines With Errors: %2$d", successful, error);
} }
/**
* Returns the result of the Parse.
* @return
*/
public ArrayList<Airline> getResult(){ public ArrayList<Airline> getResult(){
return parsedAirline; return parsedAirline;
} }

@ -13,6 +13,10 @@ public class AirportFilter extends Filter{
private ArrayList<Airport> baseArray; private ArrayList<Airport> baseArray;
private ArrayList<Airport> filteredList; private ArrayList<Airport> filteredList;
/**
* Constructor of the Airport FIlter.
* @param baseList
*/
public AirportFilter(ArrayList<Airport> baseList){ public AirportFilter(ArrayList<Airport> baseList){
filteredList = new ArrayList<Airport>(); filteredList = new ArrayList<Airport>();
baseArray = new ArrayList<Airport>(); baseArray = new ArrayList<Airport>();
@ -22,6 +26,10 @@ public class AirportFilter extends Filter{
} }
} }
/**
* Filters the list by name Case Insensitive.
* @param name
*/
public void filterName(String name){ public void filterName(String name){
String regexCode = "(?i).*"+name+".*"; String regexCode = "(?i).*"+name+".*";
int index = 0; int index = 0;
@ -34,6 +42,10 @@ public class AirportFilter extends Filter{
} }
} }
/**
* filters the list by the city Case Insensitive.
* @param city
*/
public void filterCity(String city){ public void filterCity(String city){
String regexCode = "(?i).*"+city+".*"; String regexCode = "(?i).*"+city+".*";
int index = 0; int index = 0;
@ -46,6 +58,10 @@ public class AirportFilter extends Filter{
} }
} }
/**
* Filters the list by Country Case Insensitive.
* @param country
*/
public void filterCountry(String country){ public void filterCountry(String country){
String regexCode = "(?i).*"+country+".*"; String regexCode = "(?i).*"+country+".*";
int index = 0; int index = 0;
@ -58,6 +74,10 @@ public class AirportFilter extends Filter{
} }
} }
/**
* FIlters list by IATA/FFA Case Insensitive.
* @param IATA_FFA
*/
public void filterIATA_FFA(String IATA_FFA){ public void filterIATA_FFA(String IATA_FFA){
String regexCode = "(?i).*"+IATA_FFA+".*"; String regexCode = "(?i).*"+IATA_FFA+".*";
int index = 0; int index = 0;
@ -70,6 +90,10 @@ public class AirportFilter extends Filter{
} }
} }
/**
* Filters the list by ICAO Case Insensitive.
* @param ICAO
*/
public void filterICAO(String ICAO){ public void filterICAO(String ICAO){
String regexCode = "(?i).*"+ICAO+".*"; String regexCode = "(?i).*"+ICAO+".*";
int index = 0; int index = 0;
@ -82,6 +106,10 @@ public class AirportFilter extends Filter{
} }
} }
/**
* FIlters the list by latitude Case Insensitive.
* @param latitude
*/
public void filterLatitude(String latitude){ public void filterLatitude(String latitude){
String regexCode = ".*"+latitude+".*"; String regexCode = ".*"+latitude+".*";
int index = 0; int index = 0;
@ -94,6 +122,10 @@ public class AirportFilter extends Filter{
} }
} }
/**
* Filters the list by longitude Case Insensitive.
* @param longitude
*/
public void filterLongitude(String longitude){ public void filterLongitude(String longitude){
String regexCode = ".*"+longitude+".*"; String regexCode = ".*"+longitude+".*";
int index = 0; int index = 0;
@ -106,6 +138,10 @@ public class AirportFilter extends Filter{
} }
} }
/**
* FIlters the list by Altitude Case Insensitive.
* @param altitude
*/
public void filterAltitude(String altitude){ public void filterAltitude(String altitude){
String regexCode = ".*"+altitude+".*"; String regexCode = ".*"+altitude+".*";
int index = 0; int index = 0;
@ -118,6 +154,10 @@ public class AirportFilter extends Filter{
} }
} }
/**
* FIlters the list by Timezeon Case Insensitive.
* @param timezone
*/
public void filterTimezone(String timezone){ public void filterTimezone(String timezone){
String regexCode = "(?i).*"+timezone+".*"; String regexCode = "(?i).*"+timezone+".*";
int index = 0; int index = 0;
@ -130,6 +170,10 @@ public class AirportFilter extends Filter{
} }
} }
/**
* Filters the list by Olson Timezone format Case Insensitive.
* @param olson
*/
public void filterOlson(String olson){ public void filterOlson(String olson){
String regexCode = "(?i).*"+olson+".*"; String regexCode = "(?i).*"+olson+".*";
int index = 0; int index = 0;
@ -142,6 +186,10 @@ public class AirportFilter extends Filter{
} }
} }
/**
* Filters the list by DST Case Insensitive.
* @param DST
*/
public void filterDST(String DST){ public void filterDST(String DST){
String regexCode = "(?i).*"+DST+".*"; String regexCode = "(?i).*"+DST+".*";
int index = 0; int index = 0;
@ -154,6 +202,9 @@ public class AirportFilter extends Filter{
} }
} }
/**
* Resets the list to it original state before filter
*/
public void reset() { public void reset() {
filteredList = new ArrayList<Airport>(); filteredList = new ArrayList<Airport>();
for (Airport airport: filteredList){ for (Airport airport: filteredList){
@ -161,6 +212,10 @@ public class AirportFilter extends Filter{
} }
} }
/**
* gets the filtered list
* @return
*/
public ArrayList getFilteredData() { public ArrayList getFilteredData() {
return filteredList; return filteredList;
} }
@ -170,8 +225,12 @@ public class AirportFilter extends Filter{
for (Airport airport: arrayList){ for (Airport airport: arrayList){
baseArray.add(airport); baseArray.add(airport);
} }
reset();
} }
/**
* prints the filtered list to console.
*/
public void printFilter(){ public void printFilter(){
for (Airport airport: filteredList){ for (Airport airport: filteredList){
System.out.println(airport); System.out.println(airport);

@ -11,12 +11,19 @@ import java.io.*;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.util.ArrayList; import java.util.ArrayList;
/**
* created by Fan-Wu Yang(fwy13)
*/
public class AirportParser extends Parser { public class AirportParser extends Parser {
String filePath = ""; String filePath = "";
ArrayList<Airport> parsedAirports; ArrayList<Airport> parsedAirports;
ArrayList<City> parsedCities; ArrayList<City> parsedCities;
ArrayList<Country> parsedCountries; ArrayList<Country> parsedCountries;
/**
* Constructer is passed a file path which is then ready for the parse() call.
* @param filePath
*/
public AirportParser(String filePath){ public AirportParser(String filePath){
this.filePath = filePath; this.filePath = filePath;
parsedAirports = new ArrayList<Airport>(); parsedAirports = new ArrayList<Airport>();
@ -24,6 +31,11 @@ public class AirportParser extends Parser {
parsedCountries = new ArrayList<Country>(); parsedCountries = new ArrayList<Country>();
} }
/**
* Parses the given file and returns a succession message of how many entries were successfully parsed.
* @return
* @throws DataException
*/
public String parse() throws DataException{ public String parse() throws DataException{
int successful = 0; int successful = 0;
int error = 0; int error = 0;
@ -173,14 +185,26 @@ public class AirportParser extends Parser {
"Airports With Errors: %2$d", successful, error); "Airports With Errors: %2$d", successful, error);
} }
/**
* gets the parsed Airport results
* @return
*/
public ArrayList<Airport> getResult(){ public ArrayList<Airport> getResult(){
return parsedAirports; return parsedAirports;
} }
/**
* gets the parsed City restuls
* @return
*/
public ArrayList<City> getCityResult(){ public ArrayList<City> getCityResult(){
return parsedCities; return parsedCities;
} }
/**
* gets the parsed COuntry results
* @return
*/
public ArrayList<Country> getCountryResult(){ public ArrayList<Country> getCountryResult(){
return parsedCountries; return parsedCountries;
} }

@ -18,7 +18,7 @@ import seng202.group9.GUI.*;
/** /**
* Main Application frame of the Flight Data Analyser. * Main Application frame of the Flight Data Analyser.
* * Created By Fan-Wu Yang (fwy13)
*/ */
public class App extends Application public class App extends Application
{ {
@ -132,24 +132,45 @@ public class App extends Application
return (Initializable) loader.getController(); return (Initializable) loader.getController();
} }
/**
* Returns the Menu COntroller of the App.
* @return
*/
public MenuController getMenuController() { public MenuController getMenuController() {
return menuController; return menuController;
} }
/**
* returns the current dataset that the user is using.
* @return
*/
public Dataset getCurrentDataset(){ public Dataset getCurrentDataset(){
return currentDataset; return currentDataset;
} }
/**
* Creates new dataset.
* @param datasetName
* @throws DataException
*/
public void createDataset(String datasetName) throws DataException{ public void createDataset(String datasetName) throws DataException{
Dataset newDataset = new Dataset(datasetName, Dataset.createNew); Dataset newDataset = new Dataset(datasetName, Dataset.createNew);
datasets.add(newDataset); datasets.add(newDataset);
currentDataset = newDataset; currentDataset = newDataset;
} }
/**
* gets the amount of datasets the user has.
* @return
*/
public ArrayList<Dataset> getDatasets() { public ArrayList<Dataset> getDatasets() {
return datasets; return datasets;
} }
/**
* deletes a dataset.
* @param dataset
*/
public void deleteDataset(Dataset dataset){ public void deleteDataset(Dataset dataset){
dataset.deleteDataset(); dataset.deleteDataset();
datasets.remove(dataset); datasets.remove(dataset);

@ -819,6 +819,11 @@ public class Dataset {
addAirline(airlineToAdd); addAirline(airlineToAdd);
} }
/**
* Adds a Single Airline from the Program to the Database
* @param airlineToAdd
* @throws DataException
*/
public void addAirline(Airline airlineToAdd) throws DataException{ public void addAirline(Airline airlineToAdd) throws DataException{
if (airlineToAdd.getIATA().length() != 0 && airlineToAdd.getIATA().length() != 2){ if (airlineToAdd.getIATA().length() != 0 && airlineToAdd.getIATA().length() != 2){
throw new DataException("IATA is either empty or length of 2 Letters."); throw new DataException("IATA is either empty or length of 2 Letters.");
@ -866,6 +871,21 @@ public class Dataset {
createDataLinks(); createDataLinks();
} }
/**
* Adds a single Airport from the Program to the Database
* @param name
* @param city
* @param country
* @param IATA_FFA
* @param ICAO
* @param latitude
* @param longitude
* @param altitude
* @param timezone
* @param DST
* @param olsonTz
* @throws DataException
*/
public void addAirport(String name, String city, String country, String IATA_FFA, String ICAO, String latitude, String longitude, public void addAirport(String name, String city, String country, String IATA_FFA, String ICAO, String latitude, String longitude,
String altitude, String timezone, String DST, String olsonTz) throws DataException{ String altitude, String timezone, String DST, String olsonTz) throws DataException{
try{ try{
@ -892,10 +912,19 @@ public class Dataset {
} }
} }
/**
* gets the name of the dataset.
* @return
*/
public String getName() { public String getName() {
return name; return name;
} }
/**
* Adds an Airport to the database and dataset.
* @param airportToAdd
* @throws DataException
*/
private void addAirport(Airport airportToAdd) throws DataException{ private void addAirport(Airport airportToAdd) throws DataException{
if (airportToAdd.getIATA_FFA().length() != 0 && airportToAdd.getIATA_FFA().length() != 3){ if (airportToAdd.getIATA_FFA().length() != 0 && airportToAdd.getIATA_FFA().length() != 3){
throw new DataException("IATA/FFA either empty or 3 letters"); throw new DataException("IATA/FFA either empty or 3 letters");
@ -945,7 +974,11 @@ public class Dataset {
} }
} }
public void addCity(City city){ /**
* Adds a city to the dataset and database
* @param city
*/
private void addCity(City city){
if (!cityDictionary.containsKey(city.getName())){ if (!cityDictionary.containsKey(city.getName())){
Connection c = null; Connection c = null;
Statement stmt = null; Statement stmt = null;
@ -971,7 +1004,11 @@ public class Dataset {
} }
} }
public void addCountry(Country country){ /**
* Adds a Country to the dataset and database
* @param country
*/
private void addCountry(Country country){
if (!countryDictionary.containsKey(country.getName())){ if (!countryDictionary.containsKey(country.getName())){
Connection c = null; Connection c = null;
Statement stmt = null; Statement stmt = null;
@ -1020,6 +1057,11 @@ public class Dataset {
addRoute(routeToAdd); addRoute(routeToAdd);
} }
/**
* Adds a single route the dataset and database.
* @param routeToAdd
* @throws DataException
*/
public void addRoute(Route routeToAdd) throws DataException{ public void addRoute(Route routeToAdd) throws DataException{
if (routeToAdd.getAirlineName().length() != 2 && routeToAdd.getAirlineName().length() != 3){ if (routeToAdd.getAirlineName().length() != 2 && routeToAdd.getAirlineName().length() != 3){
throw new DataException("Airline ICAO code must be 2 or 3 letters."); throw new DataException("Airline ICAO code must be 2 or 3 letters.");
@ -1198,18 +1240,43 @@ public class Dataset {
flightPathDictionary.get(Integer.valueOf(id)).addFlightPoint(pointToAdd, index); flightPathDictionary.get(Integer.valueOf(id)).addFlightPoint(pointToAdd, index);
} }
/***
* Adds a single flight Point to an Existing FLight Path.
* @param point
* @param index
* @throws DataException
*/
public void addFlightPointToPath(FlightPoint point, int index) throws DataException{ public void addFlightPointToPath(FlightPoint point, int index) throws DataException{
addFlightPointToPath(point.getIndex(), point.getName(), point.getType(), point.getVia(), String.valueOf(point.getAltitude()), addFlightPointToPath(point.getIndex(), point.getName(), point.getType(), point.getVia(), String.valueOf(point.getAltitude()),
String.valueOf( point.getLatitude()),String.valueOf(point.getLongitude()), String.valueOf( point.getLatitude()),String.valueOf(point.getLongitude()),
String.valueOf(point.getHeading()), String.valueOf(point.getLegDistance()), String.valueOf(point.getTotalDistance()), index); String.valueOf(point.getHeading()), String.valueOf(point.getLegDistance()), String.valueOf(point.getTotalDistance()), index);
} }
/***
* Adds a single flight Point to an Existing FLight Path appended on the end of the list.
* @param point
* @throws DataException
*/
public void addFlightPointToPath(FlightPoint point) throws DataException{ public void addFlightPointToPath(FlightPoint point) throws DataException{
addFlightPointToPath(point.getIndex(), point.getName(), point.getType(), point.getVia(), String.valueOf(point.getAltitude()), addFlightPointToPath(point.getIndex(), point.getName(), point.getType(), point.getVia(), String.valueOf(point.getAltitude()),
String.valueOf( point.getLatitude()),String.valueOf(point.getLongitude()), String.valueOf( point.getLatitude()),String.valueOf(point.getLongitude()),
String.valueOf(point.getHeading()), String.valueOf(point.getLegDistance()), String.valueOf(point.getTotalDistance()), -1); String.valueOf(point.getHeading()), String.valueOf(point.getLegDistance()), String.valueOf(point.getTotalDistance()), -1);
} }
/**
* Adds a single flight Point to an Existing FLight Path appended on the end of the list.
* @param id
* @param name
* @param type
* @param via
* @param altitude
* @param latitude
* @param longitude
* @param heading
* @param legDist
* @param totDist
* @throws DataException
*/
public void addFlightPointToPath(int id, String name, String type, String via, String altitude, String latitude, String longitude, public void addFlightPointToPath(int id, String name, String type, String via, String altitude, String latitude, String longitude,
String heading, String legDist, String totDist) throws DataException{ String heading, String legDist, String totDist) throws DataException{
addFlightPointToPath(id, name, type, via, altitude, latitude, longitude, heading, legDist, totDist, -1); addFlightPointToPath(id, name, type, via, altitude, latitude, longitude, heading, legDist, totDist, -1);
@ -1302,6 +1369,10 @@ public class Dataset {
createDataLinks(); createDataLinks();
} }
/**
* Deletes an AIrline from the dataset and database based on it index
* @param index
*/
public void deleteAirline(int index){ public void deleteAirline(int index){
deleteAirline(airlines.get(index)); deleteAirline(airlines.get(index));
} }
@ -1381,6 +1452,10 @@ public class Dataset {
createDataLinks(); createDataLinks();
} }
/**
* Deletes an Airport from the dataset and database based on it index.
* @param index
*/
public void deleteAirport(int index){ public void deleteAirport(int index){
deleteAirport(airports.get(index)); deleteAirport(airports.get(index));
} }
@ -1410,6 +1485,10 @@ public class Dataset {
createDataLinks(); createDataLinks();
} }
/**
* Deletes a Route from the dataset and database based on its index
* @param index
*/
public void deleteRoute(int index){ public void deleteRoute(int index){
deleteRoute(routes.get(index)); deleteRoute(routes.get(index));
} }
@ -1428,6 +1507,10 @@ public class Dataset {
try { try {
Class.forName("org.sqlite.JDBC"); Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:res/userdb.db"); c = DriverManager.getConnection("jdbc:sqlite:res/userdb.db");
stmt = c.createStatement();
String deletePointsQuery = "DELETE FROM `"+this.name+"_FlightPoints` WHERE `Index_ID` = "+flightPath.getID()+ ";";
stmt.execute(deletePointsQuery);
stmt.close();
String deleteQuery = "DELETE FROM `"+this.name+"_Flight_Path` WHERE `Path_ID` = " + flightPath.getID() + ";"; String deleteQuery = "DELETE FROM `"+this.name+"_Flight_Path` WHERE `Path_ID` = " + flightPath.getID() + ";";
stmt = c.createStatement(); stmt = c.createStatement();
stmt.execute(deleteQuery); stmt.execute(deleteQuery);
@ -1444,6 +1527,10 @@ public class Dataset {
} }
} }
/**
* Deletes a flight path from the database based on its index.
* @param index
*/
public void deleteFlightPath(int index){ public void deleteFlightPath(int index){
deleteFlightPath(flightPaths.get(index)); deleteFlightPath(flightPaths.get(index));
} }
@ -1470,54 +1557,107 @@ public class Dataset {
flightPath.getFlightPoints().remove(flightPoint); flightPath.getFlightPoints().remove(flightPoint);
} }
/**
* deletes a single flight point from a given path.
* @param pathIndex
* @param pointIndex
*/
public void deleteFlightPoint(int pathIndex, int pointIndex){ public void deleteFlightPoint(int pathIndex, int pointIndex){
deleteFlightPoint(flightPathDictionary.get(pathIndex).getFlightPoints().get(pointIndex), flightPathDictionary.get(pathIndex)); deleteFlightPoint(flightPathDictionary.get(pathIndex).getFlightPoints().get(pointIndex), flightPathDictionary.get(pathIndex));
} }
/**
* returns the airlines that are part of this dataset.
* @return
*/
public ArrayList<Airline> getAirlines() { public ArrayList<Airline> getAirlines() {
return airlines; return airlines;
} }
/**
* returns the airports that are associated with this dataset.
* @return
*/
public ArrayList<Airport> getAirports() { public ArrayList<Airport> getAirports() {
return airports; return airports;
} }
/**
* returns the routes that are associated with this dataset.
* @return
*/
public ArrayList<Route> getRoutes() { public ArrayList<Route> getRoutes() {
return routes; return routes;
} }
/**
* returns the flight paths that are associated with this dataset.
* @return
*/
public ArrayList<FlightPath> getFlightPaths() { public ArrayList<FlightPath> getFlightPaths() {
return flightPaths; return flightPaths;
} }
/**
* returns the countries that are associated with this dataset.
* @return
*/
public ArrayList<Country> getCountries() { public ArrayList<Country> getCountries() {
return countries; return countries;
} }
/**
* returns the cities that are associate wit hthis dataset.
* @return
*/
public ArrayList<City> getCities() { public ArrayList<City> getCities() {
return cities; return cities;
} }
/**
* returns a dictionary with the airlines that are associated with this datatset.
* @return
*/
public LinkedHashMap<String, Airline> getAirlineDictionary() { public LinkedHashMap<String, Airline> getAirlineDictionary() {
return airlineDictionary; return airlineDictionary;
} }
/**
* returns a dictionary with the airports that are associated with this dataset.
* @return
*/
public LinkedHashMap<String, Airport> getAirportDictionary() { public LinkedHashMap<String, Airport> getAirportDictionary() {
return airportDictionary; return airportDictionary;
} }
/**
* returns a route dictionary with the routes that are associated wit hthis dataset.
* @return
*/
public LinkedHashMap<String, Route> getRouteDictionary() { public LinkedHashMap<String, Route> getRouteDictionary() {
return routeDictionary; return routeDictionary;
} }
/**
* returns a flightpath dictionary with the flights that are associated with this dataset.
* @return
*/
public LinkedHashMap<Integer, FlightPath> getFlightPathDictionary() { public LinkedHashMap<Integer, FlightPath> getFlightPathDictionary() {
return flightPathDictionary; return flightPathDictionary;
} }
/**
* returns a Country Dictionary with the COuntries that are associated with this dataset.
* @return
*/
public LinkedHashMap<String, Country> getCountryDictionary() { public LinkedHashMap<String, Country> getCountryDictionary() {
return countryDictionary; return countryDictionary;
} }
/**
* returns a City Dictionary with the Cities that are associated with this datatset.
* @return
*/
public LinkedHashMap<String, City> getCityDictionary() { public LinkedHashMap<String, City> getCityDictionary() {
return cityDictionary; return cityDictionary;
} }

@ -5,15 +5,27 @@ import seng202.group9.Core.FlightPoint;
import java.io.*; import java.io.*;
import java.util.ArrayList; import java.util.ArrayList;
/**
* Created by Fan-Wu Yang(fwy13)
*/
public class FlightPathParser extends Parser { public class FlightPathParser extends Parser {
String filePath = ""; String filePath = "";
ArrayList<FlightPoint> parsedPoints; ArrayList<FlightPoint> parsedPoints;
/**
* Constructor for parsing flight paths, reads in a file and gets it ready for the parse() call.
* @param filePath
*/
public FlightPathParser(String filePath){ public FlightPathParser(String filePath){
this.filePath = filePath; this.filePath = filePath;
parsedPoints = new ArrayList<FlightPoint>(); parsedPoints = new ArrayList<FlightPoint>();
} }
/**
* Parses the file that and returns a success message.
* @return
* @throws DataException
*/
public String parse() throws DataException{ public String parse() throws DataException{
int successful = 0; int successful = 0;
int error = 0; int error = 0;
@ -151,6 +163,10 @@ public class FlightPathParser extends Parser {
"Flight Points With Errors: %2$d", successful, error); "Flight Points With Errors: %2$d", successful, error);
} }
/**
* returns the resultant Flight points that are successfully parsed.
* @return
*/
public ArrayList<FlightPoint> getResult(){ public ArrayList<FlightPoint> getResult(){
return parsedPoints; return parsedPoints;
} }

@ -12,6 +12,10 @@ public class RouteFilter extends Filter{
private ArrayList<Route> baseArray; private ArrayList<Route> baseArray;
private ArrayList<Route> filteredList; private ArrayList<Route> filteredList;
/**
* Constructor which takes in a base List which all data is filtered from.
* @param baseList
*/
public RouteFilter(ArrayList<Route> baseList){ public RouteFilter(ArrayList<Route> baseList){
filteredList = new ArrayList<Route>(); filteredList = new ArrayList<Route>();
baseArray = new ArrayList<Route>(); baseArray = new ArrayList<Route>();
@ -21,6 +25,10 @@ public class RouteFilter extends Filter{
} }
} }
/**
* Filters the list by the Airline Case Insensitive.
* @param airline
*/
public void filterAirline(String airline){ public void filterAirline(String airline){
String regexCode = "(?i).*"+airline+".*"; String regexCode = "(?i).*"+airline+".*";
int index = 0; int index = 0;
@ -33,6 +41,10 @@ public class RouteFilter extends Filter{
} }
} }
/**
* filters list by Airport Case Insensitive.
* @param airport
*/
public void filterSourceAirport(String airport){ public void filterSourceAirport(String airport){
String regexCode = "(?i).*"+airport+".*"; String regexCode = "(?i).*"+airport+".*";
int index = 0; int index = 0;
@ -45,6 +57,10 @@ public class RouteFilter extends Filter{
} }
} }
/**
* filters lsit by destination airport Case Insensitive.
* @param airport
*/
public void filterDestinationAirport(String airport){ public void filterDestinationAirport(String airport){
String regexCode = "(?i).*"+airport+".*"; String regexCode = "(?i).*"+airport+".*";
int index = 0; int index = 0;
@ -57,6 +73,10 @@ public class RouteFilter extends Filter{
} }
} }
/**
* filters the list by its codeshare Case Insensitive.
* @param code
*/
public void filterCodeshare(String code){ public void filterCodeshare(String code){
String regexCode = "(?i).*"+code+".*"; String regexCode = "(?i).*"+code+".*";
int index = 0; int index = 0;
@ -69,6 +89,10 @@ public class RouteFilter extends Filter{
} }
} }
/**
* filters the list by how many stops it does Case Insensitive, Doesn't have to match exactly.
* @param stops
*/
public void filterDestinationStops(String stops){ public void filterDestinationStops(String stops){
String regexCode = "(?i).*"+stops+".*"; String regexCode = "(?i).*"+stops+".*";
int index = 0; int index = 0;
@ -81,6 +105,10 @@ public class RouteFilter extends Filter{
} }
} }
/**
* filters the list by the equipment used for the route Case Insensitive.
* @param equipment
*/
public void filterEquipment(String equipment){ public void filterEquipment(String equipment){
String regexCode = "(?i).*"+equipment+".*"; String regexCode = "(?i).*"+equipment+".*";
int index = 0; int index = 0;
@ -93,6 +121,9 @@ public class RouteFilter extends Filter{
} }
} }
/**
* resets the list to what the baselist.
*/
public void reset() { public void reset() {
filteredList = new ArrayList<Route>(); filteredList = new ArrayList<Route>();
for (Route airline: filteredList){ for (Route airline: filteredList){
@ -100,17 +131,29 @@ public class RouteFilter extends Filter{
} }
} }
/**
* get the filnal filtered array.
* @return
*/
public ArrayList getFilteredData() { public ArrayList getFilteredData() {
return filteredList; return filteredList;
} }
/**
* sets the new baselist.
* @param arrayList
*/
public void setBaseList(ArrayList<Route> arrayList) { public void setBaseList(ArrayList<Route> arrayList) {
baseArray = new ArrayList<Route>(); baseArray = new ArrayList<Route>();
for (Route route: arrayList){ for (Route route: arrayList){
baseArray.add(route); baseArray.add(route);
} }
reset();
} }
/**
* prints the filtered list to Console.
*/
public void printFilter(){ public void printFilter(){
for (Route route: filteredList){ for (Route route: filteredList){
System.out.println(route); System.out.println(route);

@ -5,15 +5,27 @@ import seng202.group9.Core.Route;
import java.io.*; import java.io.*;
import java.util.ArrayList; import java.util.ArrayList;
/**
* Created By Fan-Wu Yang(fwy13)
*/
public class RouteParser extends Parser { public class RouteParser extends Parser {
String filePath = ""; String filePath = "";
ArrayList<Route> parsedRoutes; ArrayList<Route> parsedRoutes;
/**
* Constructor for Route Parser takes in a file and gets ready for the parse() call.
* @param filePath
*/
public RouteParser(String filePath){ public RouteParser(String filePath){
this.filePath = filePath; this.filePath = filePath;
parsedRoutes = new ArrayList<Route>(); parsedRoutes = new ArrayList<Route>();
} }
/**
* parses the given file for ROutes.
* @return
* @throws DataException
*/
public String parse() throws DataException{ public String parse() throws DataException{
int successful = 0; int successful = 0;
int error = 0; int error = 0;
@ -153,6 +165,10 @@ public class RouteParser extends Parser {
"Routes With Errors: %2$d", successful, error); "Routes With Errors: %2$d", successful, error);
} }
/**
* returns the final successful results.
* @return
*/
public ArrayList<Route> getResult(){ public ArrayList<Route> getResult(){
return parsedRoutes; return parsedRoutes;
} }

@ -2,6 +2,7 @@ package seng202.group9.Controller;
/** /**
* Created by fwy13 on 16/09/16. * Created by fwy13 on 16/09/16.
* SceneCode enum is used for Serialization of sessions as well as changing the GUI state from one to the other.
*/ */
public enum SceneCode { public enum SceneCode {
INITIAL(""), AIRLINE_SUMMARY("airline_summary.fxml"), AIRLINE_RAW_DATA("airline_raw_data.fxml"), INITIAL(""), AIRLINE_SUMMARY("airline_summary.fxml"), AIRLINE_RAW_DATA("airline_raw_data.fxml"),
@ -12,10 +13,16 @@ public enum SceneCode {
private String filePath; private String filePath;
/**
* COnstructor for Scene
* @param filePath
*/
SceneCode(String filePath){ SceneCode(String filePath){
this.filePath = filePath; this.filePath = filePath;
} }
/**
* gets the filepath of the specific scene
*/
public String getFilePath(){ public String getFilePath(){
return filePath; return filePath;
} }

@ -4,23 +4,39 @@ import java.io.Serializable;
/** /**
* Created by fwy13 on 16/09/16. * Created by fwy13 on 16/09/16.
* Users last session state is store here.
*/ */
public class Session implements Serializable { public class Session implements Serializable {
private SceneCode sceneDisplayed; private SceneCode sceneDisplayed;
/**
* Constructor for a new session
*/
public Session(){ public Session(){
//blank constructor //blank constructor
this.sceneDisplayed = SceneCode.INITIAL; this.sceneDisplayed = SceneCode.INITIAL;
} }
/**
* Constructor for a previous session.
* @param scene
*/
public Session(SceneCode scene){ public Session(SceneCode scene){
this.sceneDisplayed = scene; this.sceneDisplayed = scene;
} }
/**
* changes the serialized scene.
* @param sceneDisplayed
*/
public void setSceneDisplayed(SceneCode sceneDisplayed) { public void setSceneDisplayed(SceneCode sceneDisplayed) {
this.sceneDisplayed = sceneDisplayed; this.sceneDisplayed = sceneDisplayed;
} }
/**
* gets the last scene displayed.
* @return
*/
public SceneCode getSceneDisplayed() { public SceneCode getSceneDisplayed() {
return sceneDisplayed; return sceneDisplayed;
} }

@ -4,6 +4,9 @@ import seng202.group9.Controller.DataException;
import java.util.ArrayList; import java.util.ArrayList;
/**
* Created By Fan-Wu Yang.
*/
public class City { public class City {
private String name; private String name;
private String country; private String country;

@ -4,6 +4,9 @@ import seng202.group9.Controller.DataException;
import java.util.ArrayList; import java.util.ArrayList;
/**
* Created By Fan-Wu Yang
*/
public class FlightPath { public class FlightPath {
private int ID; private int ID;
private ArrayList<FlightPoint> flightPoints; private ArrayList<FlightPoint> flightPoints;

Loading…
Cancel
Save