Question

I am trying to call a method and pass a String as an argument to that method when processing a particular tag for XML-to-Object transformation using Digester:

<pattern value="abc/xyz">
    <object-create-rule classname="com.test.XYZ"/>
    <call-method-rule methodname="setTypeName" paramcount="1" paramtypes="java.lang.String"/>
    <call-param-rule paramnumber="0"/>
</pattern>

This sets the typeName in XYZ to empty string, but I want to set it to some other fixed string (e.g. "test"). How do I specify this fixed string in call-method-rule or call-param-rule?

Was it helpful?

Solution

There is a object-param-rule for this

Try

<pattern value="abc/xyz">
    <object-create-rule classname="com.test.XYZ"/>
    <call-method-rule methodname="setTypeName" paramcount="1" paramtypes="java.lang.String"/>
    <object-param-rule paramnumber="0" type="java.lang.String" value="test" />
</pattern>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top