svn commit: r764323 - in /ofbiz/trunk: LICENSE framework/base/lib/el-api-1.1.jar framework/base/lib/juel-2.1.1-rc1.jar framework/base/lib/juel-2.1.1.jar framework/base/src/org/ofbiz/base/util/string/UelFunctions.java

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

svn commit: r764323 - in /ofbiz/trunk: LICENSE framework/base/lib/el-api-1.1.jar framework/base/lib/juel-2.1.1-rc1.jar framework/base/lib/juel-2.1.1.jar framework/base/src/org/ofbiz/base/util/string/UelFunctions.java

adrianc
Author: adrianc
Date: Sun Apr 12 20:39:52 2009
New Revision: 764323

URL: http://svn.apache.org/viewvc?rev=764323&view=rev
Log:
Updated the JUEL library. Added two UEL functions for handling sequence IDs used as Map keys.

Added:
    ofbiz/trunk/framework/base/lib/juel-2.1.1.jar   (with props)
Removed:
    ofbiz/trunk/framework/base/lib/el-api-1.1.jar
    ofbiz/trunk/framework/base/lib/juel-2.1.1-rc1.jar
Modified:
    ofbiz/trunk/LICENSE
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelFunctions.java

Modified: ofbiz/trunk/LICENSE
URL: http://svn.apache.org/viewvc/ofbiz/trunk/LICENSE?rev=764323&r1=764322&r2=764323&view=diff
==============================================================================
--- ofbiz/trunk/LICENSE (original)
+++ ofbiz/trunk/LICENSE Sun Apr 12 20:39:52 2009
@@ -18,7 +18,7 @@
 ofbiz/trunk/framework/base/lib/batik-all-1.7.jar
 ofbiz/trunk/framework/base/lib/jakarta-regexp-1.5.jar
 ofbiz/trunk/framework/base/lib/jpim-0.1.jar
-ofbiz/trunk/framework/base/lib/juel-2.1.1-rc1.jar
+ofbiz/trunk/framework/base/lib/juel-2.1.1.jar
 ofbiz/trunk/framework/base/lib/log4j-1.2.15.jar
 ofbiz/trunk/framework/base/lib/mx4j-3.0.1.jar
 ofbiz/trunk/framework/base/lib/mx4j-remote-3.0.1.jar
@@ -1938,7 +1938,7 @@
 =========================================================================
 The following library distributed with Apache OFBiz is licensed under the
 COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL):
-ofbiz/trunk/framework/base/lib/el-api-1.1.jar
+ofbiz/trunk/framework/base/lib/juel-2.1.1.jar (contains the javax.el package)
 ofbiz/trunk/framework/base/lib/mail.jar
 =========================================================================
 COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 1.

Added: ofbiz/trunk/framework/base/lib/juel-2.1.1.jar
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/lib/juel-2.1.1.jar?rev=764323&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ofbiz/trunk/framework/base/lib/juel-2.1.1.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

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=764323&r1=764322&r2=764323&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 Sun Apr 12 20:39:52 2009
@@ -125,8 +125,10 @@
  * <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>
  */
@@ -134,6 +136,8 @@
 
     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
@@ -229,6 +233,8 @@
                 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);
             }
@@ -386,4 +392,18 @@
         } 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;
+    }
 }