You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Simon Kitching <sk...@apache.org> on 2006/09/02 05:41:14 UTC
Re: [betwixt] Reading and writing objects without using
getters/setters
Hi Ryan,
On Wed, 2006-08-30 at 18:01 -0500, Ryan wrote:
> I would like to use betwixt to read and write objects from a 3rd party
> java library. Unfortunately the naming conventions used in some of
> these objects don't conform to the getter/setter properties that
> betwixt likes. Here are a few of the problems I need to address:
>
> 1. There is a class called Money which is backed by a BigDecimal that
> is accessible using the method asBigDecimal(). The object can be
> recreated using new Money(oldMoney.asBigDecimal()). Is there a way to
> tell betwixt/digestor to do the conversion by using that conversion to
> BigDecimal?
Sorry, don't know.
>
> 2. The setter methods on each of the objects return themselves instead
> of void. This appears to cause betwixt to believe the properties are
> readable but not writable. It looks like I can subclass
> XMLIntrospector so that I can modify the BeanInfo object before it is
> cached so that it knows about the writer methods, is this the best way
> to go about it?
If you have methods that don't obey the java properties spec, but want
software to treat them as properties, then the standard solution is to
write a BeanInfo class.
public class MoneyBeanInfo extends SimpleBeanInfo {
....
}
Regards,
Simon
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org