commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r687117 - in /commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils: BeanUtilsBean.java PropertyUtilsBean.java
Date Tue, 19 Aug 2008 18:19:37 GMT
Author: niallp
Date: Tue Aug 19 11:19:36 2008
New Revision: 687117

URL: http://svn.apache.org/viewvc?rev=687117&view=rev
Log:
BEANUTILS-326 Iterating by key/value pairs in Map in BeanUtilsBean.populate(...) method -
reported by Vladimir Orlov

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

Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/BeanUtilsBean.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/BeanUtilsBean.java?rev=687117&r1=687116&r2=687117&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/BeanUtilsBean.java
(original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/BeanUtilsBean.java
Tue Aug 19 11:19:36 2008
@@ -262,12 +262,12 @@
                 }
             }
         } else if (orig instanceof Map) {
-            Iterator names = ((Map) orig).keySet().iterator();
-            while (names.hasNext()) {
-                String name = (String) names.next();
+            Iterator entries = ((Map) orig).entrySet().iterator();
+            while (entries.hasNext()) {
+                Map.Entry entry = (Map.Entry) entries.next();
+                String name = (String)entry.getKey();
                 if (getPropertyUtils().isWriteable(dest, name)) {
-                    Object value = ((Map) orig).get(name);
-                    copyProperty(dest, name, value);
+                    copyProperty(dest, name, entry.getValue());
                 }
             }
         } else /* if (orig is a standard JavaBean) */ {
@@ -816,18 +816,18 @@
         }
 
         // Loop through the property name/value pairs to be set
-        Iterator names = properties.keySet().iterator();
-        while (names.hasNext()) {
+        Iterator entries = properties.entrySet().iterator();
+        while (entries.hasNext()) {
 
             // Identify the property name and value(s) to be assigned
-            String name = (String) names.next();
+            Map.Entry entry = (Map.Entry)entries.next();
+            String name = (String) entry.getKey();
             if (name == null) {
                 continue;
             }
-            Object value = properties.get(name);
 
             // Perform the assignment for this property
-            setProperty(bean, name, value);
+            setProperty(bean, name, entry.getValue());
 
         }
 

Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/PropertyUtilsBean.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/PropertyUtilsBean.java?rev=687117&r1=687116&r2=687117&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/PropertyUtilsBean.java
(original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/PropertyUtilsBean.java
Tue Aug 19 11:19:36 2008
@@ -259,16 +259,16 @@
                 }
             }
         } else if (orig instanceof Map) {
-            Iterator names = ((Map) orig).keySet().iterator();
-            while (names.hasNext()) {
-                String name = (String) names.next();
+            Iterator entries = ((Map) orig).entrySet().iterator();
+            while (entries.hasNext()) {
+                Map.Entry entry = (Map.Entry) entries.next();
+                String name = (String)entry.getKey();
                 if (isWriteable(dest, name)) {
                     try {
-                        Object value = ((Map) orig).get(name);
                         if (dest instanceof DynaBean) {
-                            ((DynaBean) dest).set(name, value);
+                            ((DynaBean) dest).set(name, entry.getValue());
                         } else {
-                            setSimpleProperty(dest, name, value);
+                            setSimpleProperty(dest, name, entry.getValue());
                         }
                     } catch (NoSuchMethodException e) {
                         if (log.isDebugEnabled()) {



Mime
View raw message