Package org.openrefine.grel.ast
Interface GrelExpr
-
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
ArrayExpr
,ControlCallExpr
,FieldAccessorExpr
,FunctionCallExpr
,LiteralExpr
,OperatorCallExpr
,PureArgumentsExpr
,VariableExpr
public interface GrelExpr extends Serializable
A GREL expression, which can be evaluated in a given context.This is introduced to serve as base class for all GREL expressions, instead of
Evaluable
which is the base class for all evaluables in OpenRefine.- Author:
- Antonin Delpeuch
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Object
evaluate(Properties bindings)
Returns the value of the expression in a given context.Set<String>
getColumnDependencies(String baseColumn)
Returns the names of the columns this expression depends on.boolean
isLocal()
GrelExpr
renameColumnDependencies(Map<String,String> substitutions)
Translates this expression by simultaneously substituting column names as the supplied map specifies.String
toString()
For GREL expressions, toString should return the source code of the expression, or a source code for an equivalent expression.
-
-
-
Method Detail
-
evaluate
Object evaluate(Properties bindings)
Returns the value of the expression in a given context.- Parameters:
bindings
- the evaluation context, mapping variable names to their values- Returns:
- the result of the evaluation of the expression
-
toString
String toString()
For GREL expressions, toString should return the source code of the expression, or a source code for an equivalent expression. (without the "grel:" prefix).
-
isLocal
boolean isLocal()
- Returns:
- true when the expression can be evaluated purely based on the local context (see
Evaluable
).
-
getColumnDependencies
Set<String> getColumnDependencies(String baseColumn)
Returns the names of the columns this expression depends on.- Parameters:
baseColumn
- the name of the column this expression is based on (null if none)- Returns:
- null if the columns could not be isolated: in this case, the expression might depend on all columns in the project.
-
renameColumnDependencies
GrelExpr renameColumnDependencies(Map<String,String> substitutions)
Translates this expression by simultaneously substituting column names as the supplied map specifies.This is only possible if the extraction of column dependencies with
getColumnDependencies(String)
succeeds (return a non-null value).- Parameters:
substitutions
- a map specifying new names for some columns. If a column name is not present in the map, it is assumed that the column is not renamed.- Returns:
- a new expression with updated column names.
-
-