svn commit: r1338361 - in /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections: FlexibleMapAccessor.java test/FlexibleMapAccessorTests.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1338361 - in /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections: FlexibleMapAccessor.java test/FlexibleMapAccessorTests.java

adrianc
Author: adrianc
Date: Mon May 14 19:43:18 2012
New Revision: 1338361

URL: http://svn.apache.org/viewvc?rev=1338361&view=rev
Log:
Added a utility method to FlexibleMapAccessor.java to test for nested expressions.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleMapAccessor.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/test/FlexibleMapAccessorTests.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleMapAccessor.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleMapAccessor.java?rev=1338361&r1=1338360&r2=1338361&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleMapAccessor.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleMapAccessor.java Mon May 14 19:43:18 2012
@@ -76,6 +76,16 @@ public class FlexibleMapAccessor<T> impl
         }
     }
 
+    /**
+     * Returns <code>true</code> if <code>fma</code> contains a nested expression.
+     * @param fma
+     * @return <code>true</code> if <code>fma</code> contains a nested expression
+     * @throws NullPointerException if <code>fma</code> is null
+     */
+    public static boolean containsNestedExpression(FlexibleMapAccessor<?> fma) {
+        return fma.fse != null;
+    }
+
     /** Returns a FlexibleMapAccessor instance.
      * @param original The original String expression
      * @return A FlexibleMapAccessor instance

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/test/FlexibleMapAccessorTests.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/test/FlexibleMapAccessorTests.java?rev=1338361&r1=1338360&r2=1338361&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/test/FlexibleMapAccessorTests.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/test/FlexibleMapAccessorTests.java Mon May 14 19:43:18 2012
@@ -139,6 +139,8 @@ public class FlexibleMapAccessorTests ex
         fmaTest("UEL auto-vivify List", "parameters.someList[0]", "parameters.someList[+0]", "Hello ${parameters.someList[0]}!", null, "World", "Hello World!");
         fmaTest("fse", "para${'meter'}s.var", "Hello ${parameters.var}!", "World", "Hello World!");
         fmaTest("foo", "'The total is ${total?currency(USD)}.'", "total", "The total is ${total?currency(USD)}.", localeToTest, new BigDecimal("12345678.90"), "The total is $12,345,678.90.");
+        assertTrue("containsNestedExpression method returns true", FlexibleMapAccessor.containsNestedExpression(FlexibleMapAccessor.getInstance("Hello ${parameters.var}!")));
+        assertFalse("containsNestedExpression method returns true", FlexibleMapAccessor.containsNestedExpression(FlexibleMapAccessor.getInstance("Hello World!")));
     }
 
     public static class ThrowException {