/[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 365 by torben, Wed Sep 30 09:14:27 2009 UTC revision 1547 by torben, Thu Jul 7 19:07:55 2011 UTC
# Line 1  Line 1 
1  package dk.thoerup.traininfo.provider;  package dk.thoerup.traininfo.provider;
2    
3    
4    
5    
6  public class ProviderFactory {  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 ... but where should it go ?
15            public static void purgeOldEntries() {          
16                    synchronized (ProviderFactory.class) {
17                            if (stationProvider != null ) {
18                                    stationProvider.purgeOldEntries();
19                            }
20                            
21                            if (departureProvider != null ) {
22                                    departureProvider.purgeOldEntries();
23                            }
24                            
25                            if (timetableProvider != null ) {
26                                    timetableProvider.purgeOldEntries();
27                            }
28                            if (metroProvider != null ) {
29                                    metroProvider.purgeOldEntries();
30                            }
31                            
32                    }
33    
34            }
35            
36          public static DepartureProvider getDepartureProvider() {          public static DepartureProvider getDepartureProvider() {
37                  if (departureProvider == null) {                  if (departureProvider == null) {
38                          if (!DEBUG) {                          if (!DEBUG) {
# Line 23  public class ProviderFactory { Line 48  public class ProviderFactory {
48          public static StationProvider getStationProvider() {          public static StationProvider getStationProvider() {
49                  if (stationProvider == null) {                  if (stationProvider == null) {
50                          if (!DEBUG) {                          if (!DEBUG) {
51                                  stationProvider = new XmlStationProvider();                                  stationProvider = new OfflineStationProvider();
52                          } else {                          } else {
53                                  stationProvider = new DebugProvider();                                  stationProvider = new DebugProvider();
54                          }                          }
# Line 42  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.365  
changed lines
  Added in v.1547

  ViewVC Help
Powered by ViewVC 1.1.20