commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roland Huss <Roland.H...@consol.de>
Subject Re: [PATCH] [Bug 10478] - Can't use . (dot) in mapped properties
Date Mon, 23 Sep 2002 20:47:36 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	23 Sep 2002 20:43:56 -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	23 Sep 2002 20:44:02
-0000
@@ -1103,6 +1103,16 @@
             fail("Thew exception: " + e);
         }
 
+        try 
+        {
+            assertEquals("Can't retrieved nested with mapped property",
+                         "Mapped Value",
+                         PropertyUtils.getNestedProperty(
+                             bean,"mappedNested.value(Mapped Key)"));
+        } catch (Exception e) 
+        {
+            fail("Thew exception: " + e);
+        } 
     }
 
 
Index: src/test/org/apache/commons/beanutils/TestBean.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/TestBean.java,v
retrieving revision 1.12
diff -u -r1.12 TestBean.java
--- src/test/org/apache/commons/beanutils/TestBean.java	22 Jul 2002 00:02:01 -0000	1.12
+++ src/test/org/apache/commons/beanutils/TestBean.java	23 Sep 2002 20:44:03 -0000
@@ -347,6 +347,24 @@
     }
 
 
+    /*
+     * Another nested reference to a bean containing mapp properties
+     */
+    class MappedTestBean { 
+        public void setValue(String key,String val) { }
+        public String getValue(String key) { return "Mapped Value"; }
+    }
+    
+    private MappedTestBean mappedNested = null;
+
+    public MappedTestBean getMappedNested() { 
+        if (mappedNested == null) 
+        {
+            mappedNested = new MappedTestBean();
+        }
+        return mappedNested;
+    }
+
     /**
      * A String property with an initial value of null.
      */
@@ -442,7 +460,7 @@
         this.writeOnlyProperty = writeOnlyProperty;
     }
 
-
+    
     // ------------------------------------------------------- Static Variables
 
 


Mime
View raw message