Package com.igormaznitsa.jcp.expression
Class Expression
- java.lang.Object
-
- com.igormaznitsa.jcp.expression.Expression
-
public class Expression extends java.lang.Object
The main class to calculate expressions
-
-
Field Summary
Fields Modifier and Type Field Description private PreprocessorContext
context
The variable contains the preprocessor context for the expression, it can be nullprivate ExpressionTree
expressionTree
The variable contains the expression treeprivate static java.lang.Class<?>[]
OPERATOR_SIGNATURE_1
Precreated array for speed up operationsprivate static java.lang.Class<?>[]
OPERATOR_SIGNATURE_2
Precreated array for speed up operations
-
Constructor Summary
Constructors Modifier Constructor Description private
Expression(PreprocessorContext context, ExpressionTree tree)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private ExpressionTreeElement
calculateTreeElement(ExpressionTreeElement element, PreprocessingState state)
private Value
eval(PreprocessingState state)
static Value
evalExpression(java.lang.String expression, PreprocessorContext context)
Evaluate expressionprivate ExpressionTreeElement
evalFunction(ExpressionTreeElement functionElement, PreprocessingState state)
private ExpressionTreeElement
evalOperator(ExpressionTreeElement operatorElement, PreprocessingState state)
static Value
evalTree(ExpressionTree tree, PreprocessorContext context)
Evaluate an expression tree
-
-
-
Field Detail
-
OPERATOR_SIGNATURE_1
private static final java.lang.Class<?>[] OPERATOR_SIGNATURE_1
Precreated array for speed up operations
-
OPERATOR_SIGNATURE_2
private static final java.lang.Class<?>[] OPERATOR_SIGNATURE_2
Precreated array for speed up operations
-
context
private final PreprocessorContext context
The variable contains the preprocessor context for the expression, it can be null
-
expressionTree
private final ExpressionTree expressionTree
The variable contains the expression tree
-
-
Constructor Detail
-
Expression
private Expression(PreprocessorContext context, ExpressionTree tree)
-
-
Method Detail
-
evalExpression
public static Value evalExpression(java.lang.String expression, PreprocessorContext context)
Evaluate expression- Parameters:
expression
- the expression as a String, must not be nullcontext
- a preprocessor context to be used for expression operations- Returns:
- the result as a Value object, it can't be null
-
evalTree
public static Value evalTree(ExpressionTree tree, PreprocessorContext context)
Evaluate an expression tree- Parameters:
tree
- an expression tree, it must not be nullcontext
- a preprocessor context to be used for expression operations- Returns:
- the result as a Value object, it can't be null
-
evalFunction
private ExpressionTreeElement evalFunction(ExpressionTreeElement functionElement, PreprocessingState state)
-
evalOperator
private ExpressionTreeElement evalOperator(ExpressionTreeElement operatorElement, PreprocessingState state)
-
calculateTreeElement
private ExpressionTreeElement calculateTreeElement(ExpressionTreeElement element, PreprocessingState state)
-
eval
private Value eval(PreprocessingState state)
-
-