/[projects]/android/TrainInfo/src/dk/thoerup/traininfo/provider/ProviderFactory.java
ViewVC logotype

Diff of /android/TrainInfo/src/dk/thoerup/traininfo/provider/ProviderFactory.java

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

revision 1027 by torben, Wed Sep 8 06:03:45 2010 UTC revision 1160 by torben, Mon Oct 4 08:42:12 2010 UTC
# Line 7  public class ProviderFactory { Line 7  public class ProviderFactory {
7          private static DepartureProvider departureProvider = null;          private static DepartureProvider departureProvider = null;
8          private static StationProvider stationProvider = null;          private static StationProvider stationProvider = null;
9          private static TimetableProvider timetableProvider = null;          private static TimetableProvider timetableProvider = null;
10            private static MetroProvider metroProvider = null;
11                    
12          private static final boolean DEBUG = false;          private static final boolean DEBUG = false;
13                    
14          //TODO: this one really doesn't belong here ... and damn it is ugly code          //TODO: this one really doesn't belong here ... but where should it go ?
15          public static void purgeOldEntries() {                    public static void purgeOldEntries() {          
16                  synchronized (ProviderFactory.class) {                  synchronized (ProviderFactory.class) {
17                          if (stationProvider != null && stationProvider instanceof XmlStationProvider) {                          if (stationProvider != null ) {
18                                  ((XmlStationProvider)stationProvider).stationCache.purgeOldEntries();                                  stationProvider.purgeOldEntries();
19                          }                          }
20                                                    
21                          if (departureProvider != null && departureProvider instanceof XmlDepartureProvider) {                          if (departureProvider != null ) {
22                                  ((XmlDepartureProvider)departureProvider).departureCache.purgeOldEntries();                                  departureProvider.purgeOldEntries();
23                          }                          }
24                                                    
25                          if (timetableProvider != null && timetableProvider instanceof XmlTimetableProvider) {                          if (timetableProvider != null ) {
26                                  ((XmlTimetableProvider)timetableProvider).timetableCache.purgeOldEntries();                                  timetableProvider.purgeOldEntries();
27                          }                          }
28                            if (metroProvider != null ) {
29                                    metroProvider.purgeOldEntries();
30                            }
31                            
32                  }                  }
33    
34          }          }
# Line 62  public class ProviderFactory { Line 67  public class ProviderFactory {
67                  }                  }
68                  return timetableProvider;                  return timetableProvider;
69          }          }
70    
71            public static MetroProvider getMetroProvider() {
72                    if (metroProvider == null) {
73                            if (!DEBUG) {
74                                    metroProvider = new XmlMetroProvider();
75                            } else {
76                                    metroProvider = new DebugProvider();
77                            }
78                    }
79                    return metroProvider;
80            }
81  }  }

Legend:
Removed from v.1027  
changed lines
  Added in v.1160

  ViewVC Help
Powered by ViewVC 1.1.20