Package org.openrefine.wikibase.schema
Class WbDateConstant
- java.lang.Object
-
- org.openrefine.wikibase.schema.WbDateConstant
-
- All Implemented Interfaces:
WbExpression<org.wikidata.wdtk.datamodel.interfaces.TimeValue>
public class WbDateConstant extends Object implements WbExpression<org.wikidata.wdtk.datamodel.interfaces.TimeValue>
A constant for a time value, accepting a number of formats which determine the precision of the parsed value.- Author:
- Antonin Delpeuch
-
-
Field Summary
Fields Modifier and Type Field Description static Map<SimpleDateFormat,Integer>
acceptedFormats
Map of formats accepted by the parser.static Pattern
calendarSuffixPattern
-
Constructor Summary
Constructors Constructor Description WbDateConstant(String origDatestamp)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object other)
org.wikidata.wdtk.datamodel.interfaces.TimeValue
evaluate(ExpressionContext ctxt)
Evaluates the value expression in a given context, returns a Wikibase value suitable to be the target of a claim.String
getOrigDatestamp()
int
hashCode()
static org.wikidata.wdtk.datamodel.interfaces.TimeValue
parse(String datestamp)
Parses a timestamp into a WikibaseTimeValue
.void
validate(ValidationState validation)
Check that this expression is fully formed and ready to be evaluated.
-
-
-
Field Detail
-
acceptedFormats
public static Map<SimpleDateFormat,Integer> acceptedFormats
Map of formats accepted by the parser. Each format is associated to the time precision it induces (an integer according to Wikibase's data model).
-
calendarSuffixPattern
public static Pattern calendarSuffixPattern
-
-
Constructor Detail
-
WbDateConstant
public WbDateConstant(String origDatestamp)
Constructor. Used for deserialization from JSON. The object will be constructed even if the time cannot be parsed (it will evaluate to null) inevaluate(org.openrefine.wikibase.schema.ExpressionContext)
.- Parameters:
origDatestamp
- the date value as a string
-
-
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.TimeValue>
- Parameters:
validation
- the state in which to log any validation errors
-
evaluate
public org.wikidata.wdtk.datamodel.interfaces.TimeValue evaluate(ExpressionContext ctxt) throws SkipSchemaExpressionException
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.TimeValue>
- Throws:
SkipSchemaExpressionException
-
parse
public static org.wikidata.wdtk.datamodel.interfaces.TimeValue parse(String datestamp) throws ParseException
Parses a timestamp into a WikibaseTimeValue
. The precision is automatically inferred from the format.- Parameters:
datestamp
- the time to parse- Returns:
- Throws:
ParseException
- if the time cannot be parsed
-
getOrigDatestamp
public String getOrigDatestamp()
- Returns:
- the original datestamp
-
-