Module jakarta.el
Package jakarta.el

Class ELProcessor

java.lang.Object
jakarta.el.ELProcessor

public class ELProcessor extends Object
Provides an API for using Jakarta Expression Language in a stand-alone environment.

This class provides a direct and simple interface for

  • Evaluating Jakarta Expression Language expressions.
  • Assigning values to beans or setting a bean property.
  • Setting a ValueExpression to a Jakarta Expression Language variable.
  • Defining a static method as Jakarta Expression Language function.
  • Defining an object instance as Jakarta Expression Language name.

This API is not a replacement for the APIs in Jakarta Expression Language 2.2. Containers that maintain Jakarta Expression Language environments can continue to do so, without using this API.

For Jakarta Expression Language users who want to manipulate Jakarta Expression Language environments, like adding custom ELResolvers, ELManager can be used.

Scope and Life Cycle

Since it maintains the state of the Jakarta Expression Language environments, ELProcessor is not thread safe. In the simplest case, an instance can be created and destroyed before and after evaluating Jakarta Expression Language expressions. A more general usage is to use an instance of ELProcessor for a session, so that the user can configure the Jakarta Expression Language evaluation environment for that session.

Automatic Bracketing of Expressions

A note about the Jakarta Expression Language expressions strings used in the class. The strings allowed in the methods getValue(java.lang.String, java.lang.Class<T>), setValue(java.lang.String, java.lang.Object), and setVariable(java.lang.String, java.lang.String) are limited to non-composite expressions, i.e. expressions of the form ${...} or #{...} only. Also, it is not necessary (in fact not allowed) to bracket the expression strings with ${ or #{ and } in these methods: they will be automatically bracketed. This reduces the visual cluster, without any lost of functionalities (thanks to the addition of the concatenation operator).

Example

The following code snippet illustrates the use of ELProcessor to define a bean and evaluate its property.
 ELProcessor elp = new ELProcessor();
 elp.defineBean("employee", new Employee("Charlie Brown"));
 String name = elp.eval("employee.name");
 
Since:
Jakarta Expression Language 3.0