1 package net.jaekl.frank.octranspo;
3 import java.util.ArrayList;
5 import net.jaekl.qd.xml.ParseResult;
6 import net.jaekl.qd.xml.XmlParseException;
8 public class StopInfo extends ParseResult
10 // potential child tag names
11 public static String STOP_NO = "StopNo";
12 public static String DESCRIPTION = "StopDescription"; // Present in RouteSummary
13 public static String STOP_LABEL = "StopLabel"; // What NextTrips calls StopDescription
14 public static String ERROR = "Error";
15 public static String ROUTES = "Routes";
16 public static String ROUTE = "Route";
18 // data returned inside our element
22 ArrayList<Route> m_routes;
25 public StopInfo(String rootTagName, String[] internal, Object[][] external) {
26 super(rootTagName, internal, external);
31 m_routes = new ArrayList<Route>();
34 // -----------------------------
35 // Public methods to access data
37 public int getStopNo() { return m_stopNo; }
38 public String getDescr() { return m_descr; }
39 public String getError() { return m_error; }
40 public int getNumRoutes() { return m_routes.size(); }
41 public Route getRoute(int idx) { return m_routes.get(idx); }
43 // --------------------------
44 // ParseResult implementation
47 public void endContents(String uri, String localName, String qName, String chars) throws XmlParseException
49 assert (null != localName);
51 if (localName.equals(STOP_NO)) {
52 m_stopNo = Integer.parseInt(chars);
54 else if (localName.equals(DESCRIPTION) || localName.equals(STOP_LABEL)) {
57 else if (localName.equals(ERROR)) {
63 public void endExternal(String uri, String localName, String qName) throws XmlParseException
65 if (localName.equals(ROUTE)) {
66 ParseResult[] collected = collectParsedChildren(Route.class);
67 for (ParseResult pr : collected) {
68 assert (pr instanceof Route);
69 m_routes.add((Route)pr);