I'm struggling to implement generic digester patterns. Some hints or
references to appropriate examples would be much appreciated!
This is my input XML:
-----------------------
<Config>
<backgroundColor>
<Color r="0" g="0" b="0" />
</background>
<axisColor>
<Color r="76" g="0" b="76" />
</axisColor>
</Config>
-----------------------
and these are my Digester rules:
-----------------------
<pattern value="*/Color">
<factory-create-rule classname="ColorFactory" />
</pattern>
<pattern value="Config">
<object-create-rule classname="Config">
<set-nested-properties-rule />
</pattern>
-----------------------
The factory is accessed properly, but I cannot get Digester to bind
the result of the "*/Color" rule set (a java.awt.Color object) so it
gets associated with the Config object.
Instead, I'm getting the following exception:
-----------------------
Exception in thread "main" java.lang.IllegalArgumentException: Cannot
invoke com.pensioenpage.protea.ChartRenderConfig.setBackground -
argument type mismatch
at org.apache.commons.digester.Digester.createSAXException
(Digester.java:3181)
at org.apache.commons.digester.Digester.createSAXException
(Digester.java:3207)
at org.apache.commons.digester.Digester.endElement(Digester.java:1195)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown
Source)
-----------------------
but the argument type does match (the method accepts a
java.awt.Paint, which is an interface implemented by java.awt.Color).
When I enable logging, I see the problem:
-----------------------
[DEBUG] Digester - [SetNestedPropertiesRule]{ChartRenderConfig/
background} Setting property 'background' to ''
[DEBUG] Digester - [SetNestedPropertiesRule]{ChartRenderConfig/
background} Set com.pensioenpage.protea.ChartRenderConfig properties
[DEBUG] ConvertUtils - Convert string '' to class 'java.awt.Paint'
[ERROR] PropertyUtils - Method invocation failed.
<java.lang.IllegalArgumentException: argument type
mismatch>java.lang.IllegalArgumentException: argument type mismatch
-----------------------
So how do I bind the Color object to the enclosing object in a
generic manner?
My environment:
- Commons Digester 1.8.0
- Java 1.5.0
- Mac OS X 10.4.10
Kind regards,
Ernst
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]