import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Locale;
import org.junit.Assert;
+ "<Route><RouteNo>4</RouteNo><DirectionID>1</DirectionID><Direction>Northbound</Direction>"
+ "<RouteHeading>Rideau C / Ctr Rideau</RouteHeading>"
+ "<Trips>"
- + "<Trip><TripDestination>Rideau Centre / Centre Rideau</TripDestination><TripStartTime>19:00</TripStartTime>"
+ + "<Trip ghost=\"false\"><TripDestination>Rideau Centre / Centre Rideau</TripDestination><TripStartTime>19:00</TripStartTime>"
+ "<AdjustedScheduleTime>16</AdjustedScheduleTime><AdjustmentAge>0.45</AdjustmentAge><LastTripOfSchedule/>"
+ "<BusType>4LB - IN</BusType><Latitude>45.408957</Latitude><Longitude>-75.664125</Longitude>"
+ "<GPSSpeed>66.4</GPSSpeed></Trip>"
- + "<Trip><TripDestination>Rideau Centre / Centre Rideau</TripDestination>"
+ + "<Trip ghost=\"true\"><TripDestination>Rideau Centre / Centre Rideau</TripDestination>"
+ "<TripStartTime>19:30</TripStartTime><AdjustedScheduleTime>40</AdjustedScheduleTime><AdjustmentAge>-1</AdjustmentAge>"
+ "<LastTripOfSchedule/><BusType>4LB - IN</BusType><Latitude/><Longitude/><GPSSpeed/></Trip>"
- + "<Trip><TripDestination>Rideau Centre / Centre Rideau</TripDestination><TripStartTime>20:00</TripStartTime>"
+ + "<Trip ghost=\"true\"><TripDestination>Rideau Centre / Centre Rideau</TripDestination><TripStartTime>20:00</TripStartTime>"
+ "<AdjustedScheduleTime>70</AdjustedScheduleTime><AdjustmentAge>-1</AdjustmentAge><LastTripOfSchedule/>"
+ "<BusType>4LB - IN</BusType><Latitude/><Longitude/><GPSSpeed/></Trip>"
+ "</Trips></Route></Routes></GetRouteSummaryForStopResult></GetRouteSummaryForStopResponse>"
@Override
public void endContents(String uri, String localName, String qName,
- String chars, Attributes attr) throws XmlParseException
+ String chars) throws XmlParseException
{
Assert.fail("Should not have any contents to end.");
}
@Override
public void endContents(String uri, String localName, String qName,
- String chars, Attributes attr) throws XmlParseException
+ String chars) throws XmlParseException
{
if (localName.equals(ONE)) {
m_one = chars;
public RouteParse getRoute(int idx) { return m_routes.get(idx); }
@Override
- public void endContents(String uri, String localName, String qName,
- String chars, Attributes attr) throws XmlParseException
+ public void endContents(String uri, String localName, String qName, String chars) throws XmlParseException
{
if (localName.equals(STOP_NO)) {
m_stopNo = Integer.parseInt(chars);
@Override
public void endContents(String uri, String localName, String qName,
- String chars, Attributes attr) throws XmlParseException
+ String chars) throws XmlParseException
{
if (localName.equals(ROUTE_NO)) {
m_routeNo = Integer.parseInt(chars);
}
public static class TripParse extends ParseResult {
private static final String TRIP = "Trip";
+ private static final String GHOST = "ghost";
private static final String TRIP_DEST = "TripDestination";
private static final String TRIP_START = "TripStartTime";
private static final String ADJ_SCHED_TIME = "AdjustedScheduleTime";
// Data gleaned from parsing
String m_dest;
String m_startTime;
- int m_adjSchedTime;;
+ int m_adjSchedTime;
+ boolean m_ghost;
public TripParse() {
super(TRIP, INTERNAL, EXTERNAL);
m_dest = m_startTime = null;
m_adjSchedTime = 0;
+ m_ghost = false;
}
public String getDestination() { return m_dest; }
public String getStartTime() { return m_startTime; }
public int getAdjustedScheduleTime() { return m_adjSchedTime; }
+ public boolean ghostAttrSet() { return m_ghost; }
+
+ @Override
+ public void handleMainAttributes(Attributes attr) throws MissingAttributeException
+ {
+ String scratch = this.getRequiredAttr(TRIP, attr, GHOST);
+ Assert.assertNotNull(scratch);
+ m_ghost = scratch.toLowerCase(Locale.CANADA).equals("true");
+ }
@Override
public void endContents(String uri, String localName, String qName,
- String chars, Attributes attr) throws XmlParseException
+ String chars) throws XmlParseException
{
if (localName.equals(TRIP_DEST)) {
m_dest = chars;
Assert.assertEquals("Rideau Centre / Centre Rideau", tp.getDestination());
Assert.assertEquals("19:00", tp.getStartTime());
Assert.assertEquals(16, tp.getAdjustedScheduleTime());
+ Assert.assertEquals(false, tp.ghostAttrSet());
tp = rp.getTrip(1);
Assert.assertNotNull(tp);
Assert.assertEquals("Rideau Centre / Centre Rideau", tp.getDestination());
Assert.assertEquals("19:30", tp.getStartTime());
Assert.assertEquals(40, tp.getAdjustedScheduleTime());
+ Assert.assertEquals(true, tp.ghostAttrSet());
tp = rp.getTrip(2);
Assert.assertNotNull(tp);
Assert.assertEquals("Rideau Centre / Centre Rideau", tp.getDestination());
Assert.assertEquals("20:00", tp.getStartTime());
Assert.assertEquals(70, tp.getAdjustedScheduleTime());
+ Assert.assertEquals(true, tp.ghostAttrSet());
}
finally {
if (null != bais) {