/[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 1039 by torben, Sun Sep 12 19:03:32 2010 UTC revision 1046 by torben, Tue Sep 14 05:33:30 2010 UTC
# Line 220  public class DepartureFetcher { Line 220  public class DepartureFetcher {
220                    
221                    
222                    
223          String cleanText(String input) {          public static String cleanText(String input) {
224                  //apparently JSoup interprets some of space characters on www.bane.dk as 0xA0                  //apparently JSoup translates   characters on www.bane.dk to 0xA0
225                  return input.replace((char) 0xA0, (char)0x20).trim();                  return input.replace((char) 0xA0, (char)0x20).trim();
226          }          }
227                    
# Line 231  public class DepartureFetcher { Line 231  public class DepartureFetcher {
231                                    
232                  String type = getTypeStringWww(trainType);                  String type = getTypeStringWww(trainType);
233                                    
234                    stationcode = URLEncoder.encode(stationcode, "ISO-8859-1");
235                    
236                                                                                            
237              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;
238                logger.info("URI:" + uri);
239              JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), replyTimeout);              JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), replyTimeout);
240              CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk");              CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk");
241                            
# Line 241  public class DepartureFetcher { Line 244  public class DepartureFetcher {
244              String tableName = arrival == false ? "afgangtabel" : "ankomsttabel";              String tableName = arrival == false ? "afgangtabel" : "ankomsttabel";
245              Element table = page.getElementById(tableName);              Element table = page.getElementById(tableName);
246                            
247    
248                
249              if (table != null) {              if (table != null) {
250                      Elements tableRows =  table.getElementsByTag("tr");                      Elements tableRows =  table.getElementsByTag("tr");
251                                            
252                        boolean passedTidsstreg = false;
253                        boolean tidsstregExists = (table.getElementsByAttributeValue("class", "Tidsstreg").size() > 0);
254                        
255                      for (Element currentRow : tableRows) {                      for (Element currentRow : tableRows) {
256                          String rowClass = currentRow.attr("class");                          String rowClass = currentRow.attr("class");
257                            
258                            if (tidsstregExists == true && passedTidsstreg == false) {
259                                    if (currentRow.getElementsByAttributeValue("class", "Tidsstreg").size() > 0) {
260                                            passedTidsstreg = true;
261                                    } else {
262                                            continue;
263                                    }
264                            }
265                            
266                            
267                          if (rowClass != null && rowClass.toLowerCase().contains("station") ) {                          if (rowClass != null && rowClass.toLowerCase().contains("station") ) {
268                                  Elements fields = currentRow.getElementsByTag("td");                                  Elements fields = currentRow.getElementsByTag("td");
269                    

Legend:
Removed from v.1039  
changed lines
  Added in v.1046

  ViewVC Help
Powered by ViewVC 1.1.20