Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Package org.apache.commons.jexl.util

Provides a framework for evaluating JEXL expressions.

See:
          Description

Class Summary
AbstractExecutor Abstract class that is used to execute an arbitrary method that is in introspected.
ArrayIterator An Iterator wrapper for an Object[].
BooleanPropertyExecutor Handles discovery and valuation of a boolean object property, of the form public boolean is when executed.
Coercion Coercion utilities for the JSTL EL-like coercion.
EnumerationIterator An Iterator wrapper for an Enumeration.
GetExecutor Executor that simply tries to execute a get(key) operation.
Introspector Little class to manage a Velocity uberspector (Vel 1.4+) for instrospective services
PropertyExecutor Returned the value of object property when executed.
 

Package org.apache.commons.jexl.util Description

Provides a framework for evaluating JEXL expressions.

Introduction

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);