/[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

android/TrainInfo/src/dk/thoerup/traininfo/provider/DepartureFactory.java revision 237 by torben, Sat Aug 8 19:02:20 2009 UTC android/TrainInfo/src/dk/thoerup/traininfo/provider/ProviderFactory.java revision 1027 by torben, Wed Sep 8 06:03:45 2010 UTC
# Line 1  Line 1 
1  package dk.thoerup.traininfo.provider;  package dk.thoerup.traininfo.provider;
2    
3    
4  public class DepartureFactory {  
5          private static DepartureProvider provider = null;  
6    public class ProviderFactory {
7            private static DepartureProvider departureProvider = null;
8            private static StationProvider stationProvider = null;
9            private static TimetableProvider timetableProvider = null;
10                    
11            private static final boolean DEBUG = false;
12                    
13          public static DepartureProvider getProvider() {          //TODO: this one really doesn't belong here ... and damn it is ugly code
14                  if (provider == null) {          public static void purgeOldEntries() {          
15                          //provider = new DebugProvider();                  synchronized (ProviderFactory.class) {
16                          provider = new XmlDepartureProvider();                          if (stationProvider != null && stationProvider instanceof XmlStationProvider) {
17                                    ((XmlStationProvider)stationProvider).stationCache.purgeOldEntries();
18                            }
19                            
20                            if (departureProvider != null && departureProvider instanceof XmlDepartureProvider) {
21                                    ((XmlDepartureProvider)departureProvider).departureCache.purgeOldEntries();
22                            }
23                            
24                            if (timetableProvider != null && timetableProvider instanceof XmlTimetableProvider) {
25                                    ((XmlTimetableProvider)timetableProvider).timetableCache.purgeOldEntries();
26                            }
27                    }
28    
29            }
30            
31            public static DepartureProvider getDepartureProvider() {
32                    if (departureProvider == null) {
33                            if (!DEBUG) {
34                                    departureProvider = new XmlDepartureProvider();
35                            } else {
36                                    departureProvider = new DebugProvider();
37                            }
38                  }                  }
39                                    
40                  return provider;                  return departureProvider;
41            }
42            
43            public static StationProvider getStationProvider() {
44                    if (stationProvider == null) {
45                            if (!DEBUG) {
46                                    stationProvider = new XmlStationProvider();
47                            } else {
48                                    stationProvider = new DebugProvider();
49                            }
50                    }
51                    
52                    return stationProvider;
53            }
54            
55            public static TimetableProvider getTimetableProvider() {
56                    if (timetableProvider == null) {
57                            if (!DEBUG) {
58                                    timetableProvider = new XmlTimetableProvider();
59                            } else {
60                                    timetableProvider = new DebugProvider();
61                            }
62                    }
63                    return timetableProvider;
64          }          }
65  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.20