Package org.openrefine.wikibase.schema
Class WbQuantityExpr
- java.lang.Object
-
- org.openrefine.wikibase.schema.WbQuantityExpr
-
- All Implemented Interfaces:
WbExpression<org.wikidata.wdtk.datamodel.interfaces.QuantityValue>
public class WbQuantityExpr extends Object implements WbExpression<org.wikidata.wdtk.datamodel.interfaces.QuantityValue>
-
-
Constructor Summary
Constructors Constructor Description WbQuantityExpr(WbExpression<? extends org.wikidata.wdtk.datamodel.interfaces.StringValue> amountExpr, WbExpression<? extends org.wikidata.wdtk.datamodel.interfaces.ItemIdValue> unitExpr)
Creates an expression for a quantity, which contains two sub-expressions: one for the amount (a string with a particular format) and one for the unit, which is optional.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.wikidata.wdtk.datamodel.interfaces.QuantityValue
evaluate(ExpressionContext ctxt)
Evaluates the value expression in a given context, returns a Wikibase value suitable to be the target of a claim.WbExpression<? extends org.wikidata.wdtk.datamodel.interfaces.StringValue>
getAmountExpr()
WbExpression<? extends org.wikidata.wdtk.datamodel.interfaces.ItemIdValue>
getUnitExpr()
void
validate(ValidationState validation)
Check that this expression is fully formed and ready to be evaluated.
-
-
-
Constructor Detail
-
WbQuantityExpr
public WbQuantityExpr(WbExpression<? extends org.wikidata.wdtk.datamodel.interfaces.StringValue> amountExpr, WbExpression<? extends org.wikidata.wdtk.datamodel.interfaces.ItemIdValue> unitExpr)
Creates an expression for a quantity, which contains two sub-expressions: one for the amount (a string with a particular format) and one for the unit, which is optional. Setting unitExpr to null will give quantities without units. Setting it to a non-null value will make the unit mandatory: if the unit expression fails to evaluate, the whole quantity expression will fail too.
-
-
Method Detail
-
validate
public void validate(ValidationState validation)
Description copied from interface:WbExpression
Check that this expression is fully formed and ready to be evaluated.- Specified by:
validate
in interfaceWbExpression<org.wikidata.wdtk.datamodel.interfaces.QuantityValue>
- Parameters:
validation
- the state in which to log any validation errors
-
evaluate
public org.wikidata.wdtk.datamodel.interfaces.QuantityValue evaluate(ExpressionContext ctxt) throws SkipSchemaExpressionException, QAWarningException
Description copied from interface:WbExpression
Evaluates the value expression in a given context, returns a Wikibase value suitable to be the target of a claim. As a premise to calling that method, we assume that callingWbExpression.validate(ValidationState)
did not log any error in the validation state.- Specified by:
evaluate
in interfaceWbExpression<org.wikidata.wdtk.datamodel.interfaces.QuantityValue>
- Throws:
SkipSchemaExpressionException
QAWarningException
-
getAmountExpr
public WbExpression<? extends org.wikidata.wdtk.datamodel.interfaces.StringValue> getAmountExpr()
-
getUnitExpr
public WbExpression<? extends org.wikidata.wdtk.datamodel.interfaces.ItemIdValue> getUnitExpr()
-
-