Package org.openrefine.grel
Class GrelEvaluable
- java.lang.Object
-
- org.openrefine.grel.GrelEvaluable
-
- All Implemented Interfaces:
Serializable
,Evaluable
public class GrelEvaluable extends Object implements Evaluable
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description GrelEvaluable(GrelExpr expr, String languagePrefix)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
evaluate(Properties bindings)
Evaluate this expression in the given environment (bindings).Set<String>
getColumnDependencies(String baseColumn)
Returns the names of the columns this expression depends on.String
getLanguagePrefix()
String
getSource()
Returns the source string which generated this expression.boolean
isLocal()
Evaluable
renameColumnDependencies(Map<String,String> substitutions)
Translates this expression by simultaneously substituting column names as the supplied map specifies.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openrefine.expr.Evaluable
getFullSource
-
-
-
-
Method Detail
-
evaluate
public Object evaluate(Properties bindings)
Description copied from interface:Evaluable
Evaluate this expression in the given environment (bindings).
-
getColumnDependencies
public Set<String> getColumnDependencies(String baseColumn)
Description copied from interface:Evaluable
Returns the names of the columns this expression depends on.- Specified by:
getColumnDependencies
in interfaceEvaluable
- 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
public Evaluable renameColumnDependencies(Map<String,String> substitutions)
Description copied from interface:Evaluable
Translates this expression by simultaneously substituting column names as the supplied map specifies.This is only possible if the extraction of column dependencies with
Evaluable.getColumnDependencies(String)
succeeds (return a non-null value).- Specified by:
renameColumnDependencies
in interfaceEvaluable
- 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.
-
getSource
public String getSource()
Description copied from interface:Evaluable
Returns the source string which generated this expression. This does not include the language prefix, which can be obtained byEvaluable.getLanguagePrefix()
.
-
getLanguagePrefix
public String getLanguagePrefix()
- Specified by:
getLanguagePrefix
in interfaceEvaluable
- Returns:
- the language prefix used to generate this evaluable.
-
isLocal
public boolean isLocal()
- Specified by:
isLocal
in interfaceEvaluable
- Returns:
- true when the evaluable can be computed fully (and quickly) from the local context (the given row or record). If it relies on any other information (external web service, aggregation over the project), then it should return false, indicating that the return value may need to be cached by the caller.
-
-