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 20:53:06 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...

this is the advantage of using ConvertUtils. the standard converters 
behave very reasonably (pretty much the way you're describing) and if this 
behaviour isn't what's wanted then the user can register custom converter 
which work in the way they want.

once the beanification work on BeanUtils has been finished, i'd probably 
like to add get/set properties for BeanUtilsBean on digester. this will 
allow more finely grained over conversions.

- 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