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 Details

  • Method Details

    • addPrefix

      public void addPrefix(String abbreviation, String value)
      Description copied from interface: RDFConsumer
      Add a prefix to the underlying ontology format, if prefixes are supported.
      Specified by:
      addPrefix in interface RDFConsumer
      Parameters:
      abbreviation - short name for prefix
      value - replacement for short version
    • getOntology

      public OWLOntology getOntology()
      Gets the ontology.
      Returns:
      the ontology
    • getOntologyFormat

      public RDFDocumentFormat getOntologyFormat()
      Gets the ontology format.
      Returns:
      the ontology format
    • setOntologyFormat

      public void setOntologyFormat(RDFDocumentFormat format)
      Sets the ontology format.
      Parameters:
      format - the new ontology format
    • getDataFactory

      public OWLDataFactory getDataFactory()
      Gets the data factory.
      Returns:
      the data factory
    • getPendingAnnotations

      public Set<OWLAnnotation> 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

      public boolean isAnonymousNode(String iri)
      Specified by:
      isAnonymousNode in interface AnonymousNodeChecker
      Parameters:
      iri - iri to check
      Returns:
      true if iri is a blank node iri
    • isAnonymousSharedNode

      public boolean isAnonymousSharedNode(String iri)
      Specified by:
      isAnonymousSharedNode in interface AnonymousNodeChecker
      Parameters:
      iri - iri to check
      Returns:
      true if iri is a blank node iri for shared nodes
    • isAnonymousNode

      public boolean isAnonymousNode(IRI iri)
      Specified by:
      isAnonymousNode in interface AnonymousNodeChecker
      Parameters:
      iri - iri to check
      Returns:
      true if iri is a blank node iri
    • getLastAddedAxiom

      @Nullable public OWLAxiom getLastAddedAxiom()
      Gets the last added axiom.
      Returns:
      the last added axiom
    • addClassExpression

      public void addClassExpression(IRI iri, boolean explicitlyTyped)
      Adds the class expression.
      Parameters:
      iri - the iri
      explicitlyTyped - the explicitly typed
    • isClassExpression

      public boolean isClassExpression(IRI iri)
      Checks if is class expression.
      Parameters:
      iri - the iri
      Returns:
      true, if is class expression
    • addObjectProperty

      public void addObjectProperty(IRI iri, boolean explicitlyTyped)
      Adds the object property.
      Parameters:
      iri - the iri
      explicitlyTyped - the explicitly typed
    • addDataProperty

      public void addDataProperty(IRI iri, boolean explicitlyTyped)
      Adds the data property.
      Parameters:
      iri - the iri
      explicitlyTyped - the explicitly typed
    • addDataRange

      public void addDataRange(IRI iri, boolean explicitlyTyped)
      Adds the data range.
      Parameters:
      iri - the iri
      explicitlyTyped - the explicitly typed
    • isRestriction

      public boolean isRestriction(IRI iri)
      Checks if is restriction.
      Parameters:
      iri - the iri
      Returns:
      true, if is restriction
    • getOWLOntologyManager

      public OWLOntologyManager getOWLOntologyManager()
      Returns:
      the ontology manager
    • addAnnotatedSource

      public void 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).
      Parameters:
      annotatedAnonSource - The source that the annotation annotates
      annotationMainNode - The annotations
    • getAnnotatedSourceAnnotationMainNodes

      public Set<IRI> getAnnotatedSourceAnnotationMainNodes(IRI source)
      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

      public OWLAnonymousIndividual getOWLAnonymousIndividual(String nodeId)
      Description copied from interface: AnonymousIndividualByIdProvider
      Gets an OWLAnonymousIndividual that has a specific NodeID .
      Specified by:
      getOWLAnonymousIndividual in interface AnonymousIndividualByIdProvider
      Parameters:
      nodeId - A String that represents the NodeID of the generated OWLAnonymousIndividual. Note: nodeId will be prefixed with "_:" if it is not specified with an "_:" prefix.
      Returns:
      An instance of OWLAnonymousIndividual
    • startModel

      public void startModel(IRI physicalURI)
      Description copied from interface: RDFConsumer
      Called when model parsing is started.
      Specified by:
      startModel in interface RDFConsumer
      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 interface RDFConsumer
    • includeModel

      public void includeModel(@Nullable String logicalURI, @Nullable String physicalURI)
      Description copied from interface: RDFConsumer
      Receives the notification that the model being parsed includes another model with supplied URIs.
      Specified by:
      includeModel in interface RDFConsumer
      Parameters:
      logicalURI - logical URI of the model
      physicalURI - physical URI of the model
    • logicalURI

      public void logicalURI(IRI logicalURI)
      Description copied from interface: RDFConsumer
      Receives the logical URI of the model.
      Specified by:
      logicalURI in interface RDFConsumer
      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 interface RDFConsumer
      Parameters:
      subject - URI of the subject resource
      predicate - URI of the predicate resource
      object - literal object value
      language - the language
      datatype - the URI of the literal's datatype (may be null)
    • 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 interface RDFConsumer
      Parameters:
      subject - URI of the subject resource
      predicate - URI of the predicate resource
      object - literal object value
      language - the language
      datatype - the URI of the literal's datatype (may be null)
    • statementWithResourceValue

      public void statementWithResourceValue(String subject, String predicate, String object)
      Description copied from interface: RDFConsumer
      Called when a statement with resource value is added to the model.
      Specified by:
      statementWithResourceValue in interface RDFConsumer
      Parameters:
      subject - URI of the subject resource
      predicate - URI of the predicate resource
      object - URI of the object resource
    • statementWithResourceValue

      public void statementWithResourceValue(IRI subject, IRI predicate, IRI object)
      Description copied from interface: RDFConsumer
      Called when a statement with resource value is added to the model.
      Specified by:
      statementWithResourceValue in interface RDFConsumer
      Parameters:
      subject - URI of the subject resource
      predicate - URI of the predicate resource
      object - URI of the object resource
    • translateClassExpression

      public OWLClassExpression translateClassExpression(IRI i)
      Parameters:
      i - iri for the class expression
      Returns:
      translated class expression
    • translateDataRange

      public OWLDataRange translateDataRange(IRI n)
      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

      public OWLDataPropertyExpression translateDataPropertyExpression(IRI iri)
      Translate data property expression.
      Parameters:
      iri - the iri
      Returns:
      the data property expression
    • translateObjectPropertyExpression

      public OWLObjectPropertyExpression translateObjectPropertyExpression(IRI mainNode)
      Translate object property expression.
      Parameters:
      mainNode - the main node
      Returns:
      the object property expression
    • translateIndividual

      public OWLIndividual translateIndividual(IRI node)
      Translate individual.
      Parameters:
      node - the node
      Returns:
      the individual
    • translateAnnotations

      public Set<OWLAnnotation> translateAnnotations(IRI n)
      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

      public <E extends OWLEntity> E generateAndLogParseError(EntityType<E> entityType, IRI mainNode)
      Type Parameters:
      E - entity type
      Parameters:
      entityType - entity type
      mainNode - main node
      Returns:
      error entity
    • getConfiguration

      public OWLOntologyLoaderConfiguration getConfiguration()
      Specified by:
      getConfiguration in interface RDFConsumer
      Returns:
      the loader configuration
    • remapIRI

      public IRI remapIRI(IRI i)
      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 interface RDFConsumer
      Parameters:
      i - iri to remap if not blank
      Returns:
      blank iri remapping i
    • remapOnlyIfRemapped

      public String remapOnlyIfRemapped(String i)
      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 interface RDFConsumer
      Parameters:
      i - iri to remap if not blank
      Returns:
      blank iri remapping i, or i if i has not been remapped earlier.