commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <robertburrelldon...@blueyonder.co.uk>
Subject Re: [Digester] problem calling methods with a primitive parameter
Date Sun, 13 Apr 2003 17:46:22 GMT
On Sunday, April 13, 2003, at 02:58 AM, Mohan Kishore wrote:

> One question reg. CallMethodRule: why was the parameters changed from 
> String[]
> to Object[]?

this allows parameters to be set in more flexible ways (rather than just 
from the xml). in particular, this changed allowed parameters to be set to 
objects on the main digester stack. the present code should ensure that 
these objects are not be converted but strings are.

> I would find the following algo more initutive - any comments:
> String p = (String) parameters[i];
> if (paramTypes.equals(String.class)) {
>     paramValues[i] = p;
> } else if (paramTypes[i].isPrimitive()) {
>     paramValues[i] = ConvertUtils.convert(p, paramTypes[i]);
> } else if (parameters[i] != null) {
>     paramValues[i] = ConvertUtils.convert(p, paramTypes[i]);
> } else {
>     paramValues[i] = null;
> }
>
> i.e.
> if String no conversion
> elseif is primitive value cannot be null, hence convert
> else is object, hence convert if not null

i'm now thinking along the lines that maybe all nulls and any objects 
which are not compatible with the given parameter type should be converted.
  this should be backwards compatible (the exception thrown when an 
incompatible type is passed prevents digestion continuing) and give extra 
functionality whilst probably also fixing the reported problem. what do 
people think about this plan?

> btw, the subject line mentioned that the problem is related to a missing
> attribute in the XML file. From the code I understand that if the method 
> takes
> in a single value from the attribute and that attribute is missing, then 
> the
> method never gets called... Am i missing something here?

i'm not sure and that's why i'd like more information. i'm having trouble 
constructing a test case and without a failed test case, i'm very 
reluctant to patch.

- robert


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message