commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roland Huss <Roland.H...@consol.de>
Subject [PATCH] [Bug 10478] - Can't use . (dot) in mapped properties
Date Sat, 21 Sep 2002 12:38:44 GMT
Index: src/java/org/apache/commons/beanutils/PropertyUtils.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/PropertyUtils.java,v
retrieving revision 1.30
diff -u -r1.30 PropertyUtils.java
--- src/java/org/apache/commons/beanutils/PropertyUtils.java	21 Jul 2002 00:20:44 -0000	1.30
+++ src/java/org/apache/commons/beanutils/PropertyUtils.java	21 Sep 2002 12:34:29 -0000
@@ -708,8 +708,11 @@
         int indexOfMAPPED_DELIM2 = -1;
         int indexOfNESTED_DELIM = -1;
         while (true) {
+            indexOfNESTED_DELIM  = name.indexOf(NESTED_DELIM);
+            indexOfMAPPED_DELIM  = name.indexOf(MAPPED_DELIM);
             indexOfMAPPED_DELIM2 = name.indexOf(MAPPED_DELIM2);
-            if (indexOfMAPPED_DELIM2 >= 0) {
+            if (indexOfMAPPED_DELIM2 >= 0 && indexOfMAPPED_DELIM >=0 &&
+                (indexOfNESTED_DELIM < 0 || indexOfNESTED_DELIM > indexOfMAPPED_DELIM))
{
                 indexOfNESTED_DELIM =
                     name.indexOf(NESTED_DELIM, indexOfMAPPED_DELIM2);
             } else {
Index: src/test/org/apache/commons/beanutils/PropertyUtilsTestCase.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/PropertyUtilsTestCase.java,v
retrieving revision 1.21
diff -u -r1.21 PropertyUtilsTestCase.java
--- src/test/org/apache/commons/beanutils/PropertyUtilsTestCase.java	21 Jul 2002 00:20:45
-0000	1.21
+++ src/test/org/apache/commons/beanutils/PropertyUtilsTestCase.java	21 Sep 2002 12:34:35
-0000
@@ -1103,6 +1103,32 @@
             fail("Thew exception: " + e);
         }
 
+        try 
+        {
+            assertEquals("Can't retrieved nested with mapped property",
+                         "First Value",
+                         PropertyUtils.getNestedProperty(
+                             bean,"nested.mappedProperty(First Key)"));
+        } catch (Exception e) 
+        {
+            fail("Thew exception: " + e);
+        } 
+        
+
+        bean.getNested().setMappedObjects("nested.property", new TestBean());
+        assertNotNull("Can retrieve directly",
+                      bean.getNested().getMappedObjects("nested.property"));
+        try 
+        {
+            assertEquals("Can't retrieved nested mapped property with nested key",
+                         "This is a string",
+                         PropertyUtils.getNestedProperty(
+                             bean,"nested.mappedObjects(nested.property).stringProperty"));
+        } catch (Exception e) 
+        {
+            fail("Thew exception: " + e);
+        } 
+        
     }
 
 


Mime
View raw message