Package org.openrefine.wikibase.schema
Class WbVariableExpr<T>
- java.lang.Object
-
- org.openrefine.wikibase.schema.WbVariableExpr<T>
-
- Type Parameters:
T
- the type of Wikibase value returned by the expression.
- All Implemented Interfaces:
WbExpression<T>
- Direct Known Subclasses:
WbDateVariable
,WbEntityVariable
,WbItemVariable
,WbLanguageVariable
,WbLocationVariable
,WbStringVariable
public abstract class WbVariableExpr<T> extends Object implements WbExpression<T>
A base class for expressions which draw their values from a particular column.- Author:
- Antonin Delpeuch
-
-
Field Summary
Fields Modifier and Type Field Description static String
NO_VALUE_KEYWORD
static String
SOME_VALUE_KEYWORD
-
Constructor Summary
Constructors Constructor Description WbVariableExpr()
Constructs a variable without setting the column name yet.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected boolean
equalAsVariables(Object other, Class<? extends WbVariableExpr<?>> targetClass)
Helper for equality methods of subclasses.T
evaluate(ExpressionContext ctxt)
Evaluates the expression in a given context, returningabstract T
fromCell(Cell cell, ExpressionContext ctxt)
Method that should be implemented by subclasses, converting an OpenRefine cell to a Wikibase value.String
getColumnName()
Returns the column name used by the variable.int
hashCode()
void
setColumnName(String columnName)
Changes the column name used by the variable.void
validate(ValidationState validation)
Checks that we have a valid column name.
-
-
-
Field Detail
-
NO_VALUE_KEYWORD
public static final String NO_VALUE_KEYWORD
- See Also:
- Constant Field Values
-
SOME_VALUE_KEYWORD
public static final String SOME_VALUE_KEYWORD
- See Also:
- Constant Field Values
-
-
Method Detail
-
validate
public void validate(ValidationState validation)
Checks that we have a valid column name.- Specified by:
validate
in interfaceWbExpression<T>
- Parameters:
validation
- the state in which to log any validation errors
-
getColumnName
public String getColumnName()
Returns the column name used by the variable.- Returns:
- the OpenRefine column name
-
setColumnName
public void setColumnName(String columnName)
Changes the column name used by the variable. This is useful for deserialization, as well as updates when column names change.
-
evaluate
public T evaluate(ExpressionContext ctxt) throws SkipSchemaExpressionException, QAWarningException, SpecialValueNoValueException, SpecialValueSomeValueException
Evaluates the expression in a given context, returning- Specified by:
evaluate
in interfaceWbExpression<T>
- Throws:
QAWarningException
SpecialValueNoValueException
SpecialValueSomeValueException
SkipSchemaExpressionException
-
fromCell
public abstract T fromCell(Cell cell, ExpressionContext ctxt) throws SkipSchemaExpressionException, QAWarningException
Method that should be implemented by subclasses, converting an OpenRefine cell to a Wikibase value. Access to other values and emitting warnings is possible via the supplied EvaluationContext object.- Parameters:
cell
- the cell to convertctxt
- the evaluation context- Returns:
- the corresponding Wikibase value
- Throws:
SkipSchemaExpressionException
QAWarningException
-
equalAsVariables
protected boolean equalAsVariables(Object other, Class<? extends WbVariableExpr<?>> targetClass)
Helper for equality methods of subclasses.- Parameters:
other
- the object to comparetargetClass
- the target class for equality- Returns:
-
-