Author: adrianc
Date: Tue Apr 14 22:53:59 2009 New Revision: 764992 URL: http://svn.apache.org/viewvc?rev=764992&view=rev Log: Changes to the UEL classes - should fix the auto-vivify issues. Removed the UEL functions that were a workaround. Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelFunctions.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelUtil.java Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelFunctions.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelFunctions.java?rev=764992&r1=764991&r2=764992&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelFunctions.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelFunctions.java Tue Apr 14 22:53:59 2009 @@ -125,10 +125,8 @@ * <tr><td colspan="2"><b><code>util:</code> contains miscellaneous utility functions</b></td></tr> * <tr><td><code>util:defaultLocale()</code></td><td>Returns the default <code>Locale</code>.</td></tr> * <tr><td><code>util:defaultTimeZone()</code></td><td>Returns the default <code>TimeZone</code>.</td></tr> - * <tr><td><code>util:fromIdentifier(String)</code></td><td>If <code>String</code> was converted to a Java identifier using <code>util:toIdentifier(String)</code>, returns the <code>String</code> in its original form.</td></tr> * <tr><td><code>util:size(Object)</code></td><td>Returns the size of <code>Maps</code>, * <code>Collections</code>, and <code>Strings</code>. Invalid <code>Object</code> types return -1.</td></tr> - * <tr><td><code>util:toIdentifier(String)</code></td><td>If <code>String</code> is not a valid Java identifier, returns <code>String</code> converted to a valid Java identifier.</td></tr> * <tr><td><code>util:urlExists(String)</code></td><td>Returns <code>true</code> if the specified URL exists.</td></tr> * </table> */ @@ -136,8 +134,6 @@ public static final String module = UelFunctions.class.getName(); protected static final FunctionMapper functionMapper = new Functions(); - protected static final String IndentifierPrefix = "_id"; - protected static final int PrefixLength = IndentifierPrefix.length(); /** Returns a <code>FunctionMapper</code> instance. * @return <code>FunctionMapper</code> instance @@ -233,8 +229,6 @@ this.functionMap.put("util:defaultLocale", Locale.class.getMethod("getDefault")); this.functionMap.put("util:defaultTimeZone", TimeZone.class.getMethod("getDefault")); this.functionMap.put("util:urlExists", UelFunctions.class.getMethod("urlExists", String.class)); - this.functionMap.put("util:toIdentifier", UelFunctions.class.getMethod("toIdentifier", String.class)); - this.functionMap.put("util:fromIdentifier", UelFunctions.class.getMethod("fromIdentifier", String.class)); } catch (Exception e) { Debug.logWarning("Error while initializing UelFunctions.Functions instance: " + e, module); } @@ -392,18 +386,4 @@ } catch (Exception e) {} return result; } - - public static String toIdentifier(String str) { - if (str != null && str.length() > 0 && !Character.isJavaIdentifierStart(str.charAt(0))) { - return IndentifierPrefix + str; - } - return str; - } - - public static String fromIdentifier(String str) { - if (str != null && str.length() > 0 && str.startsWith(IndentifierPrefix)) { - return str.substring(PrefixLength); - } - return str; - } } Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelUtil.java?rev=764992&r1=764991&r2=764992&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelUtil.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelUtil.java Tue Apr 14 22:53:59 2009 @@ -313,16 +313,16 @@ /** Evaluates a property <code>Object</code> and returns a new * <code>List</code> or <code>Map</code>. If <code>property</code> - * evaluates to an integer value, a new <code>List</code> instance - * is returned, otherwise a new <code>Map</code> instance is - * returned. + * is not a String object type and it evaluates to an integer value, + * a new <code>List</code> instance is returned, otherwise a new + * <code>Map</code> instance is returned. * @param property Property <code>Object</code> to be evaluated * @return New <code>List</code> or <code>Map</code> */ public static Object autoVivifyListOrMap(Object property) { String str = property.toString(); boolean isList = ("add".equals(str) || str.startsWith("insert@")); - if (!isList) { + if (!isList && !"java.lang.String".equals(property.getClass().getName())) { Integer index = UtilMisc.toIntegerObject(property); isList = (index != null); } @@ -350,14 +350,6 @@ result = base + "['insert@" + property + "']" + end; } result = result.replace("[]", "['add']"); - int pos = result.indexOf("."); - while (pos != -1) { - char c = result.charAt(pos + 1); - if (c >= '0' && c <= '9') { - result = result.substring(0, pos) + "._" + result.substring(pos + 1); - } - pos = result.indexOf(".", pos + 1); - } return result; } } |
Free forum by Nabble | Edit this page |