Author: henrib Date: Thu Jan 7 21:35:19 2010 New Revision: 897021 URL: http://svn.apache.org/viewvc?rev=897021&view=rev Log: Fixed bad error messages in case of errors (thanks Sebb); Added JEXL-46 to changes and documented regex operators syntax; Updated package documentation to reflect last changes (public fields as properties, class as namespace)
Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/Interpreter.java commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/package.html commons/proper/jexl/trunk/xdocs/changes.xml commons/proper/jexl/trunk/xdocs/reference/syntax.xml Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/Interpreter.java URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/Interpreter.java?rev=897021&r1=897020&r2=897021&view=diff ============================================================================== --- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/Interpreter.java (original) +++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/Interpreter.java Thu Jan 7 21:35:19 2010 @@ -667,7 +667,7 @@ try { return arithmetic.matches(left, right) ? Boolean.TRUE : Boolean.FALSE; } catch (RuntimeException xrt) { - throw new JexlException(node, ">= error", xrt); + throw new JexlException(node, "=~ error", xrt); } } @@ -991,7 +991,7 @@ try { return arithmetic.matches(left, right) ? Boolean.FALSE : Boolean.TRUE; } catch (RuntimeException xrt) { - throw new JexlException(node, ">= error", xrt); + throw new JexlException(node, "!~ error", xrt); } } Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/package.html URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/package.html?rev=897021&r1=897020&r2=897021&view=diff ============================================================================== --- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/package.html (original) +++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/package.html Thu Jan 7 21:35:19 2010 @@ -207,7 +207,6 @@ {...@link org.apache.commons.jexl2.JexlEngine#setClassLoader} indicates to a JexlEngine which class loader to use to solve a class name; this affects how JexlEngine.newInstance and the 'new' script method operates. This is mostly usefull in cases where you rely on JEXL to dynamically load and call plugins for your application. - This </p> <p> JexlEngine and UnifiedJEXL expression caches can be configured as well. If you intend to use JEXL @@ -221,7 +220,7 @@ <p>{...@link org.apache.commons.jexl2.JexlEngine#setCache} will set how many expressions can be simultaneously cached by the JEXL engine. UnifiedJEXL allows to define the cache size through its constructor.</p> <p> - {...@link org.apache.commons.jexl2.JexlEngine#setFunctions} extend JEXL scripting by registering functions in + {...@link org.apache.commons.jexl2.JexlEngine#setFunctions} extends JEXL scripting by registering functions in namespaces. </p> This can be used as in: @@ -243,13 +242,16 @@ o = e.evaluate(jc); assertEquals(Double.valueOf(-1),o); </code></pre> + If the <i>namespace</i> is a Class and that class declares a constructor that takes a JexlContext (or + a class extending JexlContext), one <i>namespace</i> instance is created on first usage in an + expression; this instance lifetime is limited to the expression evaluation. <h2><a name="customization">JEXL Customization</a></h2> If you need to make JEXL treat some objects in a specialized manner or tweak how it reacts to some settings, you can derive most of its inner-workings. <p> {...@link org.apache.commons.jexl2.JexlEngine} is meant to be - extended and let you capture your own configuration defaults wrt cache sizes and various flags. + extended and lets you capture your own configuration defaults wrt cache sizes and various flags. Implementing your own cache - instead of the basic LinkedHashMap based one - would be another possible extension. </p> @@ -268,7 +270,7 @@ <p> {...@link org.apache.commons.jexl2.introspection.UberspectImpl} is the class to derive if you need to add introspection or reflection capabilities for some objects. - The code already optionally reflects public fields as properties on top of Java-beans conventions. + The code already reflects public fields as properties on top of Java-beans conventions. </p> </body> </html> Modified: commons/proper/jexl/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/xdocs/changes.xml?rev=897021&r1=897020&r2=897021&view=diff ============================================================================== --- commons/proper/jexl/trunk/xdocs/changes.xml (original) +++ commons/proper/jexl/trunk/xdocs/changes.xml Thu Jan 7 21:35:19 2010 @@ -28,6 +28,7 @@ <release version="2.0" date="unreleased"> <action dev="henrib" type="add" issue="JEXL-27" due-to="Weikuo Liaw">Bean-ish & ant-ish like assignment</action> <action dev="henrib" type="add" issue="JEXL-19" due-to="Jesse Glick">Ternary operator support</action> + <action dev="henrib" type="add" issue="JEXL-46" due-to="Alfred Reibenschuh">adding Perl-like regular-expression operators</action> <action dev="henrib" type="add" issue="JEXL-41" due-to="Alejandro Torras">Support for ${...} and #{...} expressions</action> <action dev="henrib" type="add" issue="JEXL-15" due-to="Paul Libbrecht">User definable functions</action> <action dev="sebb" type="add" issue="JEXL-63">JSR-223 support</action> Modified: commons/proper/jexl/trunk/xdocs/reference/syntax.xml URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/xdocs/reference/syntax.xml?rev=897021&r1=897020&r2=897021&view=diff ============================================================================== --- commons/proper/jexl/trunk/xdocs/reference/syntax.xml (original) +++ commons/proper/jexl/trunk/xdocs/reference/syntax.xml Thu Jan 7 21:35:19 2010 @@ -376,6 +376,24 @@ </td> </tr> <tr> + <td>Regex match <code>=~</code></td> + <td> + The Perl inspired <code>=~</code> operator can be used to check that a <code>string</code> matches + a regular expression (expressed either a Java String or a java.util.regex.Pattern). + For example + <code>"abcdef" =~ "abc.*</code> returns <code>true</code>. + </td> + </tr> + <tr> + <td>Regex no-match <code>!~</code></td> + <td> + The Perl inspired <code>!~</code> operator can be used to check that a <code>string</code> does not + match a regular expression (expressed either a Java String or a java.util.regex.Pattern). + For example + <code>"abcdef" !~ "abc.*</code> returns <code>false</code>. + </td> + </tr> + <tr> <td>Addition</td> <td> The usual <code>+</code> operator is used.