How to call java reflection when you don't know the parameter type -
i want save parameter name, type , value in xml file , call , set object values through reflection. example:
<object type="objecttype"> <param name="param" type="integer" value="500"></param> <param name="param2" type="bigdecimal" value="500"></param> </object> class c = class.forname("objecttype"); object parsedobj = c.newinstance(); class paramclass = class.forname("java.math.bigdecimal"); method method = c.getdeclaredmethod(attribute.getparam(), new class[]{paramclass}); // here problem, not know how cast object correct object type. method.invoke(parsedobj, new bigdecimal("500"));
if know how parse object value "500" paramclass, please me answering thread.
thanks.
Comments
Post a Comment