1 package net.myvietnam.mvncore.configuration; 2 3 56 57 import java.util.Iterator ; 58 59 import org.apache.commons.collections.SequencedHashMap; 60 61 86 public class BaseConfiguration extends AbstractConfiguration 87 { 88 89 private SequencedHashMap store = new SequencedHashMap(); 90 91 94 public BaseConfiguration() 95 { 96 super(); 97 } 98 99 105 public BaseConfiguration(Configuration defaults) 106 { 107 super(defaults); 108 } 109 110 117 protected void addPropertyDirect(String key, Object obj) 118 { 119 Object o = getPropertyDirect(key); 120 Object objAdd = null; 121 122 if(o == null) 123 { 124 objAdd = obj; 125 } 126 else 127 { 128 if (o instanceof Container) 129 { 130 ((Container) o).add(obj); 131 } 132 else 133 { 134 Container c = new Container(); 136 137 c.add(o); 140 141 c.add(obj); 143 144 objAdd = c; 145 } 146 } 147 148 if(objAdd != null) 149 { 150 store.put(key, objAdd); 151 } 152 } 153 154 161 protected Object getPropertyDirect(String key) 162 { 163 return store.get(key); 164 } 165 166 172 public boolean isEmpty() 173 { 174 return store.isEmpty(); 175 } 176 177 185 public boolean containsKey(String key) 186 { 187 return store.containsKey(key); 188 } 189 190 195 public void clearProperty(String key) 196 { 197 if (containsKey(key)) 198 { 199 store.remove(key); 200 } 201 } 202 203 209 public Iterator getKeys() 210 { 211 return store.iterator(); 212 } 213 } 214 | Popular Tags |