You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Valerio Schiavoni <va...@gmail.com> on 2005/12/20 16:12:55 UTC
Digester: create parent from child node value
Hello,
i'm using digester to parse this kind ofxml:
<parameters type="RenameRelationOperatorParameter">
<param>newName</param>
</parameters>
there are different kind of types. Now, the value of the parameters should
be used on the
1-arg constructor for objects of type RenameRelationOperatorParameter. At
this time, there are no setParam method, and i' searching for a solution
that avoid adding them.
in my digesterReader at this time i have this (reduced to show the problem)
:
digester.addFactoryCreate("parameters", new OperatorParameterFactory());
and the OperatorParameterFactory is:
public static class OperatorParameterFactory extends
AbstractObjectCreationFactory {
@Override
public Object createObject(Attributes arg0) throws Exception {
String operatorType = arg0.getValue("type");
OperatorParameter result = null;
try {
result = (OperatorParameter) Class.forName
(operatorType).newInstance();
}catch ( ClassNotFoundException e) {
throw new UnsupportedOperationException("OperatorParameter named
"+operatorType+" is not supported yet");
}
return result;
}
}
thanks for any support you can provide,
valerio
--
To Iterate is Human, to Recurse, Divine
James O. Coplien, Bell Labs
Re: Digester: create parent from child node value
Posted by Valerio Schiavoni <va...@gmail.com>.
Hello,
this is my first post to the commons ml, thanks for the support.
i'm willing to use digester to parse this kind ofxml:
<parameters type="RenameRelationOperatorParameter">
<param>newName</param>
</parameters>
there could be different kind of type values.
Now, the value of the parameters should be used on the
1-arg constructor for objects of type RenameRelationOperatorParameter. At
this time, there are no setParam method, and i' searching for a solution
that avoid adding them.
in my digesterReader at this time i have this (reduced to show the problem)
:
digester.addFactoryCreate("parameters", new OperatorParameterFactory());
and the OperatorParameterFactory is:
public static class OperatorParameterFactory extends
AbstractObjectCreationFactory {
@Override
public Object createObject(Attributes arg0) throws Exception {
String operatorType = arg0.getValue("type");
OperatorParameter result = null;
try {
result = (OperatorParameter) Class.forName
(operatorType).newInstance();
}catch ( ClassNotFoundException e) {
throw new UnsupportedOperationException("OperatorParameter named
"+operatorType+" is not supported yet");
}
return result;
}
}
thanks for any support you can provide,
valerio
--
To Iterate is Human, to Recurse, Divine
James O. Coplien, Bell Labs