Class 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 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) in evaluate(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 interface WbExpression<org.wikidata.wdtk.datamodel.interfaces.TimeValue>
        Parameters:
        validation - the state in which to log any validation errors
      • 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
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object