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

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

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

revision 386 by torben, Fri Oct 2 13:44:31 2009 UTC revision 387 by torben, Fri Oct 2 15:06:08 2009 UTC
# Line 7  import java.util.ArrayList; Line 7  import java.util.ArrayList;
7  import java.util.List;  import java.util.List;
8  import java.util.logging.Logger;  import java.util.logging.Logger;
9    
10  import com.gargoylesoftware.htmlunit.*;  import com.gargoylesoftware.htmlunit.Page;
11  import com.gargoylesoftware.htmlunit.html.*;  import com.gargoylesoftware.htmlunit.RefreshHandler;
12    import com.gargoylesoftware.htmlunit.WebClient;
13    import com.gargoylesoftware.htmlunit.html.DomNodeList;
14    import com.gargoylesoftware.htmlunit.html.HtmlElement;
15    import com.gargoylesoftware.htmlunit.html.HtmlPage;
16    
17  public class TimetableFetcher {  public class TimetableFetcher {
18                    
# Line 17  public class TimetableFetcher { Line 21  public class TimetableFetcher {
21                  }                  }
22                                    
23          }          }
24                    
25            TimeoutCache<String, List<TimetableBean>> cache = new TimeoutCache<String,List<TimetableBean>>(120 * 1000);
26            
27                    
28          Logger logger = Logger.getLogger(TimetableFetcher.class.getName());          Logger logger = Logger.getLogger(TimetableFetcher.class.getName());
29            
30            
31            List<TimetableBean> cachedLookupTimetable(String trainID, String type) throws Exception {
32                    String key = trainID+type;
33                    List<TimetableBean> list = cache.get(key);
34                    
35                    if (list == null) {
36                            logger.warning("Timetable: Cache miss " + trainID); //remove before production
37                            list = lookupTimetable(trainID,type);
38                            cache.put(key, list);
39                    } else {
40                            logger.warning("Timetable: Cache hit " + trainID); //remove before production
41                    }
42                    return list;
43            }
44    
45          List<TimetableBean> lookupTimetable(String trainID, String type) throws Exception {          List<TimetableBean> lookupTimetable(String trainID, String type) throws Exception {            
46                  List<TimetableBean> timetableList = new ArrayList<TimetableBean>();                  List<TimetableBean> timetableList = new ArrayList<TimetableBean>();
47                                    
48                  String url = "http://www.bane.dk/visRute.asp?W=" + type + "&TogNr=" + trainID + "&artikelId=4276";                  String url = "http://www.bane.dk/visRute.asp?W=" + type + "&TogNr=" + trainID + "&artikelId=4276";

Legend:
Removed from v.386  
changed lines
  Added in v.387

  ViewVC Help
Powered by ViewVC 1.1.20