Package org.vedantatree.expressionoasis
Class ExpressionEngine
- java.lang.Object
-
- org.vedantatree.expressionoasis.ExpressionEngine
-
public final class ExpressionEngine extends Object
It is a Utility class for XpressionEngine Framework. It provides utility methods for accessing various functionalities of the Framework. A few points to consider -If any of the sub-expression is returning Type.ANY_TYPE, i.e. type will be decided at runtime. -If any of the sub-expression is returning Type.ANY_TYPE, the whole expression will return Type.ANY_TYPE -If expression contains XML expression, XML document 'URL' should be set as property to Context before executing the expression -In case of XML expression, it will always return the String value as it does not have any way to identify the required type of the value - To override all above, currently we are getting only string type value from XML expressions- Since:
- 3.1
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Expression
compileExpression(String expression, ExpressionContext expressionContext, boolean validate)
Compiles the expression string and prepares the expression tree with relevant Expression's objects.static Object
evaluate(String expression, ExpressionContext expressionContext)
Evaluates the expression and returns the resultstatic Grammar
getGrammar()
static Set<String>
getVariableNames(String expression)
Retrieves a set of variable names contained within the specified expression stringstatic void
main(String[] args)
-
-
-
Method Detail
-
getGrammar
public static Grammar getGrammar()
-
evaluate
public static Object evaluate(String expression, ExpressionContext expressionContext) throws ExpressionEngineException
Evaluates the expression and returns the result- Parameters:
expression
- the expression to evaluateexpressionContext
- the object contains the contextual information, which may be required for expression evaluation. It may be like an Java Bean in case of property expression- Returns:
- the result of expression
- Throws:
ExpressionEngineException
- if unable to parse the expression
-
compileExpression
public static Expression compileExpression(String expression, ExpressionContext expressionContext, boolean validate) throws ExpressionEngineException
Compiles the expression string and prepares the expression tree with relevant Expression's objects.- Parameters:
expression
- the expression to compileexpressionContext
- the object contains the contextual information, which may be required for expression evaluation. It may be like an Java Bean in case of property expressionvalidate
- true if the operands should be validated- Returns:
- compiled Expression object. It is actually a tree of Expression Objects
- Throws:
ExpressionEngineException
- if unable to compile the expression
-
getVariableNames
public static Set<String> getVariableNames(String expression) throws ExpressionEngineException
Retrieves a set of variable names contained within the specified expression string- Parameters:
expression
- the expression to extract the variable names for- Returns:
- a set of variable names contained within the specified expression string
- Throws:
ExpressionEngineException
-
main
public static void main(String[] args) throws ExpressionEngineException
- Throws:
ExpressionEngineException
-
-