/[projects]/android/TrainInfoServiceGoogle/src/dk/thoerup/traininfoservice/banedk/MetroFetcher.java
ViewVC logotype

Diff of /android/TrainInfoServiceGoogle/src/dk/thoerup/traininfoservice/banedk/MetroFetcher.java

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

revision 1043 by torben, Mon Sep 13 18:53:30 2010 UTC revision 1056 by torben, Tue Sep 14 17:01:24 2010 UTC
# Line 62  public class MetroFetcher { Line 62  public class MetroFetcher {
62                                                    
63                                    
64                  URL url = new URL("http://www.m.dk/layouts/Metro/Widgets/MetroWidget.ashx?StationId=" + station.getMetro() + "&Congestion=true&Application=MyMetro&Expiration=true");                  URL url = new URL("http://www.m.dk/layouts/Metro/Widgets/MetroWidget.ashx?StationId=" + station.getMetro() + "&Congestion=true&Application=MyMetro&Expiration=true");
65                    logger.fine("URL:" + url);
66                                    
67              JsoupInvocation wrapper = new JsoupInvocation( url, 3000);              JsoupInvocation wrapper = new JsoupInvocation( url, 3000);
68              CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("metro");              CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("metro");
# Line 82  public class MetroFetcher { Line 83  public class MetroFetcher {
83                  for (int i=1; i<rows.size(); i++) {                  for (int i=1; i<rows.size(); i++) {
84                          Element row = rows.get(i);                                Element row = rows.get(i);      
85                          Elements fields = row.children();                          Elements fields = row.children();
86    
87                            
88                            
89                            Elements metroFields = fields.get(0).children();                        
90                            String metro ="";                      
91                            for (Element elm : metroFields) {
92                                    metro = metro + elm.text() + " ";
93                            }
94                            
95                            
96                                                    
                         String metro = fields.get(0).text();  
97                          String destination = fields.get(1).text();                          String destination = fields.get(1).text();
                         Elements minuteFields = fields.get(2).children();  
                         String minutes ="";  
98                                                    
99                            Elements minuteFields = fields.get(2).children();                      
100                            String minutes ="";                    
101                          for (Element elm : minuteFields) {                          for (Element elm : minuteFields) {
102                                  minutes = minutes + elm.text() + " ";                                  minutes = minutes + elm.text() + " ";
103                          }                          }
104                                                    
105                          MetroEntry entry = new MetroEntry();                          MetroEntry entry = new MetroEntry();
106                          entry.metro = metro;                          entry.metro = metro.trim();
107                          entry.destination = destination;                          entry.destination = destination.trim();
108                          entry.minutes = minutes;                          entry.minutes = minutes.trim();
109                                                    
110                          bean.entries.add(entry);                                                  bean.entries.add(entry);                        
111                  }                  }
112                                                                    
113                  bean.operationInfo = contentElems.get(3).text();                  bean.operationInfo = contentElems.get(3).text();
114                                    
115                  int planIndex;                  for (int i=4; i<contentElems.size(); i++) {
116                  if (contentElems.get(4).text().trim().equalsIgnoreCase("stationsinformation")) {                          if (contentElems.get(i).text().trim().equalsIgnoreCase("køreplan")) {                          
117                          planIndex = 7;                                  bean.plan = contentElems.get(i+1).text();
118                  } else {                          }
                         planIndex = 5;  
119                  }                  }
120                            
                 bean.plan = contentElems.get(planIndex).text();  
                   
121                  return bean;                  return bean;
122          }          }
123                    

Legend:
Removed from v.1043  
changed lines
  Added in v.1056

  ViewVC Help
Powered by ViewVC 1.1.20