Class WbDateConstant

java.lang.Object
org.openrefine.wikidata.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 Details

    • 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 Details

    • 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) in evaluate(org.openrefine.wikidata.schema.ExpressionContext).
      Parameters:
      origDatestamp - the date value as a string
  • Method Details

    • 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.
      Specified by:
      evaluate in interface WbExpression<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 Wikibase TimeValue. 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
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object