Class OWLRDFConsumer
java.lang.Object
org.semanticweb.owlapi.rdf.rdfxml.parser.OWLRDFConsumer
- All Implemented Interfaces:
AnonymousIndividualByIdProvider
,RDFConsumer
,AnonymousNodeChecker
- Direct Known Subclasses:
OWLRDFConsumerAdapter
public class OWLRDFConsumer
extends Object
implements RDFConsumer, AnonymousNodeChecker, AnonymousIndividualByIdProvider
A parser/interpreter for an RDF graph which represents an OWL ontology. The consumer interprets
triple patterns in the graph to produce the appropriate OWLAPI entities, class expressions and
axioms. The parser is based on triple handlers. A given triple handler handles a specific type of
triple. Generally speaking this is based on the predicate of a triple, for example, A
rdfs:subClassOf B is handled by a subClassOf handler. A handler determines if it can handle a
triple in a streaming mode (i.e. while parsing is taking place) or if it can handle a triple
after parsing has taken place and the complete graph is in memory. Once a handler handles a
triple, that triple is deemed to have been consumed an is discarded. The parser attempts to
consume as many triples as possible while streaming parsing is taking place. Whether or not a
triple can be consumed during parsing is determined by installed triple handlers.
- Since:
- 2.0.0
- Author:
- Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group
-
Constructor Summary
ConstructorsConstructorDescriptionOWLRDFConsumer
(OWLOntology ontology, OWLOntologyLoaderConfiguration configuration) OWLRDFConsumer
(OWLOntology ontology, AnonymousNodeChecker checker, OWLOntologyLoaderConfiguration configuration) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAnnotatedSource
(IRI annotatedAnonSource, IRI annotationMainNode) Records an annotation of an anonymous node (either an annotation of an annotation, or an annotation of an axiom for example).void
addClassExpression
(IRI iri, boolean explicitlyTyped) Adds the class expression.void
addDataProperty
(IRI iri, boolean explicitlyTyped) Adds the data property.void
addDataRange
(IRI iri, boolean explicitlyTyped) Adds the data range.void
addObjectProperty
(IRI iri, boolean explicitlyTyped) Adds the object property.void
Add a prefix to the underlying ontology format, if prefixes are supported.void
endModel()
Called when model parsing is finished.<E extends OWLEntity>
EgenerateAndLogParseError
(EntityType<E> entityType, IRI mainNode) Gets the main nodes of annotations that annotated the specified source.Gets the data factory.Gets the last added axiom.Gets the ontology.Gets the ontology format.getOWLAnonymousIndividual
(String nodeId) Gets anOWLAnonymousIndividual
that has a specificNodeID
.Gets any annotations that were translated since the last call of this method (calling this method clears the current pending annotations).void
includeModel
(String logicalURI, String physicalURI) Receives the notification that the model being parsed includes another model with supplied URIs.boolean
isAnonymousNode
(String iri) boolean
isAnonymousNode
(IRI iri) boolean
boolean
isClassExpression
(IRI iri) Checks if is class expression.boolean
Checks if is parsed all triples.boolean
isRestriction
(IRI iri) Checks if is restriction.void
logicalURI
(IRI logicalURI) Receives the logical URI of the model.for iris that need to be mapped to blank nodes, e.g., SWRL rules with an IRI - the IRI should be dropped for such constructs.for iris that have been remapped to blank nodes, e.g., SWRL rules: the triple subject swrl:body object, for example, needs the subject to be remapped consistently.void
setOntologyFormat
(RDFDocumentFormat format) Sets the ontology format.void
startModel
(IRI physicalURI) Called when model parsing is started.void
statementWithLiteralValue
(String subject, String predicate, String object, String language, String datatype) Called when a statement with literal value is added to the model.void
Called when a statement with literal value is added to the model.void
statementWithResourceValue
(String subject, String predicate, String object) Called when a statement with resource value is added to the model.void
statementWithResourceValue
(IRI subject, IRI predicate, IRI object) Called when a statement with resource value is added to the model.Translates the annotation on a main node.compatibility proxy forTranslators.TranslatorAccessor.translateClassExpression(IRI)
Translate data property expression.Given a main node, translated data ranges according to Table 12.translateIndividual
(IRI node) Translate individual.translateObjectPropertyExpression
(IRI mainNode) Translate object property expression.
-
Constructor Details
-
OWLRDFConsumer
- Parameters:
ontology
- the ontologyconfiguration
- the configuration
-
OWLRDFConsumer
public OWLRDFConsumer(OWLOntology ontology, AnonymousNodeChecker checker, OWLOntologyLoaderConfiguration configuration) - Parameters:
ontology
- the ontologychecker
- anonymous node checkerconfiguration
- the configuration
-
-
Method Details
-
addPrefix
Description copied from interface:RDFConsumer
Add a prefix to the underlying ontology format, if prefixes are supported.- Specified by:
addPrefix
in interfaceRDFConsumer
- Parameters:
abbreviation
- short name for prefixvalue
- replacement for short version
-
getOntology
Gets the ontology.- Returns:
- the ontology
-
getOntologyFormat
Gets the ontology format.- Returns:
- the ontology format
-
setOntologyFormat
Sets the ontology format.- Parameters:
format
- the new ontology format
-
getDataFactory
Gets the data factory.- Returns:
- the data factory
-
getPendingAnnotations
Gets any annotations that were translated since the last call of this method (calling this method clears the current pending annotations).- Returns:
- The set (possibly empty) of pending annotations.
-
isAnonymousNode
- Specified by:
isAnonymousNode
in interfaceAnonymousNodeChecker
- Parameters:
iri
- iri to check- Returns:
- true if iri is a blank node iri
-
isAnonymousNode
- Specified by:
isAnonymousNode
in interfaceAnonymousNodeChecker
- Parameters:
iri
- iri to check- Returns:
- true if iri is a blank node iri
-
getLastAddedAxiom
Gets the last added axiom.- Returns:
- the last added axiom
-
addClassExpression
Adds the class expression.- Parameters:
iri
- the iriexplicitlyTyped
- the explicitly typed
-
isClassExpression
Checks if is class expression.- Parameters:
iri
- the iri- Returns:
- true, if is class expression
-
addObjectProperty
Adds the object property.- Parameters:
iri
- the iriexplicitlyTyped
- the explicitly typed
-
addDataProperty
Adds the data property.- Parameters:
iri
- the iriexplicitlyTyped
- the explicitly typed
-
addDataRange
Adds the data range.- Parameters:
iri
- the iriexplicitlyTyped
- the explicitly typed
-
isRestriction
Checks if is restriction.- Parameters:
iri
- the iri- Returns:
- true, if is restriction
-
getOWLOntologyManager
- Returns:
- the ontology manager
-
addAnnotatedSource
Records an annotation of an anonymous node (either an annotation of an annotation, or an annotation of an axiom for example).- Parameters:
annotatedAnonSource
- The source that the annotation annotatesannotationMainNode
- The annotations
-
getAnnotatedSourceAnnotationMainNodes
Gets the main nodes of annotations that annotated the specified source.- Parameters:
source
- The source (axiom or annotation main node)- Returns:
- The set of main nodes that annotate the specified source
-
getOWLAnonymousIndividual
Description copied from interface:AnonymousIndividualByIdProvider
Gets anOWLAnonymousIndividual
that has a specificNodeID
.- Specified by:
getOWLAnonymousIndividual
in interfaceAnonymousIndividualByIdProvider
- Parameters:
nodeId
- A String that represents theNodeID
of the generatedOWLAnonymousIndividual
. Note:nodeId
will be prefixed with "_:" if it is not specified with an "_:" prefix.- Returns:
- An instance of
OWLAnonymousIndividual
-
startModel
Description copied from interface:RDFConsumer
Called when model parsing is started.- Specified by:
startModel
in interfaceRDFConsumer
- Parameters:
physicalURI
- physical URI of the model
-
isParsedAllTriples
public boolean isParsedAllTriples()Checks if is parsed all triples.- Returns:
- true, if is parsed all triples
-
endModel
public void endModel()Description copied from interface:RDFConsumer
Called when model parsing is finished.- Specified by:
endModel
in interfaceRDFConsumer
-
includeModel
Description copied from interface:RDFConsumer
Receives the notification that the model being parsed includes another model with supplied URIs.- Specified by:
includeModel
in interfaceRDFConsumer
- Parameters:
logicalURI
- logical URI of the modelphysicalURI
- physical URI of the model
-
logicalURI
Description copied from interface:RDFConsumer
Receives the logical URI of the model.- Specified by:
logicalURI
in interfaceRDFConsumer
- Parameters:
logicalURI
- logical URI of the model
-
statementWithLiteralValue
public void statementWithLiteralValue(String subject, String predicate, String object, @Nullable String language, @Nullable String datatype) Description copied from interface:RDFConsumer
Called when a statement with literal value is added to the model.- Specified by:
statementWithLiteralValue
in interfaceRDFConsumer
- Parameters:
subject
- URI of the subject resourcepredicate
- URI of the predicate resourceobject
- literal object valuelanguage
- the languagedatatype
- the URI of the literal's datatype (may benull
)
-
statementWithLiteralValue
public void statementWithLiteralValue(IRI subject, IRI predicate, String object, @Nullable String language, @Nullable IRI datatype) Description copied from interface:RDFConsumer
Called when a statement with literal value is added to the model.- Specified by:
statementWithLiteralValue
in interfaceRDFConsumer
- Parameters:
subject
- URI of the subject resourcepredicate
- URI of the predicate resourceobject
- literal object valuelanguage
- the languagedatatype
- the URI of the literal's datatype (may benull
)
-
statementWithResourceValue
Description copied from interface:RDFConsumer
Called when a statement with resource value is added to the model.- Specified by:
statementWithResourceValue
in interfaceRDFConsumer
- Parameters:
subject
- URI of the subject resourcepredicate
- URI of the predicate resourceobject
- URI of the object resource
-
statementWithResourceValue
Description copied from interface:RDFConsumer
Called when a statement with resource value is added to the model.- Specified by:
statementWithResourceValue
in interfaceRDFConsumer
- Parameters:
subject
- URI of the subject resourcepredicate
- URI of the predicate resourceobject
- URI of the object resource
-
translateClassExpression
compatibility proxy forTranslators.TranslatorAccessor.translateClassExpression(IRI)
- Parameters:
i
- iri for the class expression- Returns:
- translated class expression
-
translateDataRange
Given a main node, translated data ranges according to Table 12.- Parameters:
n
- The main node- Returns:
- The translated data range. If the data range could not be translated then an OWLDatatype with the given IRI is returned.
-
translateDataPropertyExpression
Translate data property expression.- Parameters:
iri
- the iri- Returns:
- the data property expression
-
translateObjectPropertyExpression
Translate object property expression.- Parameters:
mainNode
- the main node- Returns:
- the object property expression
-
translateIndividual
Translate individual.- Parameters:
node
- the node- Returns:
- the individual
-
translateAnnotations
Translates the annotation on a main node. Triples whose subject is the specified main node and whose subject is typed an an annotation property (or is a built in annotation property) will be translated to annotation on this main node.- Parameters:
n
- The main node- Returns:
- The set of annotations on the main node
-
generateAndLogParseError
- Type Parameters:
E
- entity type- Parameters:
entityType
- entity typemainNode
- main node- Returns:
- error entity
-
getConfiguration
- Specified by:
getConfiguration
in interfaceRDFConsumer
- Returns:
- the loader configuration
-
remapIRI
Description copied from interface:RDFConsumer
for iris that need to be mapped to blank nodes, e.g., SWRL rules with an IRI - the IRI should be dropped for such constructs.- Specified by:
remapIRI
in interfaceRDFConsumer
- Parameters:
i
- iri to remap if not blank- Returns:
- blank iri remapping i
-
remapOnlyIfRemapped
Description copied from interface:RDFConsumer
for iris that have been remapped to blank nodes, e.g., SWRL rules: the triple subject swrl:body object, for example, needs the subject to be remapped consistently.- Specified by:
remapOnlyIfRemapped
in interfaceRDFConsumer
- Parameters:
i
- iri to remap if not blank- Returns:
- blank iri remapping i, or i if i has not been remapped earlier.
-