1 16 17 package org.apache.commons.configuration; 18 19 import java.util.Iterator ; 20 import java.util.Map ; 21 import java.util.List ; 22 import java.util.ArrayList ; 23 24 import org.apache.commons.collections.map.LinkedMap; 25 26 50 public class BaseConfiguration extends AbstractConfiguration 51 { 52 53 private Map store = new LinkedMap(); 54 55 58 public BaseConfiguration() 59 { 60 super(); 61 } 62 63 70 protected void addPropertyDirect(String key, Object obj) 71 { 72 Object o = getProperty(key); 73 Object objAdd = null; 74 75 if (o == null) 76 { 77 objAdd = obj; 78 } 79 else 80 { 81 if (o instanceof List ) 82 { 83 ((List ) o).add(obj); 84 } 85 else 86 { 87 List list = new ArrayList (); 89 90 list.add(o); 93 94 list.add(obj); 96 97 objAdd = list; 98 } 99 } 100 101 if (objAdd != null) 102 { 103 store.put(key, objAdd); 104 } 105 } 106 107 114 public Object getProperty(String key) 115 { 116 return store.get(key); 117 } 118 119 125 public boolean isEmpty() 126 { 127 return store.isEmpty(); 128 } 129 130 138 public boolean containsKey(String key) 139 { 140 return store.containsKey(key); 141 } 142 143 148 public void clearProperty(String key) 149 { 150 if (containsKey(key)) 151 { 152 store.remove(key); 153 } 154 } 155 156 159 public void clear() 160 { 161 store.clear(); 162 } 163 164 170 public Iterator getKeys() 171 { 172 return store.keySet().iterator(); 173 } 174 } 175 | Popular Tags |