Changeset 5
- Timestamp:
- 06/23/05 11:26:28 (3 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/net/schst/XJConf/Examples/ExampleHashMap.java
r3 r5 14 14 15 15 public static void main(String[] args) { 16 17 16 DefinitionParser tagParser = new DefinitionParser(); 18 17 NamespaceDefinitions defs = tagParser.parse("xml/defines-hashmap.xml"); 19 20 18 21 19 XmlReader conf = new XmlReader(); trunk/src/net/schst/XJConf/TagDefinition.java
r4 r5 128 128 // no name, the parent should be a collection 129 129 if (this.name.equals("__none")) { 130 return "add";130 return null; 131 131 } 132 132 return "set" + this.name.substring(0,1).toUpperCase() + this.name.substring(1); … … 239 239 // Check, whether the current instance is a HashMap 240 240 } else if (instance instanceof java.util.AbstractMap) { 241 Object name = (Object)child.getKey(); 242 Class childParamTypes[] = {Class.forName("java.lang.Object"), Class.forName("java.lang.Object")}; 243 Method childMethod = cl.getMethod("put", childParamTypes); 244 245 Object params[] = {name, childValue}; 246 childMethod.invoke(instance, params); 247 } else if (methodName.equals("add")) { 248 // nasty workaround for Collections 249 // needs to be fixed 241 Object name = (Object)child.getKey(); 242 Class childParamTypes[] = {Class.forName("java.lang.Object"), Class.forName("java.lang.Object")}; 243 Method childMethod = cl.getMethod("put", childParamTypes); 244 245 Object params[] = {name, childValue}; 246 childMethod.invoke(instance, params); 247 // Check, whether the current instance is a collection 248 } else if (methodName == null && instance instanceof java.util.AbstractCollection) { 250 249 Class childParamTypes[] = {Class.forName("java.lang.Object")}; 251 Method childMethod = cl.getMethod( methodName, childParamTypes);250 Method childMethod = cl.getMethod("add", childParamTypes); 252 251 childMethod.invoke(instance, childParams); 253 254 } else {252 // instance is any generic object 253 } else { 255 254 Class childParamTypes[] = {childValue.getClass()}; 256 255
