01: package org.skunk.config;
02:
03: import java.util.HashMap;
04: import java.util.Iterator;
05:
06: public class InMemoryConfigStore implements ConfigStore {
07: private HashMap configMap;
08:
09: public InMemoryConfigStore() {
10: configMap = new HashMap();
11: }
12:
13: protected HashMap getConfigMap() {
14: return configMap;
15: }
16:
17: protected void setConfigMap(HashMap configMap) {
18: this .configMap = configMap;
19: }
20:
21: public Object getConfigValue(Class configClass,
22: String configProperty) {
23: if (!configMap.containsKey(configClass))
24: return null;
25: HashMap classMap = (HashMap) configMap.get(configClass);
26: if (classMap.containsKey(configProperty)) {
27: return classMap.get(configProperty);
28: }
29: return null;
30: }
31:
32: public Iterator registeredClasses() {
33: return configMap.keySet().iterator();
34: }
35:
36: public boolean isRegistered(Class configClass) {
37: return configMap.containsKey(configClass);
38: }
39:
40: public void unregister(Class configClass) {
41: if (configMap.containsKey(configClass)) {
42: configMap.remove(configClass);
43: }
44: }
45:
46: public void setConfigValue(Class configClass,
47: String configProperty, Object configValue) {
48: HashMap classMap;
49: if (!configMap.containsKey(configClass)) {
50: classMap = new HashMap();
51: configMap.put(configClass, classMap);
52: } else
53: classMap = (HashMap) configMap.get(configClass);
54: classMap.put(configProperty, configValue);
55: }
56:
57: }
58:
59: /* $Log: InMemoryConfigStore.java,v $
60: /* Revision 1.4 2001/02/02 23:30:33 smulloni
61: /* adding customization features to the text editor.
62: /*
63: /* Revision 1.3 2000/11/09 23:34:46 smullyan
64: /* log added to every Java file, with the help of python. Lock stealing
65: /* implemented, and treatment of locks made more robust.
66: /* */
|