Package org.forgerock.openig.el
Class Expression<T>
java.lang.Object
org.forgerock.openig.el.Expression<T>
- Type Parameters:
T
- expected result type
- Direct Known Subclasses:
LeftValueExpression
An Unified Expression Language expression. Creating an expression is the equivalent to
compiling it. Once created, an expression can be evaluated within a supplied scope. An
expression can safely be evaluated concurrently in multiple threads.
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
Expression
(String expression, Class<T> expectedType, Bindings initialBindings) Constructs an expression for later evaluation. -
Method Summary
Modifier and TypeMethodDescriptioneval()
Convenient method to eval an Expression that does not need a scope.Evaluates the expression within the specified bindings and returns the resulting object if it matches the specified type, ornull
if it does not resolve or match.Evaluates asynchronously the expression with the specified bindings and returns a promise of the resulting object if it matches the specified type, or a promise completed withnull
if it does not resolve or match.toString()
Returns the original string used to create this expression, unmodified.static <T> Expression<T>
Factory method to create an Expression.static <T> Expression<T>
Factory method to create an Expression.
-
Field Details
-
CLOCK_BINDING_KEY
The key of theClock
when it is added to bindings.- See Also:
-
valueExpression
protected final de.odysseus.el.TreeValueExpression valueExpressionThe underlying EL expression that this object represents.
-
-
Constructor Details
-
Expression
protected Expression(String expression, Class<T> expectedType, Bindings initialBindings) throws ExpressionException Constructs an expression for later evaluation.- Parameters:
expression
- the expression to parse.expectedType
- The expected result type of the expression.initialBindings
- The initial bindings used when evaluated this expression- Throws:
ExpressionException
- if the expression was not syntactically correct.
-
-
Method Details
-
valueOf
public static <T> Expression<T> valueOf(String expression, Class<T> expectedType) throws ExpressionException Factory method to create an Expression.- Type Parameters:
T
- expected result type- Parameters:
expression
- The expression to parse.expectedType
- The expected result type of the expression.- Returns:
- An expression based on the given string.
- Throws:
ExpressionException
- if the expression was not syntactically correct.
-
valueOf
public static <T> Expression<T> valueOf(String expression, Class<T> expectedType, Bindings initialBindings) throws ExpressionException Factory method to create an Expression.- Type Parameters:
T
- expected result type- Parameters:
expression
- The expression to parse.expectedType
- The expected result type of the expression.initialBindings
- The initial bindings used when evaluated this expression- Returns:
- An expression based on the given string.
- Throws:
ExpressionException
- if the expression was not syntactically correct.
-
evalAsync
Evaluates asynchronously the expression with the specified bindings and returns a promise of the resulting object if it matches the specified type, or a promise completed withnull
if it does not resolve or match.If this expression requires asynchronous processing (declared using "#{...}"), then the evaluation is triggered on completion of the
Bindings
.Otherwise it's evaluated immediately.
- Parameters:
bindings
- the bindings to evaluate the expression within.- Returns:
- a promise containing the result of the expression evaluation, or containing
null
if it does not resolve or match the type.
-
eval
Evaluates the expression within the specified bindings and returns the resulting object if it matches the specified type, ornull
if it does not resolve or match.- Parameters:
bindings
- the bindings to evaluate the expression within.- Returns:
- the result of the expression evaluation, or
null
if it does not resolve or match the type.
-
eval
Convenient method to eval an Expression that does not need a scope.- Returns:
- the result of the expression evaluation, or
null
if it does not resolve or match the type.
-
toString
Returns the original string used to create this expression, unmodified.Note to implementors: That returned value must be usable in Expression.valueOf() to create an equivalent Expression(somehow cloning this instance)
-