commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r556361 - /jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/PropertyUtilsBean.java
Date Sun, 15 Jul 2007 01:07:27 GMT
Author: niallp
Date: Sat Jul 14 18:07:26 2007
New Revision: 556361

URL: http://svn.apache.org/viewvc?view=rev&rev=556361
Log:
Small re-factoring to simplify/remove duplication. 

Modified:
    jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/PropertyUtilsBean.java

Modified: jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/PropertyUtilsBean.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/PropertyUtilsBean.java?view=diff&rev=556361&r1=556360&r2=556361
==============================================================================
--- jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/PropertyUtilsBean.java
(original)
+++ jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/PropertyUtilsBean.java
Sat Jul 14 18:07:26 2007
@@ -240,11 +240,11 @@
                 ((DynaBean) orig).getDynaClass().getDynaProperties();
             for (int i = 0; i < origDescriptors.length; i++) {
                 String name = origDescriptors[i].getName();
-                // Need to check isReadable() for WrapDynaBean
-                // (see Jira issue# BEANUTILS-61)
-                if (isReadable(orig, name)) {
-                    if (isWriteable(dest, name)) {
-                        Object value = ((DynaBean) orig).get(name);
+                if (isReadable(orig, name) && isWriteable(dest, name)) {
+                    Object value = ((DynaBean) orig).get(name);
+                    if (dest instanceof DynaBean) {
+                        ((DynaBean) dest).set(name, value);
+                    } else {
                         setSimpleProperty(dest, name, value);
                     }
                 }
@@ -253,14 +253,11 @@
             Iterator names = ((Map) orig).keySet().iterator();
             while (names.hasNext()) {
                 String name = (String) names.next();
-                if (dest instanceof DynaBean) {
-                    if (isWriteable(dest, name)) {
-                        Object value = ((Map) orig).get(name);
+                if (isWriteable(dest, name)) {
+                    Object value = ((Map) orig).get(name);
+                    if (dest instanceof DynaBean) {
                         ((DynaBean) dest).set(name, value);
-                    }
-                } else /* if (dest is a standard JavaBean) */ {
-                    if (isWriteable(dest, name)) {
-                        Object value = ((Map) orig).get(name);
+                    } else {
                         setSimpleProperty(dest, name, value);
                     }
                 }
@@ -270,17 +267,12 @@
                 getPropertyDescriptors(orig);
             for (int i = 0; i < origDescriptors.length; i++) {
                 String name = origDescriptors[i].getName();
-                if (isReadable(orig, name)) {
+                if (isReadable(orig, name) && isWriteable(dest, name)) {
+                    Object value = getSimpleProperty(orig, name);
                     if (dest instanceof DynaBean) {
-                        if (isWriteable(dest, name)) {
-                            Object value = getSimpleProperty(orig, name);
-                            ((DynaBean) dest).set(name, value);
-                        }
-                    } else /* if (dest is a standard JavaBean) */ {
-                        if (isWriteable(dest, name)) {
-                            Object value = getSimpleProperty(orig, name);
-                            setSimpleProperty(dest, name, value);
-                        }
+                        ((DynaBean) dest).set(name, value);
+                    } else {
+                        setSimpleProperty(dest, name, value);
                     }
                 }
             }



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


Mime
View raw message