propertylist/IPropertylist: removed obsolete loadTextDB_sub()
[metux-java.git] / datasource / Cached_TextDB_Loader.java
blob27184b4a6e81f2f55fb06125e442a12043fb576e
1 package org.de.metux.datasource;
3 import java.io.File;
4 import java.util.Hashtable;
5 import java.util.Properties;
7 import org.de.metux.util.TextDB;
9 public class Cached_TextDB_Loader implements ITextDB_Loader
11 public boolean enabled = true;
13 Hashtable<String,Properties> cache = null;
15 public void clearCache()
17 cache = null;
20 public void setCaching(boolean e)
22 enabled = e;
25 private Properties __load(String fn)
27 Properties pr = new Properties();
28 if (TextDB.LoadIntoHashtable(fn,pr))
29 return pr;
30 else
31 return null;
34 public Properties load(String filename)
36 if (filename == null)
37 return null;
39 if (!enabled)
40 return __load(filename);
42 Properties pr;
44 if (cache == null)
45 cache = new Hashtable<String,Properties>();
46 else if ((pr = cache.get(filename)) != null)
47 return pr;
49 if ((pr = __load(filename)) != null)
50 cache.put(filename,pr);
52 return pr;
55 public Properties load(File filename)
57 return load(filename.toString());