1 64 package com.jcorporate.expresso.kernel.internal; 65 66 import com.jcorporate.expresso.kernel.Configuration; 67 68 import java.util.ArrayList ; 69 import java.util.HashMap ; 70 import java.util.Iterator ; 71 import java.util.Map ; 72 import java.util.TreeMap ; 73 74 75 85 86 public class DefaultConfigBean implements Configuration { 87 Map properties = null; 88 89 Map namedProperties = null; 90 91 Map indexedProperties = null; 92 93 94 public DefaultConfigBean() { 95 } 96 97 public Object get(String name) { 98 if (properties == null) { 99 return null; 100 } else { 101 return properties.get(name); 102 } 103 } 104 105 public Object get(String name, int index) { 106 if (indexedProperties == null) { 107 return null; 108 } 109 110 if (!indexedProperties.containsKey(name)) { 111 return null; 112 } 113 114 Map indexKeyMap = (Map ) indexedProperties.get(name); 115 return indexKeyMap.get(new Integer (index)); 116 } 117 118 124 public java.util.List getIndexedProperties(String name) { 125 if (indexedProperties == null) { 126 return null; 127 } 128 129 if (!indexedProperties.containsKey(name)) { 130 return null; 131 } 132 133 Map indexKeyMap = (Map ) indexedProperties.get(name); 134 ArrayList returnValue = new ArrayList (indexKeyMap.size()); 135 136 145 for (Iterator i = indexKeyMap.keySet().iterator(); i.hasNext();) { 146 Integer key = (Integer ) i.next(); 147 returnValue.add(indexKeyMap.get(key)); 148 } 149 150 return null; 151 } 152 153 154 public Object get(String name, String key) { 155 if (namedProperties == null) { 156 return null; 157 } else { 158 Map keyedProperties = (Map ) namedProperties.get(name); 159 if (keyedProperties == null) { 160 return null; 161 } else { 162 return keyedProperties.get(key); 163 } 164 } 165 } 166 167 173 public java.util.Map getMappedProperties(String name) { 174 if (namedProperties == null) { 175 return null; 176 } 177 178 return (Map ) namedProperties.get(name); 179 } 180 181 182 public boolean contains(String name, String key) { 183 if (namedProperties == null) { 184 return false; 185 } else { 186 Map keyedProperties = (Map ) namedProperties.get(name); 187 if (keyedProperties == null) { 188 return false; 189 } else { 190 return keyedProperties.containsKey(key); 191 } 192 } 193 } 194 195 public void set(String name, Object o) { 196 if (properties == null) { 197 properties = new HashMap (); 198 } 199 properties.put(name, o); 200 201 } 202 203 public void set(String name, int index, Object o) { 204 if (indexedProperties == null) { 205 indexedProperties = new HashMap (); 206 } 207 208 if (!indexedProperties.containsKey(name)) { 209 Map internalArray = new TreeMap (); 210 indexedProperties.put(name, internalArray); 211 } 212 213 Map indexKeyMap = (Map ) indexedProperties.get(name); 214 indexKeyMap.put(new Integer (index), o); 215 } 216 217 public void set(String name, String key, Object o) { 218 if (namedProperties == null) { 219 namedProperties = new HashMap (); 220 } 221 222 if (!namedProperties.containsKey(name)) { 223 namedProperties.put(name, new HashMap ()); 224 } 225 226 Map keyedProperties = (Map ) namedProperties.get(name); 227 keyedProperties.put(key, o); 228 } 229 230 } | Popular Tags |