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
ConstructorDescriptionAnyValueConverter
(RdfWriter rdfWriter, OwlDeclarationBuffer rdfConversionBuffer, PropertyRegister propertyRegister) -
Method Summary
Modifier and TypeMethodDescriptionorg.eclipse.rdf4j.model.Value
getRdfValue
(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.Value
visit
(EntityIdValue value) Visits a EntityIdValue and returns a result.org.eclipse.rdf4j.model.Value
visit
(GlobeCoordinatesValue value) Visits a GlobeCoordinatesValue and returns a result.org.eclipse.rdf4j.model.Value
visit
(MonolingualTextValue value) Visits a MonolingualTextValue and returns a result.org.eclipse.rdf4j.model.Value
visit
(QuantityValue value) Visits a QuantityValue and returns a result.org.eclipse.rdf4j.model.Value
visit
(StringValue value) Visits a StringValue and returns a result.org.eclipse.rdf4j.model.Value
Visits a TimeValue and returns a result.org.eclipse.rdf4j.model.Value
visit
(UnsupportedValue value) Visits an UnsupportedValue and returns a resultvoid
Writes 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:ValueConverter
Returns an RDF value that should be used to represent the given Wikibase data value in RDF.- Specified by:
getRdfValue
in 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:ValueVisitor
Visits a EntityIdValue and returns a result. In practice, only specific subtypes of EntityIdValue are used, such asItemIdValue
andPropertyIdValue
. 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 interfaceValueVisitor<org.eclipse.rdf4j.model.Value>
- Parameters:
value
- the value to visit- Returns:
- the result for this value
-
visit
Description copied from interface:ValueVisitor
Visits a GlobeCoordinatesValue and returns a result.- Specified by:
visit
in interfaceValueVisitor<org.eclipse.rdf4j.model.Value>
- Parameters:
value
- the value to visit- Returns:
- the result for this value
-
visit
Description copied from interface:ValueVisitor
Visits a MonolingualTextValue and returns a result.- Specified by:
visit
in interfaceValueVisitor<org.eclipse.rdf4j.model.Value>
- Parameters:
value
- the value to visit- Returns:
- the result for this value
-
visit
Description copied from interface:ValueVisitor
Visits a QuantityValue and returns a result.- Specified by:
visit
in interfaceValueVisitor<org.eclipse.rdf4j.model.Value>
- Parameters:
value
- the value to visit- Returns:
- the result for this value
-
visit
Description copied from interface:ValueVisitor
Visits a StringValue and returns a result.- Specified by:
visit
in interfaceValueVisitor<org.eclipse.rdf4j.model.Value>
- Parameters:
value
- the value to visit- Returns:
- the result for this value
-
visit
Description copied from interface:ValueVisitor
Visits a TimeValue and returns a result.- Specified by:
visit
in 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:ValueConverter
Writes auxiliary triples that might be needed to encode a Wikibase value in RDF.- Specified by:
writeAuxiliaryTriples
in interfaceValueConverter<Value>
- Throws:
org.eclipse.rdf4j.rio.RDFHandlerException
- if there is a problem writing the triples
-
visit
Description copied from interface:ValueVisitor
Visits an UnsupportedValue and returns a result- Specified by:
visit
in interfaceValueVisitor<org.eclipse.rdf4j.model.Value>
- Parameters:
value
- the value to visit- Returns:
- the result for this value
-