org.coode.owl.rdfxml.parser
Class OWLRDFConsumer

java.lang.Object
  extended by org.coode.owl.rdfxml.parser.OWLRDFConsumer
All Implemented Interfaces:
RDFConsumer
Direct Known Subclasses:
OWLRDFConsumerAdapter

public class OWLRDFConsumer
extends java.lang.Object
implements RDFConsumer

Author: Matthew Horridge
The University Of Manchester
Bio-Health Informatics Group
Date: 07-Dec-2006

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, descriptions 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.


Constructor Summary
OWLRDFConsumer(OWLOntologyManager owlOntologyManager, OWLOntology ontology, AnonymousNodeChecker checker)
           
 
Method Summary
 void addFirst(java.net.URI subject, OWLConstant object)
           
 void addFirst(java.net.URI subject, java.net.URI object)
           
 void addList(java.net.URI uri)
           
 void addModelAttribte(java.lang.String string, java.lang.String string1)
          Receives the notification that the attribute and its value has been parsed.
 void addOntology(java.net.URI uri)
           
 void addOWLDataRange(java.net.URI uri)
           
 void addReifiedAxiom(java.net.URI axiomURI, OWLAxiom axiom)
           
 void addRest(java.net.URI subject, java.net.URI object)
           
 void addTriple(java.net.URI subject, java.net.URI predicate, OWLConstant con)
           
 void addTriple(java.net.URI subject, java.net.URI predicate, java.net.URI object)
           
 java.net.URI checkForSynonym(java.net.URI original)
           
 void endModel()
          This is where we do all remaining parsing
 OWLAxiom getAxiom(java.net.URI uri)
           
 OWLDataFactory getDataFactory()
           
 OWLDescription getDescriptionIfTranslated(java.net.URI mainNode)
           
 OWLConstant getFirstLiteral(java.net.URI subject)
           
 java.net.URI getFirstResource(java.net.URI subject, boolean consume)
           
 OWLAxiom getLastAddedAxiom()
           
 OWLConstant getLiteralObject(java.net.URI subject, java.net.URI predicate, boolean consume)
           
 OWLOntology getOntology()
           
 RDFXMLOntologyFormat getOntologyFormat()
           
 OWLOntologyManager getOWLOntologyManager()
           
 java.net.URI getResourceObject(java.net.URI subject, java.net.URI predicate, boolean consume)
           
 java.net.URI getRest(java.net.URI subject, boolean consume)
           
 void handle(java.net.URI subject, java.net.URI predicate, OWLConstant object)
           
 void handle(java.net.URI subject, java.net.URI predicate, java.net.URI object)
           
 boolean hasPredicate(java.net.URI subject, java.net.URI predicate)
           
 boolean hasPredicateObject(java.net.URI subject, java.net.URI predicate, java.net.URI object)
           
 void importsClosureChanged()
           
 void includeModel(java.lang.String string, java.lang.String string1)
          Receives the notification that the model being parsed includes another model with supplied URIs.
 boolean isAxiom(java.net.URI uri)
           
 boolean isDataRange(java.net.URI uri)
           
 boolean isDataRestriction(java.net.URI uri)
           
 boolean isList(java.net.URI uri, boolean consume)
           
 boolean isObjectRestriction(java.net.URI uri)
           
 boolean isRestriction(java.net.URI uri)
           
 boolean isSelfRestriction(java.net.URI uri)
           
 boolean isTriplePresent(java.net.URI subject, java.net.URI predicate, OWLConstant object, boolean consume)
           
 boolean isTriplePresent(java.net.URI subject, java.net.URI predicate, java.net.URI object, boolean consume)
           
 void logicalURI(java.lang.String string)
          Receives the logical URI of the model.
 void setOntologyFormat(RDFXMLOntologyFormat format)
           
 void setXMLBase(java.lang.String base)
           
 void startModel(java.lang.String string)
          Called when model parsing is started.
 void statementWithLiteralValue(java.lang.String subject, java.lang.String predicate, java.lang.String object, java.lang.String lang, java.lang.String datatype)
          Called when a statement with literal value is added to the model.
 void statementWithResourceValue(java.lang.String subject, java.lang.String predicate, java.lang.String object)
          Called when a statement with resource value is added to the model.
 OWLDataPropertyExpression translateDataPropertyExpression(java.net.URI uri)
           
 OWLDataRange translateDataRange(java.net.URI uri)
           
 OWLDescription translateDescription(java.net.URI mainNode)
           
 OWLIndividual translateIndividual(java.net.URI node)
           
 OWLObjectPropertyExpression translateObjectPropertyExpression(java.net.URI mainNode)
           
 java.util.Set<OWLConstant> translateToConstantSet(java.net.URI mainNode)
           
 java.util.List<OWLDataPropertyExpression> translateToDataPropertyList(java.net.URI mainNode)
           
 java.util.Set<OWLDescription> translateToDescriptionSet(java.net.URI mainNode)
           
 java.util.Set<OWLIndividual> translateToIndividualSet(java.net.URI mainNode)
           
 java.util.List<OWLObjectPropertyExpression> translateToObjectPropertyList(java.net.URI mainNode)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OWLRDFConsumer

public OWLRDFConsumer(OWLOntologyManager owlOntologyManager,
                      OWLOntology ontology,
                      AnonymousNodeChecker checker)
Method Detail

getOntology

public OWLOntology getOntology()

getOntologyFormat

public RDFXMLOntologyFormat getOntologyFormat()

setOntologyFormat

public void setOntologyFormat(RDFXMLOntologyFormat format)

getDataFactory

public OWLDataFactory getDataFactory()

importsClosureChanged

public void importsClosureChanged()

getLastAddedAxiom

public OWLAxiom getLastAddedAxiom()

addOWLDataRange

public void addOWLDataRange(java.net.URI uri)

isSelfRestriction

public boolean isSelfRestriction(java.net.URI uri)

isRestriction

public boolean isRestriction(java.net.URI uri)

isObjectRestriction

public boolean isObjectRestriction(java.net.URI uri)

isDataRestriction

public boolean isDataRestriction(java.net.URI uri)

getOWLOntologyManager

public OWLOntologyManager getOWLOntologyManager()

handle

public void handle(java.net.URI subject,
                   java.net.URI predicate,
                   java.net.URI object)
            throws OWLException
Throws:
OWLException

handle

public void handle(java.net.URI subject,
                   java.net.URI predicate,
                   OWLConstant object)
            throws OWLException
Throws:
OWLException

startModel

public void startModel(java.lang.String string)
                throws org.xml.sax.SAXException
Description copied from interface: RDFConsumer
Called when model parsing is started.

Specified by:
startModel in interface RDFConsumer
Parameters:
string - physical URI of the model
Throws:
org.xml.sax.SAXException

endModel

public void endModel()
              throws org.xml.sax.SAXException
This is where we do all remaining parsing

Specified by:
endModel in interface RDFConsumer
Throws:
org.xml.sax.SAXException

addModelAttribte

public void addModelAttribte(java.lang.String string,
                             java.lang.String string1)
                      throws org.xml.sax.SAXException
Description copied from interface: RDFConsumer
Receives the notification that the attribute and its value has been parsed.

Specified by:
addModelAttribte in interface RDFConsumer
Parameters:
string - the key of the attribute
string1 - the value of the attribute
Throws:
org.xml.sax.SAXException

includeModel

public void includeModel(java.lang.String string,
                         java.lang.String string1)
                  throws org.xml.sax.SAXException
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:
string - logical URI of the model
string1 - physical URI of the model
Throws:
org.xml.sax.SAXException

logicalURI

public void logicalURI(java.lang.String string)
                throws org.xml.sax.SAXException
Description copied from interface: RDFConsumer
Receives the logical URI of the model.

Specified by:
logicalURI in interface RDFConsumer
Parameters:
string - logical URI of the model
Throws:
org.xml.sax.SAXException

checkForSynonym

public java.net.URI checkForSynonym(java.net.URI original)

statementWithLiteralValue

public void statementWithLiteralValue(java.lang.String subject,
                                      java.lang.String predicate,
                                      java.lang.String object,
                                      java.lang.String lang,
                                      java.lang.String datatype)
                               throws org.xml.sax.SAXException
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
lang - the language
datatype - the URI of the literal's datatype (may be null)
Throws:
org.xml.sax.SAXException

statementWithResourceValue

public void statementWithResourceValue(java.lang.String subject,
                                       java.lang.String predicate,
                                       java.lang.String object)
                                throws org.xml.sax.SAXException
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
Throws:
org.xml.sax.SAXException

translateDataRange

public OWLDataRange translateDataRange(java.net.URI uri)
                                throws OWLException
Throws:
OWLException

translateDataPropertyExpression

public OWLDataPropertyExpression translateDataPropertyExpression(java.net.URI uri)
                                                          throws OWLException
Throws:
OWLException

translateObjectPropertyExpression

public OWLObjectPropertyExpression translateObjectPropertyExpression(java.net.URI mainNode)
                                                              throws OWLException
Throws:
OWLException

translateIndividual

public OWLIndividual translateIndividual(java.net.URI node)
                                  throws OWLException
Throws:
OWLException

translateDescription

public OWLDescription translateDescription(java.net.URI mainNode)
                                    throws OWLException
Throws:
OWLException

getDescriptionIfTranslated

public OWLDescription getDescriptionIfTranslated(java.net.URI mainNode)

translateToObjectPropertyList

public java.util.List<OWLObjectPropertyExpression> translateToObjectPropertyList(java.net.URI mainNode)
                                                                          throws OWLException
Throws:
OWLException

translateToDataPropertyList

public java.util.List<OWLDataPropertyExpression> translateToDataPropertyList(java.net.URI mainNode)
                                                                      throws OWLException
Throws:
OWLException

translateToDescriptionSet

public java.util.Set<OWLDescription> translateToDescriptionSet(java.net.URI mainNode)
                                                        throws OWLException
Throws:
OWLException

translateToConstantSet

public java.util.Set<OWLConstant> translateToConstantSet(java.net.URI mainNode)
                                                  throws OWLException
Throws:
OWLException

translateToIndividualSet

public java.util.Set<OWLIndividual> translateToIndividualSet(java.net.URI mainNode)
                                                      throws OWLException
Throws:
OWLException

getResourceObject

public java.net.URI getResourceObject(java.net.URI subject,
                                      java.net.URI predicate,
                                      boolean consume)

getLiteralObject

public OWLConstant getLiteralObject(java.net.URI subject,
                                    java.net.URI predicate,
                                    boolean consume)

isTriplePresent

public boolean isTriplePresent(java.net.URI subject,
                               java.net.URI predicate,
                               java.net.URI object,
                               boolean consume)

isTriplePresent

public boolean isTriplePresent(java.net.URI subject,
                               java.net.URI predicate,
                               OWLConstant object,
                               boolean consume)

hasPredicate

public boolean hasPredicate(java.net.URI subject,
                            java.net.URI predicate)

hasPredicateObject

public boolean hasPredicateObject(java.net.URI subject,
                                  java.net.URI predicate,
                                  java.net.URI object)
                           throws OWLException
Throws:
OWLException

addList

public void addList(java.net.URI uri)

isList

public boolean isList(java.net.URI uri,
                      boolean consume)

addRest

public void addRest(java.net.URI subject,
                    java.net.URI object)

addFirst

public void addFirst(java.net.URI subject,
                     java.net.URI object)

getFirstResource

public java.net.URI getFirstResource(java.net.URI subject,
                                     boolean consume)

getFirstLiteral

public OWLConstant getFirstLiteral(java.net.URI subject)

getRest

public java.net.URI getRest(java.net.URI subject,
                            boolean consume)

addFirst

public void addFirst(java.net.URI subject,
                     OWLConstant object)

addOntology

public void addOntology(java.net.URI uri)

addReifiedAxiom

public void addReifiedAxiom(java.net.URI axiomURI,
                            OWLAxiom axiom)

isAxiom

public boolean isAxiom(java.net.URI uri)

getAxiom

public OWLAxiom getAxiom(java.net.URI uri)

isDataRange

public boolean isDataRange(java.net.URI uri)

addTriple

public void addTriple(java.net.URI subject,
                      java.net.URI predicate,
                      java.net.URI object)

addTriple

public void addTriple(java.net.URI subject,
                      java.net.URI predicate,
                      OWLConstant con)

setXMLBase

public void setXMLBase(java.lang.String base)