1 |
|
package net.jaekl.frank.octranspo; |
2 |
|
|
3 |
|
import java.util.ArrayList; |
4 |
|
import net.jaekl.qd.xml.ParseResult; |
5 |
|
import net.jaekl.qd.xml.XmlParseException; |
6 |
|
|
7 |
Block: 1/1 |
public class Route extends ParseResult { |
8 |
|
static final String ROUTE = "Route"; |
9 |
|
|
10 |
|
static final String ROUTE_NO = "RouteNo"; |
11 |
|
static final String DIRECTION_ID = "DirectionID"; |
12 |
|
static final String DIRECTION = "Direction"; |
13 |
|
static final String ROUTE_HEADING = "RouteHeading"; |
14 |
|
static final String ROUTE_LABEL = "RouteLabel"; |
15 |
|
static final String TRIPS = "Trips"; |
16 |
|
|
17 |
|
static final String TRIP = "Trip"; |
18 |
|
|
19 |
Block: 1/1 |
static final String[] INTERNAL = { ROUTE_NO, DIRECTION_ID, DIRECTION, ROUTE_HEADING, ROUTE_LABEL, TRIPS }; |
20 |
|
static final Object[][] EXTERNAL = { { TRIP, Trip.class } }; |
21 |
|
|
22 |
|
int m_routeNo; |
23 |
|
int m_directionID; |
24 |
|
String m_direction; |
25 |
|
String m_routeHeading; |
26 |
|
ArrayList<Trip> m_trips; |
27 |
|
|
28 |
|
public Route() { |
29 |
Block: 1/1 |
super(ROUTE, INTERNAL, EXTERNAL); |
30 |
|
m_routeNo = 0; |
31 |
|
m_directionID = 0; |
32 |
|
m_direction = ""; |
33 |
|
m_routeHeading = ""; |
34 |
|
m_trips = new ArrayList<Trip>(); |
35 |
|
} |
36 |
|
|
37 |
Block: 1/1 |
public int getRouteNo() { return m_routeNo; } |
38 |
Block: 1/1 |
public int getDirectionID() { return m_directionID; } |
39 |
Block: 1/1 |
public String getDirection() { return m_direction; } |
40 |
Block: 1/1 |
public String getRouteHeading() { return m_routeHeading; } |
41 |
Block: 1/1 |
public int getNumTrips() { return m_trips.size(); } |
42 |
Block: 1/1 |
public Trip getTrip(int idx) { return new Trip(m_trips.get(idx)); } |
43 |
|
|
44 |
|
@Override |
45 |
|
public void endContents(String uri, String localName, String qName, String chars) throws XmlParseException |
46 |
|
{ |
47 |
Block: 1/1 |
if (ROUTE_NO.equals(localName)) { |
48 |
Block: 1/1 Branch: 1/1 |
m_routeNo = Integer.parseInt(chars); |
49 |
|
} |
50 |
Block: 1/1 Branch: 1/1 |
else if (DIRECTION_ID.equals(localName)) { |
51 |
Block: 1/1 Branch: 1/1 |
m_directionID = Integer.parseInt(chars); |
52 |
|
} |
53 |
Block: 1/1 Branch: 1/1 |
else if (DIRECTION.equals(localName)) { |
54 |
Block: 1/1 Branch: 1/1 |
m_direction = chars; |
55 |
|
} |
56 |
Block: 1/1 Branch: 1/1 |
else if (ROUTE_HEADING.equals(localName) || ROUTE_LABEL.equals(localName)) { |
57 |
Block: 1/1 Branch: 2/2 |
m_routeHeading = chars; |
58 |
|
} |
59 |
Block: 1/1 Branch: 1/1 |
} |
60 |
|
|
61 |
|
@Override |
62 |
|
public void endExternal(String uri, String localName, String qName) throws XmlParseException |
63 |
|
{ |
64 |
Block: 1/1 |
if (localName.equals(TRIP)) { |
65 |
Block: 1/1 Branch: 1/1 |
ParseResult[] collected = collectParsedChildren(Trip.class); |
66 |
|
for (ParseResult pr : collected) { |
67 |
Block: 1/1 Branch: 1/1 |
assert(pr instanceof Trip); |
68 |
Block: 1/1 Branch: 1/2 |
m_trips.add((Trip)pr); |
69 |
|
} |
70 |
|
} |
71 |
Block: 1/1 Branch: 1/2 |
} |
72 |
|
} |