/[projects]/android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureFetcher.java
ViewVC logotype

Diff of /android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureFetcher.java

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

revision 992 by torben, Wed Jul 14 08:05:31 2010 UTC revision 1020 by torben, Mon Aug 30 11:53:34 2010 UTC
# Line 2  package dk.thoerup.traininfoservice.bane Line 2  package dk.thoerup.traininfoservice.bane
2    
3    
4  import java.net.URL;  import java.net.URL;
5    import java.net.URLEncoder;
6  import java.util.Collections;  import java.util.Collections;
7  import java.util.Map;  import java.util.Map;
8  import java.util.logging.Logger;  import java.util.logging.Logger;
# Line 108  public class DepartureFetcher { Line 109  public class DepartureFetcher {
109                            
110              String typeString = getTypeString(type);              String typeString = getTypeString(type);
111              String arrivalDeparture = (arrival==false) ? "Afgang" : "Ankomst";              String arrivalDeparture = (arrival==false) ? "Afgang" : "Ankomst";
112                                            
113                stationcode = URLEncoder.encode(stationcode,"ISO-8859-1");
114              //String uri = "http://www.bane.dk/visStation.asp?ArtikelID=4275&W=" + type + "&S=" + stationcode;              //String uri = "http://www.bane.dk/visStation.asp?ArtikelID=4275&W=" + type + "&S=" + stationcode;
115              String uri = "http://trafikinfo.bane.dk/Trafikinformation/AfgangAnkomst/" + arrivalDeparture + "/" + stationcode + "/" + typeString + "/UdvidetVisning";              String uri = "http://trafikinfo.bane.dk/Trafikinformation/AfgangAnkomst/" + arrivalDeparture + "/" + stationcode + "/" + typeString + "/UdvidetVisning";
116    
117                
118                
119              //logger.info("URI: " + uri);                        //logger.info("URI: " + uri);          
120              JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), 2500);              JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), 2500);
121              CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk");              CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk");
# Line 124  public class DepartureFetcher { Line 128  public class DepartureFetcher {
128              if (table != null) {              if (table != null) {
129                      Elements tableRows =  table.getElementsByTag("tr");                      Elements tableRows =  table.getElementsByTag("tr");
130                                            
131                        boolean tidsstregExists = (table.getElementsByAttributeValue("class", "Tidsstreg").size() > 0);
132                        boolean passedTidsstreg = false;
133                        
134                      for (Element currentRow : tableRows) {                      for (Element currentRow : tableRows) {
135                          String rowClass = currentRow.attr("class");                          String rowClass = currentRow.attr("class");
136                            
137                            if (tidsstregExists == true && passedTidsstreg == false) {
138                                    if (currentRow.getElementsByAttributeValue("class", "Tidsstreg").size() > 0) {
139                                            passedTidsstreg = true;
140                                    } else {
141                                            continue;
142                                    }
143                            }
144                            
145                          if (rowClass != null && rowClass.toLowerCase().contains("station") ) {                          if (rowClass != null && rowClass.toLowerCase().contains("station") ) {
146                                    
147                                  Elements fields = currentRow.getElementsByTag("td");                                  Elements fields = currentRow.getElementsByTag("td");
148                    
149                                  DepartureEntry departure = new DepartureEntry();                                  DepartureEntry departure = new DepartureEntry();

Legend:
Removed from v.992  
changed lines
  Added in v.1020

  ViewVC Help
Powered by ViewVC 1.1.20