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 Mon, 14 Apr 2003 21:30:25 GMT
On Sunday, April 13, 2003, at 08:41 PM, Mohan Kishore wrote:

> --- robert burrell donkin <robertburrelldonkin@blueyonder.co.uk> wrote:
>>> I would find the following algo more initutive - any comments:
>>> String p = (String) parameters[i];
>>> if (paramTypes[i].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'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.
>
> how about the case when the user wants the missing parameters to be 
> passed in
> as nulls? We need to ensure that missing primitives are converted to their
> default values. I guess what I am saying is that the wrapper converters 
> should
> have a default value, and all other converters should return null when 
> null is
> being converted...

should have consulted the javadocs before opening my mouth :)

ConvertUtils only takes strings so an additional test that makes sure 
nulls are tested is the right fix.

- 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