# Package org.apache.commons.jexl

Provides a framework for evaluating JEXL expressions.

See: Description

Interface Summary
Interface | Description
--- | ---
Expression | Represents a single JEXL expression.
JexlContext | Holds a Map of variables which are referenced in a JEXL expression.
JexlExprResolver | A Resolver allows custom resolution of the expression, and can be added in front of the jexl engine, or after in the evaluation.
Script | A JEXL Script.

Class Summary
Class | Description
--- | ---
ExpressionFactory | Creates Expression objects.
JexlHelper | Helper to create a context.
ScriptFactory | Creates `Script`s.

Exception Summary
Exception | Description
--- | ---
JexlException | Signals an error inside JEXL.

## Package org.apache.commons.jexl Description

Provides a framework for evaluating JEXL expressions.

- Introduction
- Brief Example

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