You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Affan Qureshi <qu...@etilize.com> on 2003/05/24 12:38:44 UTC

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


Re: PropertyUtils.copyProperties()

Posted by Reinhard Nägele <re...@mgm-edv.de>.
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
>
>  
>


RE: PropertyUtils.copyProperties()

Posted by Steve Raeburn <st...@ninsky.com>.
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