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){
baseArray.add(airline);
}
reset();
}
/**

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

@ -13,6 +13,10 @@ public class AirportFilter extends Filter{
private ArrayList<Airport> baseArray;
private ArrayList<Airport> filteredList;
/**
* Constructor of the Airport FIlter.
* @param baseList
*/
public AirportFilter(ArrayList<Airport> baseList){
filteredList = 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){
String regexCode = "(?i).*"+name+".*";
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){
String regexCode = "(?i).*"+city+".*";
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){
String regexCode = "(?i).*"+country+".*";
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){
String regexCode = "(?i).*"+IATA_FFA+".*";
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){
String regexCode = "(?i).*"+ICAO+".*";
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){
String regexCode = ".*"+latitude+".*";
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){
String regexCode = ".*"+longitude+".*";
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){
String regexCode = ".*"+altitude+".*";
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){
String regexCode = "(?i).*"+timezone+".*";
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){
String regexCode = "(?i).*"+olson+".*";
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){
String regexCode = "(?i).*"+DST+".*";
int index = 0;
@ -154,6 +202,9 @@ public class AirportFilter extends Filter{
}
}
/**
* Resets the list to it original state before filter
*/
public void reset() {
filteredList = new ArrayList<Airport>();
for (Airport airport: filteredList){
@ -161,6 +212,10 @@ public class AirportFilter extends Filter{
}
}
/**
* gets the filtered list
* @return
*/
public ArrayList getFilteredData() {
return filteredList;
}
@ -170,8 +225,12 @@ public class AirportFilter extends Filter{
for (Airport airport: arrayList){
baseArray.add(airport);
}
reset();
}
/**
* prints the filtered list to console.
*/
public void printFilter(){
for (Airport airport: filteredList){
System.out.println(airport);

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

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

@ -819,6 +819,11 @@ public class Dataset {
addAirline(airlineToAdd);
}
/**
* Adds a Single Airline from the Program to the Database
* @param airlineToAdd
* @throws DataException
*/
public void addAirline(Airline airlineToAdd) throws DataException{
if (airlineToAdd.getIATA().length() != 0 && airlineToAdd.getIATA().length() != 2){
throw new DataException("IATA is either empty or length of 2 Letters.");
@ -866,6 +871,21 @@ public class Dataset {
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,
String altitude, String timezone, String DST, String olsonTz) throws DataException{
try{
@ -892,10 +912,19 @@ public class Dataset {
}
}
/**
* gets the name of the dataset.
* @return
*/
public String getName() {
return name;
}
/**
* Adds an Airport to the database and dataset.
* @param airportToAdd
* @throws DataException
*/
private void addAirport(Airport airportToAdd) throws DataException{
if (airportToAdd.getIATA_FFA().length() != 0 && airportToAdd.getIATA_FFA().length() != 3){
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())){
Connection c = 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())){
Connection c = null;
Statement stmt = null;
@ -1020,6 +1057,11 @@ public class Dataset {
addRoute(routeToAdd);
}
/**
* Adds a single route the dataset and database.
* @param routeToAdd
* @throws DataException
*/
public void addRoute(Route routeToAdd) throws DataException{
if (routeToAdd.getAirlineName().length() != 2 && routeToAdd.getAirlineName().length() != 3){
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);
}
/***
* 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{
addFlightPointToPath(point.getIndex(), point.getName(), point.getType(), point.getVia(), String.valueOf(point.getAltitude()),
String.valueOf( point.getLatitude()),String.valueOf(point.getLongitude()),
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{
addFlightPointToPath(point.getIndex(), point.getName(), point.getType(), point.getVia(), String.valueOf(point.getAltitude()),
String.valueOf( point.getLatitude()),String.valueOf(point.getLongitude()),
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,
String heading, String legDist, String totDist) throws DataException{
addFlightPointToPath(id, name, type, via, altitude, latitude, longitude, heading, legDist, totDist, -1);
@ -1302,6 +1369,10 @@ public class Dataset {
createDataLinks();
}
/**
* Deletes an AIrline from the dataset and database based on it index
* @param index
*/
public void deleteAirline(int index){
deleteAirline(airlines.get(index));
}
@ -1381,6 +1452,10 @@ public class Dataset {
createDataLinks();
}
/**
* Deletes an Airport from the dataset and database based on it index.
* @param index
*/
public void deleteAirport(int index){
deleteAirport(airports.get(index));
}
@ -1410,6 +1485,10 @@ public class Dataset {
createDataLinks();
}
/**
* Deletes a Route from the dataset and database based on its index
* @param index
*/
public void deleteRoute(int index){
deleteRoute(routes.get(index));
}
@ -1428,6 +1507,10 @@ public class Dataset {
try {
Class.forName("org.sqlite.JDBC");
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() + ";";
stmt = c.createStatement();
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){
deleteFlightPath(flightPaths.get(index));
}
@ -1470,54 +1557,107 @@ public class Dataset {
flightPath.getFlightPoints().remove(flightPoint);
}
/**
* deletes a single flight point from a given path.
* @param pathIndex
* @param pointIndex
*/
public void deleteFlightPoint(int pathIndex, int pointIndex){
deleteFlightPoint(flightPathDictionary.get(pathIndex).getFlightPoints().get(pointIndex), flightPathDictionary.get(pathIndex));
}
/**
* returns the airlines that are part of this dataset.
* @return
*/
public ArrayList<Airline> getAirlines() {
return airlines;
}
/**
* returns the airports that are associated with this dataset.
* @return
*/
public ArrayList<Airport> getAirports() {
return airports;
}
/**
* returns the routes that are associated with this dataset.
* @return
*/
public ArrayList<Route> getRoutes() {
return routes;
}
/**
* returns the flight paths that are associated with this dataset.
* @return
*/
public ArrayList<FlightPath> getFlightPaths() {
return flightPaths;
}
/**
* returns the countries that are associated with this dataset.
* @return
*/
public ArrayList<Country> getCountries() {
return countries;
}
/**
* returns the cities that are associate wit hthis dataset.
* @return
*/
public ArrayList<City> getCities() {
return cities;
}
/**
* returns a dictionary with the airlines that are associated with this datatset.
* @return
*/
public LinkedHashMap<String, Airline> getAirlineDictionary() {
return airlineDictionary;
}
/**
* returns a dictionary with the airports that are associated with this dataset.
* @return
*/
public LinkedHashMap<String, Airport> getAirportDictionary() {
return airportDictionary;
}
/**
* returns a route dictionary with the routes that are associated wit hthis dataset.
* @return
*/
public LinkedHashMap<String, Route> getRouteDictionary() {
return routeDictionary;
}
/**
* returns a flightpath dictionary with the flights that are associated with this dataset.
* @return
*/
public LinkedHashMap<Integer, FlightPath> getFlightPathDictionary() {
return flightPathDictionary;
}
/**
* returns a Country Dictionary with the COuntries that are associated with this dataset.
* @return
*/
public LinkedHashMap<String, Country> getCountryDictionary() {
return countryDictionary;
}
/**
* returns a City Dictionary with the Cities that are associated with this datatset.
* @return
*/
public LinkedHashMap<String, City> getCityDictionary() {
return cityDictionary;
}

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

@ -12,6 +12,10 @@ public class RouteFilter extends Filter{
private ArrayList<Route> baseArray;
private ArrayList<Route> filteredList;
/**
* Constructor which takes in a base List which all data is filtered from.
* @param baseList
*/
public RouteFilter(ArrayList<Route> baseList){
filteredList = 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){
String regexCode = "(?i).*"+airline+".*";
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){
String regexCode = "(?i).*"+airport+".*";
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){
String regexCode = "(?i).*"+airport+".*";
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){
String regexCode = "(?i).*"+code+".*";
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){
String regexCode = "(?i).*"+stops+".*";
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){
String regexCode = "(?i).*"+equipment+".*";
int index = 0;
@ -93,6 +121,9 @@ public class RouteFilter extends Filter{
}
}
/**
* resets the list to what the baselist.
*/
public void reset() {
filteredList = new ArrayList<Route>();
for (Route airline: filteredList){
@ -100,17 +131,29 @@ public class RouteFilter extends Filter{
}
}
/**
* get the filnal filtered array.
* @return
*/
public ArrayList getFilteredData() {
return filteredList;
}
/**
* sets the new baselist.
* @param arrayList
*/
public void setBaseList(ArrayList<Route> arrayList) {
baseArray = new ArrayList<Route>();
for (Route route: arrayList){
baseArray.add(route);
}
reset();
}
/**
* prints the filtered list to Console.
*/
public void printFilter(){
for (Route route: filteredList){
System.out.println(route);

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

@ -2,6 +2,7 @@ package seng202.group9.Controller;
/**
* 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 {
INITIAL(""), AIRLINE_SUMMARY("airline_summary.fxml"), AIRLINE_RAW_DATA("airline_raw_data.fxml"),
@ -12,10 +13,16 @@ public enum SceneCode {
private String filePath;
/**
* COnstructor for Scene
* @param filePath
*/
SceneCode(String filePath){
this.filePath = filePath;
}
/**
* gets the filepath of the specific scene
*/
public String getFilePath(){
return filePath;
}

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

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

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

Loading…
Cancel
Save