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 StringNO_VALUE_KEYWORDstatic StringSOME_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 booleanequalAsVariables(Object other, Class<? extends WbVariableExpr<?>> targetClass)Helper for equality methods of subclasses.Tevaluate(ExpressionContext ctxt)Evaluates the expression in a given context, returningabstract TfromCell(Cell cell, ExpressionContext ctxt)Method that should be implemented by subclasses, converting an OpenRefine cell to a Wikibase value.StringgetColumnName()Returns the column name used by the variable.inthashCode()voidsetColumnName(String columnName)Changes the column name used by the variable.voidvalidate(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:
validatein 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:
evaluatein interfaceWbExpression<T>- Throws:
QAWarningExceptionSpecialValueNoValueExceptionSpecialValueSomeValueExceptionSkipSchemaExpressionException
-
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:
SkipSchemaExpressionExceptionQAWarningException
-
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:
-
-