Author: adrianc
Date: Wed Apr 25 16:23:29 2012 New Revision: 1330390 URL: http://svn.apache.org/viewvc?rev=1330390&view=rev Log: FlexibleMapAccessor improvement - fixed inconsistent toString() results. 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=1330390&r1=1330389&r2=1330390&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 Wed Apr 25 16:23:29 2012 @@ -44,7 +44,7 @@ public class FlexibleMapAccessor<T> impl public static final String module = FlexibleMapAccessor.class.getName(); protected static final UtilCache<String, FlexibleMapAccessor<?>> fmaCache = UtilCache.createUtilCache("flexibleMapAccessor.ExpressionCache"); @SuppressWarnings("unchecked") - protected static final FlexibleMapAccessor nullFma = new FlexibleMapAccessor(null); + protected static final FlexibleMapAccessor nullFma = new FlexibleMapAccessor(""); protected final String original; protected final String bracketedOriginal; @@ -102,7 +102,7 @@ public class FlexibleMapAccessor<T> impl } public boolean isEmpty() { - return this.original == null; + return this.original.length() == 0; } /** Given the name based information in this accessor, get the value from the passed in Map. @@ -198,9 +198,6 @@ public class FlexibleMapAccessor<T> impl @Override public String toString() { - if (this.isEmpty()) { - return super.toString(); - } return this.original; } 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=1330390&r1=1330389&r2=1330390&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 Wed Apr 25 16:23:29 2012 @@ -124,7 +124,7 @@ public class FlexibleMapAccessorTests ex assertTrue(label + ":map-isEmpty-null", testMap.isEmpty()); assertSame(label + ":same-null", fmaNull, fma); assertSame(label + ":same-empty", fmaEmpty, fma); - assertNull(label + ":original-name", fma.getOriginalName()); + assertEquals(label + ":original-name", "", fma.getOriginalName()); assertNull(label + ":remove", fma.remove(testMap)); assertNotNull(label + ":toString", fma.toString()); } @@ -133,7 +133,7 @@ public class FlexibleMapAccessorTests ex // should follow the FlexibleStringExpander tests. public void testFlexibleMapAccessor() { fmaEmptyTest("fmaEmpty", ""); - fmaEmptyTest("fmaNull", ""); + fmaEmptyTest("fmaNull", null); fmaEmptyTest("fma\"null\"", "null"); fmaTest("UEL auto-vivify Map", "parameters.var", "Hello ${parameters.var}!", "World", "Hello World!"); fmaTest("UEL auto-vivify List", "parameters.someList[0]", "parameters.someList[+0]", "Hello ${parameters.someList[0]}!", null, "World", "Hello World!"); |
Free forum by Nabble | Edit this page |