/[projects]/android/TrainInfo/src/dk/thoerup/traininfo/provider/XmlTimetableProvider.java
ViewVC logotype

Diff of /android/TrainInfo/src/dk/thoerup/traininfo/provider/XmlTimetableProvider.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 364 by torben, Tue Sep 29 19:06:34 2009 UTC revision 365 by torben, Wed Sep 30 09:14:27 2009 UTC
# Line 4  import java.util.ArrayList; Line 4  import java.util.ArrayList;
4  import java.util.List;  import java.util.List;
5    
6  import org.w3c.dom.Document;  import org.w3c.dom.Document;
7    import org.w3c.dom.NamedNodeMap;
8  import org.w3c.dom.Node;  import org.w3c.dom.Node;
9  import org.w3c.dom.NodeList;  import org.w3c.dom.NodeList;
10    
# Line 24  public class XmlTimetableProvider implem Line 25  public class XmlTimetableProvider implem
25          @Override          @Override
26          public boolean lookupTimetable(String trainID) {          public boolean lookupTimetable(String trainID) {
27                  boolean success = false;                  boolean success = false;
28                  String url = XmlUtil.SERVICE_BASE + "/TimetableServlet?train=" + trainID ;                  String url = XmlUtil.SERVICE_BASE + "/TimetableServlet?train=" + trainID.replace(" ", "%20") ;
29                  Log.i("url", url);                  Log.i("url", url);
30                  try {                  try {
31                          timetables.clear();                          timetables.clear();
# Line 45  public class XmlTimetableProvider implem Line 46  public class XmlTimetableProvider implem
46                    
47                                  TimetableBean timetable = new TimetableBean();                                  TimetableBean timetable = new TimetableBean();
48                                                                    
49                                  NodeList entries = entryNode.getChildNodes();                                  NodeList entries = entryNode.getChildNodes();                          
50                                    
51                                    if (entryNode.hasAttributes() && entryNode.getAttributes().getNamedItem("current") != null) {                                  
52                                            timetable.setCurrent( Boolean.parseBoolean(entryNode.getAttributes().getNamedItem("current").getNodeValue()));
53                                    } else {
54                                            timetable.setCurrent(false);
55                                    }
56                                    
57                                  for (int j=0; j<entries.getLength(); j++) {                                      for (int j=0; j<entries.getLength(); j++) {    
58                                          Node current = entries.item(j);                                          Node current = entries.item(j);
59                                                                                                                                                                    
# Line 64  public class XmlTimetableProvider implem Line 72  public class XmlTimetableProvider implem
72                                          if (nodeName.equals("departure"))                                          if (nodeName.equals("departure"))
73                                                  timetable.setDeparture( content );                                                  timetable.setDeparture( content );
74                                                                                    
75                                          if (nodeName.equals("current"))                                          /*if (nodeName.equals("current"))
76                                                  timetable.setCurrent( Boolean.parseBoolean(content) );                                                  timetable.setCurrent( Boolean.parseBoolean(content) );*/
77    
78                                  }                                  }
79                                  timetables.add(timetable);                                                                timetables.add(timetable);                              

Legend:
Removed from v.364  
changed lines
  Added in v.365

  ViewVC Help
Powered by ViewVC 1.1.20