1 18 19 package org.apache.struts.tiles; 20 21 import java.io.Serializable ; 22 import java.lang.reflect.InvocationTargetException ; 23 import java.util.HashMap ; 24 import java.util.Iterator ; 25 import java.util.Map ; 26 import java.util.Set ; 27 28 import org.apache.commons.beanutils.BeanUtils; 29 30 37 public class DefinitionsFactoryConfig implements Serializable { 38 39 44 protected String factoryClassname = 45 "org.apache.struts.tiles.xmlDefinition.I18nFactorySet"; 46 47 51 protected boolean parserValidate = true; 52 53 56 protected String definitionConfigFiles = null; 57 58 61 protected boolean moduleAware = true; 62 63 71 protected String factoryName; 72 73 77 public static final String PARSER_DETAILS_PARAMETER_NAME = 78 "definitions-parser-details"; 79 80 83 public static final String PARSER_VALIDATE_PARAMETER_NAME = 84 "definitions-parser-validate"; 85 86 89 public static final String FACTORY_CLASSNAME_PARAMETER_NAME = 90 "definitions-factory-class"; 91 92 95 public static final String DEFINITIONS_CONFIG_PARAMETER_NAME = 96 "definitions-config"; 97 98 102 public static final String TILES_DETAILS_PARAMETER_NAME = "definitions-debug"; 103 104 107 private Map extraAttributes = new HashMap (); 108 109 112 public DefinitionsFactoryConfig() { 113 super(); 114 } 115 116 123 public DefinitionsFactoryConfig(Map initParameters) { 124 super(); 125 } 126 127 132 public boolean isModuleAware() { 133 return moduleAware; 134 } 135 140 public void setModuleAware(boolean moduleAware) { 141 this.moduleAware = moduleAware; 142 } 143 144 148 public String getFactoryClassname() { 149 return factoryClassname; 150 } 151 152 156 public void setFactoryClassname(String aFactoryClassname) { 157 factoryClassname = aFactoryClassname; 158 } 159 160 164 public boolean getParserValidate() { 165 return parserValidate; 166 } 167 168 172 public void setParserValidate(boolean aParserValidate) { 173 parserValidate = aParserValidate; 174 } 175 176 180 public String getDefinitionConfigFiles() { 181 return definitionConfigFiles; 182 } 183 184 188 public void setDefinitionConfigFiles(String aDefinitionConfigFiles) { 189 definitionConfigFiles = aDefinitionConfigFiles; 190 } 191 192 197 public void setAttribute(String name, Object value) { 198 extraAttributes.put(name, value); 199 } 200 201 206 public Object getAttribute(String name) { 207 return extraAttributes.get(name); 208 } 209 210 214 public Map getAttributes() { 215 Map map = new HashMap (extraAttributes); 216 226 return map; 227 } 228 229 257 public void populate(Map properties) 258 throws IllegalAccessException , InvocationTargetException { 259 260 linkOldPropertyNames(properties); 262 BeanUtils.populate(this, properties); 263 } 264 265 271 static public void linkOldPropertyNames(Map properties) { 272 Set entries = properties.entrySet(); 273 Map toAdd = new HashMap (); 274 Iterator i = entries.iterator(); 275 while (i.hasNext()) { 276 Map.Entry entry = (Map.Entry ) i.next(); 277 278 if (DEFINITIONS_CONFIG_PARAMETER_NAME.equals(entry.getKey())) { 279 toAdd.put("definitionConfigFiles", entry.getValue()); 280 281 } else if (FACTORY_CLASSNAME_PARAMETER_NAME.equals(entry.getKey())) { 282 toAdd.put("factoryClassname", entry.getValue()); 283 284 } else if (PARSER_DETAILS_PARAMETER_NAME.equals(entry.getKey())) { 285 toAdd.put("parserDebugLevel", entry.getValue()); 286 287 } else if (PARSER_VALIDATE_PARAMETER_NAME.equals(entry.getKey())) { 288 toAdd.put("parserValidate", entry.getValue()); 289 290 } else if (TILES_DETAILS_PARAMETER_NAME.equals(entry.getKey())) { 291 toAdd.put("debugLevel", entry.getValue()); 292 } 293 } 294 295 if (toAdd.size() > 0) { 296 properties.putAll(toAdd); 297 } 298 } 299 300 303 public String getFactoryName() { 304 return factoryName; 305 } 306 310 public void setFactoryName(String factoryName) { 311 this.factoryName = factoryName; 312 } 313 } 314 | Popular Tags |