/[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 1038 by torben, Sun Sep 12 18:41:17 2010 UTC revision 1039 by torben, Sun Sep 12 19:03:32 2010 UTC
# Line 173  public class DepartureFetcher { Line 173  public class DepartureFetcher {
173                                                                    
174                                  String trainNumber = fields.get(2).text();                                  String trainNumber = fields.get(2).text();
175                                  if (type == TrainType.STOG) //If it is S-train we need to extract the trainNumber                                  if (type == TrainType.STOG) //If it is S-train we need to extract the trainNumber
176                                          trainNumber = trainNumber + " " + extractTrainNumber(fields.get(2));                                          trainNumber = trainNumber + " " + extractTrainNumberAzure(fields.get(2));
177                                  departure.setTrainNumber(trainNumber);                                  departure.setTrainNumber(trainNumber);
178                                                                    
179                                  String destination = fields.get(3).text();                                  String destination = fields.get(3).text();
# Line 263  public class DepartureFetcher { Line 263  public class DepartureFetcher {
263                                                                    
264                                  String trainNumber = cleanText( fields.get(2).text() );                                  String trainNumber = cleanText( fields.get(2).text() );
265                                  if (type.equalsIgnoreCase("S2")) //If it is S-train we need to extract the trainNumber                                  if (type.equalsIgnoreCase("S2")) //If it is S-train we need to extract the trainNumber
266                                          trainNumber = trainNumber + " " + extractTrainNumber(fields.get(2));                                          trainNumber = trainNumber + " " + extractTrainNumberWww(fields.get(2));
267                                  departure.setTrainNumber(trainNumber);                                  departure.setTrainNumber(trainNumber);
268                                                                    
269                                  String destination = cleanText( fields.get(3).text() );                                  String destination = cleanText( fields.get(3).text() );
# Line 326  public class DepartureFetcher { Line 326  public class DepartureFetcher {
326                  return note.trim();                  return note.trim();
327          }          }
328                    
329          private String extractTrainNumber(Element trainTd) {          private String extractTrainNumberAzure(Element trainTd) {
330                  Element anchorElement = trainTd.getElementsByTag("a").get(0);                  Element anchorElement = trainTd.getElementsByTag("a").get(0);
331                  String href = anchorElement.attr("href");                  String href = anchorElement.attr("href");
332                                    
# Line 336  public class DepartureFetcher { Line 336  public class DepartureFetcher {
336                  return number;                  return number;
337          }          }
338                    
339            private String extractTrainNumberWww(Element trainTd) {
340                    String number = "";
341                    Element anchorElement = trainTd.getElementsByTag("a").get(0);
342                    String href = anchorElement.attr("href");
343                    String argstring = href.substring( href.indexOf('?') + 1);
344                    
345                    String args[] = argstring.split("&");
346                    for (String arg : args) {
347                            String pair[] = arg.split("="); // Key=pair[0], Value=pair[1]
348                            
349                            if (pair[0].equalsIgnoreCase("TogNr"))
350                                    number = pair[1];
351                    }
352                    
353                    
354                    return number;
355            }
356    
357            
358          //test          //test
359          /*          /*
360          public static void main(String args[]) throws Exception {          public static void main(String args[]) throws Exception {

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

  ViewVC Help
Powered by ViewVC 1.1.20