Package nl.rrd.wool.expressions
Interface Expression
-
- All Known Implementing Classes:
AddExpression,AndExpression,AssignExpression,DivideExpression,DotExpression,EqualExpression,GreaterEqualExpression,GreaterThanExpression,GroupExpression,IndexExpression,InExpression,LessEqualExpression,LessThanExpression,ListExpression,MultiplyExpression,NotEqualExpression,NotExpression,NotStrictEqualExpression,ObjectExpression,OrExpression,StrictEqualExpression,StringExpression,SubtractExpression,ValueExpression
public interface ExpressionAn expression is some code that can be evaluated as aValue. Instances can be obtained from text input using theExpressionParser. It has one method:evaluate(), which takes a map of variables. The expression may contain variable names and their values will be taken from the map. A variable name that is not included in the map, will be evaluated as null. The variable values should be the same elementary types as inValue. That is one of the following:Each element of a list or map should also be one of these types.
-
-
Method Summary
Modifier and Type Method Description Valueevaluate(Map<String,Object> variables)Evaluates this expression using the specified variable values.List<Expression>getChildren()Returns the child expressions of this expression.List<Expression>getDescendants()Returns all descendant expressions of this expression.Set<String>getVariableNames()Returns all variable names that occur in this expression and its descendants.
-
-
-
Method Detail
-
evaluate
Value evaluate(Map<String,Object> variables) throws EvaluationException
Evaluates this expression using the specified variable values. The variable map may be modified as a result of an "assign" expression.- Parameters:
variables- the variable values (can be null)- Returns:
- the value of the expression
- Throws:
EvaluationException- if the expression can't be evaluted with the specified variables
-
getChildren
List<Expression> getChildren()
Returns the child expressions of this expression.- Returns:
- the child expressions
-
getDescendants
List<Expression> getDescendants()
Returns all descendant expressions of this expression.- Returns:
- the descendant expressions
-
-