craigmcc 2002/11/23 15:47:07
Modified: beanutils/src/java/org/apache/commons/beanutils
PropertyUtils.java
Log:
Correctly copy properties from a standard JavaBean to a DynaBean.
PR: Bugzilla #14667
Submitted by: Brian Topping <topping at digidemic.com>
Revision Changes Path
1.33 +16 -14
jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/PropertyUtils.java
Index: PropertyUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/PropertyUtils.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- PropertyUtils.java 22 Oct 2002 06:48:32 -0000 1.32
+++ PropertyUtils.java 23 Nov 2002 23:47:07 -0000 1.33
@@ -277,9 +277,13 @@
while (names.hasNext()) {
String name = (String) names.next();
Object value = ((Map) orig).get(name);
- setSimpleProperty(dest, name, value);
+ try {
+ setSimpleProperty(dest, name, value);
+ } catch (NoSuchMethodException e) {
+ ; // Skip non-matching property
+ }
}
- } else {
+ } else /* orig is a standard JavaBean */ {
PropertyDescriptor origDescriptors[] =
getPropertyDescriptors(orig);
for (int i = 0; i < origDescriptors.length; i++) {
@@ -294,13 +298,11 @@
continue; // This is a write-only property
}
String name = origDescriptors[i].getName();
- if (getPropertyDescriptor(dest, name) != null) {
- Object value = getSimpleProperty(orig, name);
- try {
- setSimpleProperty(dest, name, value);
- } catch (NoSuchMethodException e) {
- ; // Skip non-matching property
- }
+ Object value = getSimpleProperty(orig, name);
+ try {
+ setSimpleProperty(dest, name, value);
+ } catch (NoSuchMethodException e) {
+ ; // Skip non-matching property
}
}
}
@@ -969,7 +971,7 @@
* same name resolution rules used by <code>getPropertyDescriptor()</code>,
* so if the last element of a name reference is indexed, the property
* editor for the underlying property's class is returned.</p>
- *
+ *
* <p>Note that <code>null</code> will be returned if there is no property,
* or if there is no registered property editor class. Because this
* return value is ambiguous, you should determine the existence of the
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>