// Path: route_lib/src/com/mapyst/campus/Campus.java
// public class Campus {
// 	public String name;
// 	public String acronym;
// 	public String description;
// 	public String directory_url;
// 	public String phone;
// 	public LatLngPoint location; //center of campus
// 
// 	public Building[] buildings;
// 	public Location_Type[] location_types;
// 
//     // TODO: This is never initialized
// 	public static FileHandlerInterface fileHandler;
// 
// 	public Floor getFloor(int buildingIndex, int floorIndex) {
// 		return buildings[buildingIndex].floors[floorIndex];
// 	}
// 
// 	public String getFloorFile (int buildingIndex, int floorIndex, String fileExtension) {
//         return buildingIndex + "-" + floorIndex + "." + fileExtension;
// 	}
// 
// 	public String getFloorFile (Building building, int floorIndex, String fileExtension) {
// 		int buildingIndex = findBuilding(building);
//         return buildingIndex + "-" + floorIndex + "." + fileExtension;
// 	}
// 
// 	public String getBuildingFile (int buildingIndex, String fileExtension) {
//         return buildingIndex + "." + fileExtension;
// 	}
// 
// 	public String getBuildingFile (Building building, String fileExtension) {
// 		int buildingIndex = findBuilding(building);
//         return buildingIndex + "." + fileExtension;
// 	}
// 
// 	private int findBuilding(Building building) {
// 		for (int i = 0; i < buildings.length; i++) {
// 			if (buildings[i] == building)
// 				return i;
// 		}
// 		return -1;
// 	}
// 
// 	public int parseFloorFromText(int buildingIndex, String floorText) {
// 		if (buildingIndex >= 0 && buildingIndex < buildings.length) {
// 			for (int i = 0; i < buildings[buildingIndex].floors.length; i++) {
// 				if (floorText.equals(getFloor(buildingIndex, i).name.toLowerCase()))
// 					return i;
// 			}
// 		}
// 		return -1;
// 	}
// 
// 	public Building[] getOutsideBuildings() {
// 		ArrayList<Building> outsideBuildings = new ArrayList<Building>();
// 		for (int i = 0; i < buildings.length; i++) {
// 			if (buildingIsOutside(i)) {
// 				outsideBuildings.add(buildings[i]);
// 			}
// 		}
// 		return outsideBuildings.toArray(new Building[outsideBuildings.size()]);
// 	}
// 
// 	public boolean buildingIsOutside(int building) {
//         return buildings[building].type == Building.OUTSIDE;
//     }
// 
// 	public int findLocationType(String type) {
// 		for (int i = 0; i < location_types.length; i++) {
// 			if (location_types[i].name.toLowerCase().equals(type.toLowerCase()))
// 				return i;
// 		}
// 		return -1;
// 	}
// 
// 	public Location[] getDirectionEndLocations() {
// 		ArrayList<Location> locations = new ArrayList<Location>();
//         for (Location_Type type : location_types) {
//             for (int j = 0; j < type.locations.length; j++) {
//                 Location location = type.locations[j];
//                 if (location.is_direction_end) {
//                     locations.add(location);
//                 }
//             }
//         }
// 
// 		return locations.toArray(new Location[locations.size()]);
// 	}
// 
// 	public Location getCampusLocation(String text) {
//         for (Location_Type type : location_types) {
//             for (int j = 0; j < type.locations.length; j++) {
//                 for (int k = 0; k < type.locations[j].names.length; k++) {
//                     if (text.equals(type.locations[j].names[k]))
//                         return type.locations[j];
//                 }
//             }
//         }
// 		return null;
// 	}
// 
// 	public static Campus load(int campusId) {
// 		fileHandler.setCampusId(campusId);
// 		
// 		Gson gson = new Gson();
// 		String json = "";
// 
// 		json = fileHandler.readCampusFile();
// 
//         return gson.fromJson(json, Campus.class);
// 	}
// }


import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
import com.mapyst.campus.Campus;
	/* This takes the info from the parseBuilding through the parse recursion */
	private ArrayList<InterpretedInfo> parseFloor(InterpretedInfo info, int numFloors) {
		InterpretedInfo newInfo = null;
		ArrayList<InterpretedInfo> infoList = new ArrayList<InterpretedInfo>();

		for (int i = 0; i < campus.buildings[info.buildingIndex].floors.length; i++) { 
			String floorName = campus.buildings[info.buildingIndex].floors[i].name.toLowerCase();
			//cut the floor name off the start of the input
			newInfo = tryFloorStart(info, floorName, i);
			
			if (newInfo != null) {
				infoList.addAll(parse(newInfo, STATE_ROOM));
			}
		}

		//this list is all possibilities for floors in a building (info.buildingIndex)
		return infoList;
	}	

	private InterpretedInfo parseRoom(InterpretedInfo info) {
		InterpretedInfo newInfo = new InterpretedInfo(info);
		int buildingIndex = info.buildingIndex;
		int floorIndex = info.floorIndex;
		
		if (loadedNodes.size() > 0)
			loadedNodes.clear();
		if (info.floorIndex == -1) {
			RouteFinder.loadBuilding(campus.buildings[buildingIndex], campus, loadedNodes);
		}
		else {
// Path: route_lib/src/com/mapyst/campus/Campus.java
// public class Campus {
// 	public String name;
// 	public String acronym;
// 	public String description;
// 	public String directory_url;
// 	public String phone;
// 	public LatLngPoint location; //center of campus
// 
// 	public Building[] buildings;
// 	public Location_Type[] location_types;
// 
//     // TODO: This is never initialized
// 	public static FileHandlerInterface fileHandler;
// 
// 	public Floor getFloor(int buildingIndex, int floorIndex) {
// 		return buildings[buildingIndex].floors[floorIndex];
// 	}
// 
// 	public String getFloorFile (int buildingIndex, int floorIndex, String fileExtension) {
//         return buildingIndex + "-" + floorIndex + "." + fileExtension;
// 	}
// 
// 	public String getFloorFile (Building building, int floorIndex, String fileExtension) {
// 		int buildingIndex = findBuilding(building);
//         return buildingIndex + "-" + floorIndex + "." + fileExtension;
// 	}
// 
// 	public String getBuildingFile (int buildingIndex, String fileExtension) {
//         return buildingIndex + "." + fileExtension;
// 	}
// 
// 	public String getBuildingFile (Building building, String fileExtension) {
// 		int buildingIndex = findBuilding(building);
//         return buildingIndex + "." + fileExtension;
// 	}
// 
// 	private int findBuilding(Building building) {
// 		for (int i = 0; i < buildings.length; i++) {
// 			if (buildings[i] == building)
// 				return i;
// 		}
// 		return -1;
// 	}
// 
// 	public int parseFloorFromText(int buildingIndex, String floorText) {
// 		if (buildingIndex >= 0 && buildingIndex < buildings.length) {
// 			for (int i = 0; i < buildings[buildingIndex].floors.length; i++) {
// 				if (floorText.equals(getFloor(buildingIndex, i).name.toLowerCase()))
// 					return i;
// 			}
// 		}
// 		return -1;
// 	}
// 
// 	public Building[] getOutsideBuildings() {
// 		ArrayList<Building> outsideBuildings = new ArrayList<Building>();
// 		for (int i = 0; i < buildings.length; i++) {
// 			if (buildingIsOutside(i)) {
// 				outsideBuildings.add(buildings[i]);
// 			}
// 		}
// 		return outsideBuildings.toArray(new Building[outsideBuildings.size()]);
// 	}
// 
// 	public boolean buildingIsOutside(int building) {
//         return buildings[building].type == Building.OUTSIDE;
//     }
// 
// 	public int findLocationType(String type) {
// 		for (int i = 0; i < location_types.length; i++) {
// 			if (location_types[i].name.toLowerCase().equals(type.toLowerCase()))
// 				return i;
// 		}
// 		return -1;
// 	}
// 
// 	public Location[] getDirectionEndLocations() {
// 		ArrayList<Location> locations = new ArrayList<Location>();
//         for (Location_Type type : location_types) {
//             for (int j = 0; j < type.locations.length; j++) {
//                 Location location = type.locations[j];
//                 if (location.is_direction_end) {
//                     locations.add(location);
//                 }
//             }
//         }
// 
// 		return locations.toArray(new Location[locations.size()]);
// 	}
// 
// 	public Location getCampusLocation(String text) {
//         for (Location_Type type : location_types) {
//             for (int j = 0; j < type.locations.length; j++) {
//                 for (int k = 0; k < type.locations[j].names.length; k++) {
//                     if (text.equals(type.locations[j].names[k]))
//                         return type.locations[j];
//                 }
//             }
//         }
// 		return null;
// 	}
// 
// 	public static Campus load(int campusId) {
// 		fileHandler.setCampusId(campusId);
// 		
// 		Gson gson = new Gson();
// 		String json = "";
// 
// 		json = fileHandler.readCampusFile();
// 
//         return gson.fromJson(json, Campus.class);
// 	}
// }


// Path: route_lib/src/com/mapyst/route/Interpreter.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
import com.mapyst.campus.Campus;

	/* This takes the info from the parseBuilding through the parse recursion */
	private ArrayList<InterpretedInfo> parseFloor(InterpretedInfo info, int numFloors) {
		InterpretedInfo newInfo = null;
		ArrayList<InterpretedInfo> infoList = new ArrayList<InterpretedInfo>();

		for (int i = 0; i < campus.buildings[info.buildingIndex].floors.length; i++) { 
			String floorName = campus.buildings[info.buildingIndex].floors[i].name.toLowerCase();
			//cut the floor name off the start of the input
			newInfo = tryFloorStart(info, floorName, i);
			
			if (newInfo != null) {
				infoList.addAll(parse(newInfo, STATE_ROOM));
			}
		}

		//this list is all possibilities for floors in a building (info.buildingIndex)
		return infoList;
	}	

	private InterpretedInfo parseRoom(InterpretedInfo info) {
		InterpretedInfo newInfo = new InterpretedInfo(info);
		int buildingIndex = info.buildingIndex;
		int floorIndex = info.floorIndex;
		
		if (loadedNodes.size() > 0)
			loadedNodes.clear();
		if (info.floorIndex == -1) {
			RouteFinder.loadBuilding(campus.buildings[buildingIndex], campus, loadedNodes);
		}
		else {
			DataParser.parseFile(campus.getFloorFile(buildingIndex, floorIndex, "ncmg"), loadedNodes, Campus.fileHandler);