commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Reinhard Nägele <reinhard.naeg...@mgm-edv.de>
Subject Re: PropertyUtils.copyProperties()
Date Mon, 26 May 2003 14:36:21 GMT
You could use BeanUtils.copyProperty() in order to copy only the 
properties you wish to.

Naily


Steve Raeburn wrote:

>Use BeanUtils.describe() to create a Map of your source bean
>Remove the values your don't need from the Map
>Use BeanUtils.populate to copy the properties from the Map to your
>destination bean.
>
>For example. Assume you have a bean, of type SourceBean and you don't want
>to copy a property called 'unwantedProperty'...
>
>  Map tmp = BeanUtils.describe(source);
>  tmp.remove("unwantedProperty");
>  DestinationBean dest = new DestinationBean();
>  BeanUtils.populate(dest, tmp);
>
>Hope that helps
>
>Steve
>
>-----Original Message-----
>From: Affan Qureshi [mailto:quereshi@etilize.com]
>Sent: May 24, 2003 3:39 AM
>To: commons-user@jakarta.apache.org
>Subject: PropertyUtils.copyProperties()
>
>
>Both BeanUtils.copyProperties() and PropertyUtils.copyProperties() are very
>useful functions. Is it possible for me to do selective copying of
>properties? I want the method (not) to copy some properties.
>
>Is this possible?
>
>Thanks,
>Affan
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>
>---------------------------------------------------------------------
>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