About Us Home Contributors License Components Sandbox Commons Jexl Overview API Documentation Examples Release Builds Nightly Builds Reference JEXL Wiki Project Documentation About Commons JEXL Downloads Project Info Project Reports Development Process General Information Charter Volunteering Contributing Patches Releasing Components Jakarta Community Get Involved Mailing Lists Access CVS Repositories Commons Resources (Unofficial) Wiki Japanese Translation Korean Translation Related Apache Commons DB Commons XML Commons | ### Java Expression Language (JEXL) Java Expression Language (JEXL) is an expression language engine which can be embedded in applications and frameworks. JEXL is inspired by Jakarta Velocity and the Expression Language defined in the JavaServer Pages Standard Tag Library version 1.1 (JSTL) and JavaServer Pages version 2.0 (JSP). JEXL attempts to bring some of the lessons learned by the Velocity community about expression languages in templating to a wider audience. Commons Jelly needed Velocity-ish method access, it just had to have it. It must be noted that JEXL is not a compatibile implementation of EL as defined in JSTL 1.1 (JSR-052) or JSP 2.0 (JSR-152). For a compatible implementation of these specifications, see the Commons EL project. ### A Brief Example When evaluating expressions, JEXL merges an Expression with a JexlContext . An Expression is created using ExpressionFactory.createExpression() , passing a String containing valid JEXL syntax. A JexlContext is created using JexlHelper.createContext() , and variables are put into a map exposed through the getVars() method on JexlContext. The following example, takes a variable named foo, and invokes the bar() method on the property innerFoo:
        // Create an expression object
        String jexlExp = "foo.innerFoo.bar()";
        Expression e = ExpressionFactory.createExpression( jexlExp );

        // Create a context and add data
        JexlContext jc = JexlHelper.createContext();
        jc.getVars().put("foo", new Foo() );

        // Now evaluate the expression, getting the result
        Object o = e.evaluate(jc);
### Extensions to JSTL Expression Language While JEXL is similar to the expression language defined in JSTL, it has improved upon the syntax in a few areas: Support for invocation of any accessible method (see example above). Added a general size() method, which works on: String - returns length Map - returns number of keys List - returns number of elements. Optional syntax for the 'empty' function : empty(obj) Misc : '+' has been overloaded to be use as a String concatenation operator ### Releases JEXL is not yet released, but a nightly build can be downloaded. See the downloads page for information on obtaining releases. ### Related Resources JEXL is not a product of the Java Community Process (JCP), but it provides a similar expression syntax. For more information about JSP 2.0 EL and JSTL 1.1 EL: JSP 2.0 is covered by Java Specification Requests (JSR) JSR-152: JavaServer Pages 2.0 Specification . Apache has an implementation of the expression language for JSP 2.0, called EL JSTL 1.1 is covered by JSR 52: A Standard Tag Library for JavaServer Pages . See the JSTL API . Apache has a JSTL Implementation . #### Velocity Jakarta Velocity implements a similar expression language. In particular the References section of the User Guide has some good information on properties and method which correlate directly to JEXL. ### Anyone Using It Yet? Jelly