Commit 2dbc34cb authored by Zachary Seguin's avatar Zachary Seguin

WIP

parent e3f7802c
package ca.zacharyseguin.gtfs;
import ca.zacharyseguin.util.io.Field;
/**
* Specifies dates of service.
*
* @author Zachary Seguin (development@zacharyseguin.ca)
* @version GTFS - June 20, 2012
*/
public class Calendar
{
@Field("service_id")
private String serviceId;
@Field("monday")
private boolean monday;
@Field("tuesday")
private boolean tuesday;
@Field("wednesday")
private boolean wednesday;
@Field("thursday")
private boolean thursday;
@Field("friday")
private boolean friday;
@Field("saturday")
private boolean saturday;
@Field("sunday")
private boolean sunday;
@Field("start_date")
private String startDate;
@Field("end_date")
private String endDate;
public Calendar()
{
this.serviceId = "";
this.monday = false;
this.tuesday = false;
this.wednesday = false;
this.thursday = false;
this.friday = false;
this.saturday = false;
this.sunday = false;
this.startDate = null;
this.endDate = null;
}// End of constructor method
public String getServiceId()
{
return serviceId;
}
public void setServiceId(String serviceId)
{
this.serviceId = serviceId;
}
public boolean hasMonday()
{
return monday;
}
public void setMonday(boolean monday)
{
this.monday = monday;
}
public boolean hasTuesday()
{
return tuesday;
}
public void setTuesday(boolean tuesday)
{
this.tuesday = tuesday;
}
public boolean hasWednesday()
{
return wednesday;
}
public void setWednesday(boolean wednesday)
{
this.wednesday = wednesday;
}
public boolean hasThursday()
{
return thursday;
}
public void setThursday(boolean thursday)
{
this.thursday = thursday;
}
public boolean hasFriday()
{
return friday;
}
public void setFriday(boolean friday)
{
this.friday = friday;
}
public boolean hasSaturday()
{
return saturday;
}
public void setSaturday(boolean saturday)
{
this.saturday = saturday;
}
public boolean hasSunday()
{
return sunday;
}
public void setSunday(boolean sunday)
{
this.sunday = sunday;
}
public String getStartDate()
{
return startDate;
}
public void setStartDate(String startDate)
{
this.startDate = startDate;
}
public String getEndDate()
{
return endDate;
}
public void setEndDate(String endDate)
{
this.endDate = endDate;
}
}// End of class
package ca.zacharyseguin.gtfs;
import ca.zacharyseguin.util.io.Field;
/**
* Enable/Disable regular service on a date,
* or specify service for a date.
*
* @author Zachary Seguin (development@zacharyseguin.ca)
* @version GTFS - June 20, 2012
*/
public class CalendarDate
{
@Field("service_id")
private String serviceId;
@Field("date")
private String date;
@Field("exception_type")
private ExceptionType exceptionType;
public CalendarDate()
{
this.serviceId = null;
this.date = null;
this.exceptionType = ExceptionType.UNKNOWN;
}// End of constructor method
public String getServiceId()
{
return serviceId;
}
public void setServiceId(String serviceId)
{
this.serviceId = serviceId;
}
public String getDate()
{
return date;
}
public void setDate(String date)
{
this.date = date;
}
public ExceptionType getExceptionType()
{
return exceptionType;
}
public void setExceptionType(ExceptionType exceptionType)
{
this.exceptionType = exceptionType;
}
}// End of class
package ca.zacharyseguin.gtfs;
import ca.zacharyseguin.util.io.EnumValue;
import ca.zacharyseguin.util.io.UnknownEnumValue;
/**
* Service exception type.
*/
public enum ExceptionType
{
@EnumValue(1)
ADDED,
@EnumValue(2)
REMOVED,
@UnknownEnumValue
UNKNOWN
}// End of enum
......@@ -13,11 +13,15 @@ public class Main
List<Stop> stops = CSVParser.parse("/Users/zachary/tmp/grt_gtfs/stops.txt", Stop.class);
List<Trip> trips = CSVParser.parse("/Users/zachary/tmp/grt_gtfs/trips.txt", Trip.class);
List<StopTime> stopTimes = CSVParser.parse("/Users/zachary/tmp/grt_gtfs/stop_times.txt", StopTime.class);
List<Calendar> calendar = CSVParser.parse("/Users/zachary/tmp/grt_gtfs/calendar.txt", Calendar.class);
List<CalendarDate> calendarDates = CSVParser.parse("/Users/zachary/tmp/grt_gtfs/calendar_dates.txt", CalendarDate.class);
System.out.println("Loaded " + agencies.size() + " agencies.");
System.out.println("Loaded " + routes.size() + " routes.");
System.out.println("Loaded " + stops.size() + " stops.");
System.out.println("Loaded " + trips.size() + " trips.");
System.out.println("Loaded " + stopTimes.size() + " stop times.");
System.out.println("Loaded " + calendar.size() + " calendar services.");
System.out.println("Loaded " + calendarDates.size() + " calendar dates.");
}// End of main method
}// End of class
\ No newline at end of file
......@@ -76,6 +76,7 @@ public class CSVParser
{
try
{
// TODO: Better way to handle blank number, possibly not setting value
if (row[x].equals(""))
row[x] = "0";
......@@ -84,6 +85,8 @@ public class CSVParser
setter.method.invoke(object, Integer.parseInt(row[x]));
else if (setter.type == double.class)
setter.method.invoke(object, Double.parseDouble(row[x]));
else if (setter.type == boolean.class)
setter.method.invoke(object, row[x].equals("1"));
}// End of try
catch (InvocationTargetException e)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment