Package org.wikidata.wdtk.rdf.values
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 Summary
ConstructorsConstructorDescriptionAnyValueConverter(RdfWriter rdfWriter, OwlDeclarationBuffer rdfConversionBuffer, PropertyRegister propertyRegister) -
Method Summary
Modifier and TypeMethodDescriptionorg.eclipse.rdf4j.model.ValuegetRdfValue(Value value, PropertyIdValue propertyIdValue, boolean simple) Returns an RDF value that should be used to represent the given Wikibase data value in RDF.org.eclipse.rdf4j.model.Valuevisit(EntityIdValue value) Visits a EntityIdValue and returns a result.org.eclipse.rdf4j.model.Valuevisit(GlobeCoordinatesValue value) Visits a GlobeCoordinatesValue and returns a result.org.eclipse.rdf4j.model.Valuevisit(MonolingualTextValue value) Visits a MonolingualTextValue and returns a result.org.eclipse.rdf4j.model.Valuevisit(QuantityValue value) Visits a QuantityValue and returns a result.org.eclipse.rdf4j.model.Valuevisit(StringValue value) Visits a StringValue and returns a result.org.eclipse.rdf4j.model.ValueVisits a TimeValue and returns a result.org.eclipse.rdf4j.model.Valuevisit(UnsupportedValue value) Visits an UnsupportedValue and returns a resultvoidWrites auxiliary triples that might be needed to encode a Wikibase value in RDF.
-
Constructor Details
-
AnyValueConverter
public AnyValueConverter(RdfWriter rdfWriter, OwlDeclarationBuffer rdfConversionBuffer, PropertyRegister propertyRegister)
-
-
Method Details
-
getRdfValue
public org.eclipse.rdf4j.model.Value getRdfValue(Value value, PropertyIdValue propertyIdValue, boolean simple) Description copied from interface:ValueConverterReturns an RDF value that should be used to represent the given Wikibase data value in RDF.- Specified by:
getRdfValuein interfaceValueConverter<Value>- Parameters:
value- the value to convertpropertyIdValue- the property for which this value was used; this provides important context information for the conversionsimple- 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
Description copied from interface:ValueVisitorVisits a EntityIdValue and returns a result. In practice, only specific subtypes of EntityIdValue are used, such asItemIdValueandPropertyIdValue. 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:
visitin interfaceValueVisitor<org.eclipse.rdf4j.model.Value>- Parameters:
value- the value to visit- Returns:
- the result for this value
-
visit
Description copied from interface:ValueVisitorVisits a GlobeCoordinatesValue and returns a result.- Specified by:
visitin interfaceValueVisitor<org.eclipse.rdf4j.model.Value>- Parameters:
value- the value to visit- Returns:
- the result for this value
-
visit
Description copied from interface:ValueVisitorVisits a MonolingualTextValue and returns a result.- Specified by:
visitin interfaceValueVisitor<org.eclipse.rdf4j.model.Value>- Parameters:
value- the value to visit- Returns:
- the result for this value
-
visit
Description copied from interface:ValueVisitorVisits a QuantityValue and returns a result.- Specified by:
visitin interfaceValueVisitor<org.eclipse.rdf4j.model.Value>- Parameters:
value- the value to visit- Returns:
- the result for this value
-
visit
Description copied from interface:ValueVisitorVisits a StringValue and returns a result.- Specified by:
visitin interfaceValueVisitor<org.eclipse.rdf4j.model.Value>- Parameters:
value- the value to visit- Returns:
- the result for this value
-
visit
Description copied from interface:ValueVisitorVisits a TimeValue and returns a result.- Specified by:
visitin interfaceValueVisitor<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.RDFHandlerExceptionDescription copied from interface:ValueConverterWrites auxiliary triples that might be needed to encode a Wikibase value in RDF.- Specified by:
writeAuxiliaryTriplesin interfaceValueConverter<Value>- Throws:
org.eclipse.rdf4j.rio.RDFHandlerException- if there is a problem writing the triples
-
visit
Description copied from interface:ValueVisitorVisits an UnsupportedValue and returns a result- Specified by:
visitin interfaceValueVisitor<org.eclipse.rdf4j.model.Value>- Parameters:
value- the value to visit- Returns:
- the result for this value
-