Changeset 31
- Timestamp:
- 07/26/05 15:20:20 (3 years ago)
- Files:
-
- trunk/src/net/schst/XJConf/AttributeDefinition.java (modified) (1 diff)
- trunk/src/net/schst/XJConf/CDataDefinition.java (modified) (1 diff)
- trunk/src/net/schst/XJConf/ChildDefinition.java (modified) (1 diff)
- trunk/src/net/schst/XJConf/ConstructorDefinition.java (modified) (1 diff)
- trunk/src/net/schst/XJConf/Definition.java (modified) (1 diff)
- trunk/src/net/schst/XJConf/Examples/MyClass.java (added)
- trunk/src/net/schst/XJConf/Examples/MyInterface.java (added)
- trunk/src/net/schst/XJConf/Examples/TestInterfaces.java (added)
- trunk/src/net/schst/XJConf/ObjectValueConverter.java (modified) (1 diff)
- trunk/src/net/schst/XJConf/PrimitiveValueConverter.java (modified) (1 diff)
- trunk/src/net/schst/XJConf/Tag.java (modified) (1 diff)
- trunk/src/net/schst/XJConf/TagDefinition.java (modified) (7 diffs)
- trunk/src/net/schst/XJConf/ValueConverter.java (modified) (1 diff)
- trunk/xml/defines-interfaces.xml (added)
- trunk/xml/test-interfaces.xml (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/net/schst/XJConf/AttributeDefinition.java
r30 r31 149 149 * @return Class object 150 150 */ 151 public Class getValueType(Tag tag ) {151 public Class getValueType(Tag tag, ClassLoader loader) { 152 152 try { 153 return this.vConverter.getType( );153 return this.vConverter.getType(loader); 154 154 } catch (Exception e) { 155 155 throw new RuntimeException("Could not return type."); trunk/src/net/schst/XJConf/CDataDefinition.java
r30 r31 94 94 * @return Class object 95 95 */ 96 public Class getValueType(Tag tag ) {96 public Class getValueType(Tag tag, ClassLoader loader) { 97 97 try { 98 return this.vConverter.getType( );98 return this.vConverter.getType(loader); 99 99 } catch (Exception e) { 100 100 throw new RuntimeException("Could not return type."); trunk/src/net/schst/XJConf/ChildDefinition.java
r25 r31 48 48 * @return Class object 49 49 */ 50 public Class getValueType(Tag tag ) {50 public Class getValueType(Tag tag, ClassLoader loader) { 51 51 Tag child = tag.getChild(this.getName()); 52 52 if (child == null) { 53 53 throw new RuntimeException("Child element " + this.getName() + " does not exist"); 54 54 } 55 return child.getValueType(tag );55 return child.getValueType(tag, loader); 56 56 } 57 57 trunk/src/net/schst/XJConf/ConstructorDefinition.java
r28 r31 52 52 * @return Always returns null 53 53 */ 54 public Class getValueType(Tag tag ) {54 public Class getValueType(Tag tag, ClassLoader loader) { 55 55 return null; 56 56 } trunk/src/net/schst/XJConf/Definition.java
r25 r31 33 33 * @return 34 34 */ 35 public Class getValueType(Tag tag );35 public Class getValueType(Tag tag, ClassLoader loader); 36 36 37 37 /** trunk/src/net/schst/XJConf/ObjectValueConverter.java
r30 r31 64 64 * @return Class object 65 65 */ 66 public Class getType( ) throws Exception {67 return Class.forName(this.className );66 public Class getType(ClassLoader loader) throws Exception { 67 return Class.forName(this.className, true, loader); 68 68 } 69 69 } trunk/src/net/schst/XJConf/PrimitiveValueConverter.java
r30 r31 52 52 * Get the type 53 53 */ 54 public Class getType( ) throws Exception {54 public Class getType(ClassLoader loader) throws Exception { 55 55 if (this.type.equals("int")) { 56 56 return Integer.TYPE; trunk/src/net/schst/XJConf/Tag.java
r25 r31 168 168 * @return Class object 169 169 */ 170 public Class getValueType(Tag tag ) {171 return this.def.getValueType(tag );170 public Class getValueType(Tag tag, ClassLoader loader) { 171 return this.def.getValueType(tag, loader); 172 172 } 173 173 trunk/src/net/schst/XJConf/TagDefinition.java
r30 r31 136 136 * @return Class object 137 137 */ 138 public Class getValueType(Tag tag ) {138 public Class getValueType(Tag tag, ClassLoader loader) { 139 139 try { 140 return this.vConverter.getType( );140 return this.vConverter.getType(loader); 141 141 } catch (Exception e) { 142 142 throw new RuntimeException("Could not return type."); … … 207 207 paramDef = (Definition)conParams.get(i); 208 208 cParams[i] = paramDef.convertValue(tag,loader); 209 cParamTypes[i] = paramDef.getValueType(tag );209 cParamTypes[i] = paramDef.getValueType(tag, loader); 210 210 } 211 211 Object instance = this.vConverter.convertValue(cParams, cParamTypes, loader); … … 246 246 try { 247 247 methodName = att.getSetterMethod(); 248 Class meParamTypes[] = {att.getValueType(tag )};248 Class meParamTypes[] = {att.getValueType(tag, loader)}; 249 249 Method me = cl.getMethod(methodName, meParamTypes); 250 250 Object meParams[] = {val}; … … 297 297 Class childParamTypes[] = {String.class, String.class}; 298 298 Method childMethod = cl.getMethod("setProperty", childParamTypes); 299 Stringparams[] = {key, (String)childValue};299 Object params[] = {key, (String)childValue}; 300 300 childMethod.invoke(instance, params); 301 301 … … 315 315 childMethod.invoke(instance, childParams); 316 316 317 // instance is any genericobject317 // instance is any object 318 318 } else { 319 Class childParamTypes[] = {child.getValueType(child )};319 Class childParamTypes[] = {child.getValueType(child, loader)}; 320 320 Method childMethod = null; 321 321 … … 323 323 childMethod = cl.getMethod(methodName, childParamTypes); 324 324 } catch (NoSuchMethodException e) { 325 Class interfaces[] = (Class[]) this.determineAllInterfaces(new ArrayList(), child.getValueType(child )).toArray(new Class[0]);325 Class interfaces[] = (Class[]) this.determineAllInterfaces(new ArrayList(), child.getValueType(child, loader)).toArray(new Class[0]); 326 326 for (int j = 0; j < interfaces.length; j++) { 327 327 try { … … 340 340 } 341 341 } catch (Exception e) { 342 throw new ValueConversionException("Could not add child " + child.getKey() + " to " + this.getType() + " using "+methodName+"() .", e);342 throw new ValueConversionException("Could not add child " + child.getKey() + " to " + this.getType() + " using "+methodName+"(), exception message: " + e.getMessage() + ".", e); 343 343 } 344 344 } trunk/src/net/schst/XJConf/ValueConverter.java
r30 r31 6 6 public interface ValueConverter { 7 7 public Object convertValue(Object[] values, Class[] types, ClassLoader loader) throws ValueConversionException; 8 public Class getType( ) throws Exception;8 public Class getType(ClassLoader loader) throws Exception; 9 9 }
