commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <skitch...@apache.org>
Subject Re: Converting properties to String
Date Thu, 09 Jun 2005 03:59:26 GMT
On Wed, 2005-06-08 at 23:18 -0400, Laurie Harper wrote:
> I understand how to use the Converter interface with BeanUtils to 
> convert String data to a target type. How do I do the reverse? In other 
> words, how to I extend the standard type of X --> String conversions?
> 
> I realise I can call getConvertUtils().register(myConverter, 
> String.class) but that would replace the default to-String conversions, 
> which is not what I want.
> 
> I could get the default converter with 
> getConvertUtils.lookup(String.class) and pass that into my converter, 
> allowing me to delegate to it when the source type of the property is 
> not one I'm interested in, but that seems a little cumbersome.
> 
> Is there an easier / better way?

ConvertUtils really isn't designed to handle custom mappings to string.
It is fundamemtally about mapping strings (from xml input, or from web
forms, etc) to objects. So I don't think there *is* an elegant solution
to your question within ConvertUtils.

If you need a general type-conversion framework you might like to look
at http://morph.sourceforge.net/

Regards,

Simon


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


Mime
View raw message