Class AnyValueConverter

java.lang.Object
org.wikidata.wdtk.rdf.values.AnyValueConverter
All Implemented Interfaces:
ValueVisitor<org.eclipse.rdf4j.model.Value>, ValueConverter<Value>

public class AnyValueConverter extends Object implements ValueConverter<Value>, ValueVisitor<org.eclipse.rdf4j.model.Value>
Class to convert Wikibase data values to RDF. The class is a visitor that that computes an RDF value (URI or literal) to represent any kind of Wikibase data value. Some values are complex and require further RDF triples to be written. In such cases, the class stores the values to a buffer. Methods for writing additional triples for these buffered values can be called later.
Author:
Markus Kroetzsch
  • Constructor Details

  • Method Details

    • getRdfValue

      public org.eclipse.rdf4j.model.Value getRdfValue(Value value, PropertyIdValue propertyIdValue, boolean simple)
      Description copied from interface: ValueConverter
      Returns an RDF value that should be used to represent the given Wikibase data value in RDF.
      Specified by:
      getRdfValue in interface ValueConverter<Value>
      Parameters:
      value - the value to convert
      propertyIdValue - the property for which this value was used; this provides important context information for the conversion
      simple - if true, use a simplified conversion to RDF and do not convert values that are inherently complex
      Returns:
      the RDF value to use for representing the data value in RDF
    • visit

      public org.eclipse.rdf4j.model.Value visit(EntityIdValue value)
      Description copied from interface: ValueVisitor
      Visits a EntityIdValue and returns a result. In practice, only specific subtypes of EntityIdValue are used, such as ItemIdValue and PropertyIdValue. Since the set of possible subtypes can be extended by extensions of Wikibase, the visitor only visits the general (abstract) supertype. Implementations will have to decide if the given specific type is supported and what to do with it.
      Specified by:
      visit in interface ValueVisitor<org.eclipse.rdf4j.model.Value>
      Parameters:
      value - the value to visit
      Returns:
      the result for this value
    • visit

      public org.eclipse.rdf4j.model.Value visit(GlobeCoordinatesValue value)
      Description copied from interface: ValueVisitor
      Visits a GlobeCoordinatesValue and returns a result.
      Specified by:
      visit in interface ValueVisitor<org.eclipse.rdf4j.model.Value>
      Parameters:
      value - the value to visit
      Returns:
      the result for this value
    • visit

      public org.eclipse.rdf4j.model.Value visit(MonolingualTextValue value)
      Description copied from interface: ValueVisitor
      Visits a MonolingualTextValue and returns a result.
      Specified by:
      visit in interface ValueVisitor<org.eclipse.rdf4j.model.Value>
      Parameters:
      value - the value to visit
      Returns:
      the result for this value
    • visit

      public org.eclipse.rdf4j.model.Value visit(QuantityValue value)
      Description copied from interface: ValueVisitor
      Visits a QuantityValue and returns a result.
      Specified by:
      visit in interface ValueVisitor<org.eclipse.rdf4j.model.Value>
      Parameters:
      value - the value to visit
      Returns:
      the result for this value
    • visit

      public org.eclipse.rdf4j.model.Value visit(StringValue value)
      Description copied from interface: ValueVisitor
      Visits a StringValue and returns a result.
      Specified by:
      visit in interface ValueVisitor<org.eclipse.rdf4j.model.Value>
      Parameters:
      value - the value to visit
      Returns:
      the result for this value
    • visit

      public org.eclipse.rdf4j.model.Value visit(TimeValue value)
      Description copied from interface: ValueVisitor
      Visits a TimeValue and returns a result.
      Specified by:
      visit in interface ValueVisitor<org.eclipse.rdf4j.model.Value>
      Parameters:
      value - the value to visit
      Returns:
      the result for this value
    • writeAuxiliaryTriples

      public void writeAuxiliaryTriples() throws org.eclipse.rdf4j.rio.RDFHandlerException
      Description copied from interface: ValueConverter
      Writes auxiliary triples that might be needed to encode a Wikibase value in RDF.
      Specified by:
      writeAuxiliaryTriples in interface ValueConverter<Value>
      Throws:
      org.eclipse.rdf4j.rio.RDFHandlerException - if there is a problem writing the triples
    • visit

      public org.eclipse.rdf4j.model.Value visit(UnsupportedValue value)
      Description copied from interface: ValueVisitor
      Visits an UnsupportedValue and returns a result
      Specified by:
      visit in interface ValueVisitor<org.eclipse.rdf4j.model.Value>
      Parameters:
      value - the value to visit
      Returns:
      the result for this value