41 |
Map<String, DepartureBean> cache; |
Map<String, DepartureBean> cache; |
42 |
|
|
43 |
StationDAO stationDao = new StationDAO(); |
StationDAO stationDao = new StationDAO(); |
44 |
|
TritinfoFetcher tritinfo; |
45 |
|
|
46 |
|
|
47 |
private TraininfoSettings settings; |
private TraininfoSettings settings; |
83 |
public DepartureFetcher(TraininfoSettings settings) { |
public DepartureFetcher(TraininfoSettings settings) { |
84 |
this.settings = settings; |
this.settings = settings; |
85 |
cache = new TimeoutMap<String,DepartureBean>( settings.getCacheTimeout() ); |
cache = new TimeoutMap<String,DepartureBean>( settings.getCacheTimeout() ); |
86 |
|
|
87 |
|
tritinfo = new TritinfoFetcher(settings); |
88 |
} |
} |
89 |
|
|
90 |
|
|
137 |
if (type == FetchTrainType.BOTH) { //if we have both S-tog and regional order by departure/arrival time |
if (type == FetchTrainType.BOTH) { //if we have both S-tog and regional order by departure/arrival time |
138 |
Collections.sort( departureBean.entries, departureTimeComparator); |
Collections.sort( departureBean.entries, departureTimeComparator); |
139 |
} |
} |
140 |
|
|
141 |
|
//System.out.println("Trit: " + settings.isTritinfoEnabled() + " " + station.getTritStation() ); |
142 |
|
if ( settings.isTritinfoEnabled() && station.getTritStation() != -1) { |
143 |
|
try { |
144 |
|
tritinfo.injectTritinfoData(departureBean, station); |
145 |
|
} catch (Exception ex) { //det er ikke kritisk at vi får perron numre med |
146 |
|
logger.warning("tritinfo failed with " + ex.getClass().getName() + ": " + ex.getMessage() ); |
147 |
|
} |
148 |
|
} |
149 |
|
|
150 |
|
|
151 |
return departureBean; |
return departureBean; |
521 |
Element anchorElement = trainTd.getElementsByTag("a").get(0); |
Element anchorElement = trainTd.getElementsByTag("a").get(0); |
522 |
String href = anchorElement.attr("href"); |
String href = anchorElement.attr("href"); |
523 |
|
|
524 |
int pos = href.lastIndexOf('/'); |
int pos = href.lastIndexOf('='); |
525 |
String number = href.substring(pos+1); |
String number = href.substring(pos+1); |
526 |
|
|
527 |
return number; |
return number; |
555 |
|
|
556 |
return number; |
return number; |
557 |
} |
} |
558 |
|
|
559 |
|
|
560 |
|
|
561 |
//test |
//test |