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
public class Expression<T> extends Object
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
Fields Modifier and Type Field Description protected de.odysseus.el.TreeValueExpressionvalueExpressionThe underlying EL expression that this object represents. 
- 
Constructor Summary
Constructors Modifier Constructor Description protectedExpression(String expression, Class<T> expectedType, Bindings initialBindings)Constructs an expression for later evaluation. 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Teval()Convenient method to eval an Expression that does not need a scope.Teval(Bindings bindings)Evaluates the expression within the specified bindings and returns the resulting object if it matches the specified type, ornullif it does not resolve or match.Promise<T,NeverThrowsException>evalAsync(Bindings bindings)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 withnullif it does not resolve or match.StringtoString()Returns the original string used to create this expression, unmodified.static <T> Expression<T>valueOf(String expression, Class<T> expectedType)Factory method to create an Expression.static <T> Expression<T>valueOf(String expression, Class<T> expectedType, Bindings initialBindings)Factory method to create an Expression. 
 - 
 
- 
- 
Constructor Detail
- 
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 Detail
- 
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
public Promise<T,NeverThrowsException> evalAsync(Bindings bindings)
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 withnullif 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 
nullif it does not resolve or match the type. 
 
- 
eval
public T eval(Bindings bindings)
Evaluates the expression within the specified bindings and returns the resulting object if it matches the specified type, ornullif it does not resolve or match.- Parameters:
 bindings- the bindings to evaluate the expression within.- Returns:
 - the result of the expression evaluation, or 
nullif it does not resolve or match the type. 
 
- 
eval
public T eval()
Convenient method to eval an Expression that does not need a scope.- Returns:
 - the result of the expression evaluation, or 
nullif it does not resolve or match the type. 
 
- 
toString
public String 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)
 
 - 
 
 -