Class OWLTranslator

java.lang.Object
org.incenp.obofoundry.kgcl.ChangeVisitorBase<List<org.semanticweb.owlapi.model.OWLOntologyChange>>
org.incenp.obofoundry.kgcl.owl.OWLTranslator
All Implemented Interfaces:
IChangeVisitor<List<org.semanticweb.owlapi.model.OWLOntologyChange>>
Direct Known Subclasses:
DirectOWLTranslator, ProvisionalOWLTranslator

public class OWLTranslator extends ChangeVisitorBase<List<org.semanticweb.owlapi.model.OWLOntologyChange>>
Base class to translate KGCL change objects into OWL axioms.
  • Field Details

    • empty

      protected final List<org.semanticweb.owlapi.model.OWLOntologyChange> empty
    • ontology

      protected org.semanticweb.owlapi.model.OWLOntology ontology
    • factory

      protected org.semanticweb.owlapi.model.OWLDataFactory factory
    • reasoner

      protected org.semanticweb.owlapi.reasoner.OWLReasoner reasoner
  • Constructor Details

    • OWLTranslator

      protected OWLTranslator(org.semanticweb.owlapi.model.OWLOntology ontology, org.semanticweb.owlapi.reasoner.OWLReasoner reasoner)
      Creates a new instance for the specified ontology.
      Parameters:
      ontology - The ontology the changes are intended for.
      reasoner - The reasoner to use for operations that require one.
  • Method Details

    • addRejectListener

      public void addRejectListener(RejectedChangeListener listener)
      Adds a listener for change rejection events. All the visit() methods will return an empty list if they cannot translate the change into OWL axioms for any reason. Use a “reject listener” to get the reason why a change has been rejected.
      Parameters:
      listener - The listener to add.
    • onReject

      protected void onReject(Change change, String format, Object... args)
      Called internally whenever a change is rejected. This method formats the provided error message then calls any listener that has been set up by addRejectListener(RejectedChangeListener).
      Parameters:
      change - The change that is rejected.
      format - The reason for rejecting the change, as a format string.
      args - Arguments referenced by the format specifiers in the format string.
    • doDefault

      protected List<org.semanticweb.owlapi.model.OWLOntologyChange> doDefault(Change v)
      Description copied from class: ChangeVisitorBase
      Override this method in derived classes to change the value returned by unimplemented methods.
      Overrides:
      doDefault in class ChangeVisitorBase<List<org.semanticweb.owlapi.model.OWLOntologyChange>>
      Parameters:
      v - The change to visit.
      Returns:
      The default value to return.
    • findMatchingAnnotations

      protected Set<org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom> findMatchingAnnotations(org.semanticweb.owlapi.model.IRI property, org.semanticweb.owlapi.model.IRI entity, NodeChange change, boolean newValue)
      Finds all annotations with a literal value that matches the old value of a NodeChange object.
      Parameters:
      property - The property of the annotations to look for.
      entity - The entity whose annotations should be retrieved.
      change - The change object whose old value should be compared against the annotations' values.
      newValue - If true, this method will compare annotations against the new value of the change object, rather than the old value.
      Returns:
      A set containing the annotation assertion axioms with a matching values.
    • findMatchingAnnotations

      protected Set<org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom> findMatchingAnnotations(org.semanticweb.owlapi.model.IRI property, org.semanticweb.owlapi.model.IRI entity, NodeChange change)
      Finds all annotations with a literal value that matches the old value of a NodeChange object.
      Parameters:
      property - The property of the annotations to look for.
      entity - The entity whose annotations should be retrieved.
      change - The change object whose old value should be compared against the annotations' values.
      Returns:
      A set containing the annotation assertion axioms with a matching values.
    • getLiteral

      protected org.semanticweb.owlapi.model.OWLLiteral getLiteral(NodeChange change, String oldLang)
      Constructs a literal value from the new value parameters of a change object.
      Parameters:
      change - The change object containing the details of the new literal to construct.
      oldLang - If non-null, and the change object does not contain an explicit language tag for the new value, this will be used as the language tag for the literal.
      Returns:
      The constructed OWL literal.
    • getLiteral

      protected org.semanticweb.owlapi.model.OWLLiteral getLiteral(NodeChange change)
      Constructs a literal value from the new value parameters of a change object.
      Parameters:
      change - The change object containing the details of the new literal to construct.
      Returns:
      The constructed OWL literal.
    • findEdges

      protected Set<org.semanticweb.owlapi.model.OWLAxiom> findEdges(org.semanticweb.owlapi.model.IRI subject, org.semanticweb.owlapi.model.IRI object, org.semanticweb.owlapi.model.IRI predicate)
      Gets all axioms representing edges between a subject and an object.
      Parameters:
      subject - The subject to look for.
      object - The object to look for.
      predicate - The predicate to look for. May be null, in which case the method will return all edges between the subject and the object regardless of their predicate.
      Returns:
      A set of matching axioms.