org.semanticweb.kaon2.api
Interface Ontology


public interface Ontology

Represents a DL ontology.


Method Summary
 java.lang.Object accept(KAON2Visitor visitor)
          Accepts a visitor for this object.
 void addOntologyListener(OntologyListener ontologyListener)
          Adds a listener to this ontology.
 void addOntologyProperty(java.lang.String ontologyPropertyURI, java.lang.String value)
          Adds the property value for this ontology.
 void addToImports(Ontology ontology)
          Adds specified ontology to the set of ontologies imported in this ontology.
 void applyChanges(java.util.List<OntologyChangeEvent> changes)
          Applies a list of changes to the ontology.
 void cancelPendingImportSave()
          Cancels the import or save operation that is pending on this ontology.
 boolean containsAxiom(Axiom axiom, boolean checkIncludedOntologies)
          Checks whether given axiom is contained in this ontology.
 boolean containsEntity(Entity entity, boolean checkIncludedOntologies)
          Checks whether given entity is contained in this ontology.
 Request<Axiom> createAxiomRequest()
          Returns an object that can be used to retrieve axioms.
<E extends Axiom>
Request<E>
createAxiomRequest(java.lang.Class<E> axiomType)
          Returns an object that can be used to retrieve axioms of given type.
 Request<Entity> createEntityRequest()
          Returns an object that can be used to retrieve existing entities.
<E extends Entity>
Request<E>
createEntityRequest(java.lang.Class<E> entityType)
          Returns an object that can be used to retrieve existing entities of given type.
 Reasoner createReasoner()
          Creates a reasoner for this ontolgy.
 java.util.Set<Ontology> getAllImportedOntologies()
          Returns the set of all imported ontologies (including the ones which are indirectly imported).
 KAON2Connection getConnection()
          Returns the connection associated with this ontology.
 Ontology getDeclaringOntology(Axiom axiom)
          Returns the ontology where the given axiom is declared.
 boolean getDuplicateAxiomsThrowException()
          Returns true if duplicate additions of axioms to this ontology result in an exception.
 java.util.Set<Ontology> getImportedOntologies()
          Returns the set of imported ontologies.
 long getLockTimeout()
          Returns the time how much this ontology waits to acquire locks.
 java.util.Map<java.lang.String,java.util.Set<java.lang.String>> getOntologyProperties()
          Returns the properties for this ontology.
 java.util.Set<java.lang.String> getOntologyPropertyValues(java.lang.String ontologyPropertyURI)
          Returns the values of a property for this ontology.
 java.lang.String getOntologyURI()
          Returns the URI of the ontology.
 java.util.Map<java.lang.String,java.lang.Object> getParameters()
          Returns the parameters of this ontology.
 java.lang.String getPhysicalURI()
          Returns the physical URI of the ontology.
 void importContentsFrom(java.io.File file)
          Exports this ontolgy into specified format.
 void importContentsFrom(java.io.InputStream inputStream, java.lang.String physicalURI)
          Adds axioms from the supplied input stream into this ontology.
 void importContentsFrom(java.io.Reader reader, java.lang.String physicalURI)
          Adds the contents from the supplied source into this ontology.
 void importContentsFrom(java.lang.String physicalURI)
          Exports this ontolgy into specified format.
 void persist()
          Ensures that the ontology is persisted.
 void removeFromImports(Ontology ontology)
          Removes specified ontology from the set of ontologies imported in this ontology.
 void removeOntologyListener(OntologyListener ontologyListener)
          Removes a listener from this ontology.
 void removeOntologyProperty(java.lang.String ontologyPropertyURI, java.lang.String value)
          Removes the property with given value for this ontology.
 void resumeNotifications()
          Resumes the the change notifications for this ontology.
 void saveOntology(OntologyFileFormat ontologyFileFormat, java.io.File file, java.lang.String encoding)
          Exports this ontolgy into specified format.
 void saveOntology(OntologyFileFormat ontologyFileFormat, java.io.OutputStream outputStream, java.lang.String encoding)
          Exports this ontolgy into specified format.
 void saveOntology(OntologyFileFormat ontologyFileFormat, java.lang.String physicalURI, java.lang.String encoding)
          Exports this ontolgy into specified format.
 void saveOntology(OntologyFileFormat ontologyFileFormat, java.io.Writer writer, java.lang.String encoding)
          Exports this ontolgy into specified format.
 void setDuplicateAxiomsThrowException(boolean throwExceptionOnDuplicates)
          Determines if duplicate additions of axioms to this ontology should result in an exception.
 void setLockTimeout(long lockTimeout)
          Determines the time in miliseconds how much one should wait for acquiring locks.
 void suspendNotifications()
          Suspends the change notifications for this ontology.
 

Method Detail

getConnection

KAON2Connection getConnection()
Returns the connection associated with this ontology.

Returns:
the connection of the ontology

getParameters

java.util.Map<java.lang.String,java.lang.Object> getParameters()
Returns the parameters of this ontology.

Returns:
the parameters of this ontology

getOntologyURI

java.lang.String getOntologyURI()
Returns the URI of the ontology.

Returns:
the URI of the ontology

getPhysicalURI

java.lang.String getPhysicalURI()
Returns the physical URI of the ontology.

Returns:
the physical URI of the ontology

addToImports

void addToImports(Ontology ontology)
                  throws KAON2Exception
Adds specified ontology to the set of ontologies imported in this ontology.

Parameters:
ontology - the ontology that is imported
Throws:
KAON2Exception - thrown if there is an error

removeFromImports

void removeFromImports(Ontology ontology)
                       throws KAON2Exception
Removes specified ontology from the set of ontologies imported in this ontology.

Parameters:
ontology - the ontology that is imported
Throws:
KAON2Exception - thrown if there is an error

getImportedOntologies

java.util.Set<Ontology> getImportedOntologies()
Returns the set of imported ontologies. This method returns only the directly included ontologies.

Returns:
the set of imported ontologies

getAllImportedOntologies

java.util.Set<Ontology> getAllImportedOntologies()
Returns the set of all imported ontologies (including the ones which are indirectly imported).

Returns:
the set of all imported ontologies

accept

java.lang.Object accept(KAON2Visitor visitor)
Accepts a visitor for this object.

Parameters:
visitor - the visitor for this object
Returns:
the return value of the visitor (can be null)

getOntologyProperties

java.util.Map<java.lang.String,java.util.Set<java.lang.String>> getOntologyProperties()
                                                                                      throws KAON2Exception
Returns the properties for this ontology.

Returns:
the property values for this ontology
Throws:
KAON2Exception - thrown if there is an error

getOntologyPropertyValues

java.util.Set<java.lang.String> getOntologyPropertyValues(java.lang.String ontologyPropertyURI)
                                                          throws KAON2Exception
Returns the values of a property for this ontology.

Parameters:
ontologyPropertyURI - the ontology property
Returns:
the value of a property for this ontology
Throws:
KAON2Exception - thrown if there is an error

addOntologyProperty

void addOntologyProperty(java.lang.String ontologyPropertyURI,
                         java.lang.String value)
                         throws KAON2Exception
Adds the property value for this ontology.

Parameters:
ontologyPropertyURI - the ontology property
value - the value
Throws:
KAON2Exception - thrown if there is an error

removeOntologyProperty

void removeOntologyProperty(java.lang.String ontologyPropertyURI,
                            java.lang.String value)
                            throws KAON2Exception
Removes the property with given value for this ontology.

Parameters:
ontologyPropertyURI - the ontology property
value - the value
Throws:
KAON2Exception - thrown if there is an error (e.g. if value does not exist)

applyChanges

void applyChanges(java.util.List<OntologyChangeEvent> changes)
                  throws KAON2Exception
Applies a list of changes to the ontology.

Parameters:
changes - the set of changes applied to the ontology
Throws:
KAON2Exception - thrown if there is an error

suspendNotifications

void suspendNotifications()
Suspends the change notifications for this ontology.


resumeNotifications

void resumeNotifications()
Resumes the the change notifications for this ontology.


addOntologyListener

void addOntologyListener(OntologyListener ontologyListener)
Adds a listener to this ontology.

Parameters:
ontologyListener - the listener object

removeOntologyListener

void removeOntologyListener(OntologyListener ontologyListener)
Removes a listener from this ontology.

Parameters:
ontologyListener - the listener object

getLockTimeout

long getLockTimeout()
Returns the time how much this ontology waits to acquire locks.

Returns:
lockTimeout the amount of time in miliseconds to wait for a lock (-1 means it waits forever)

setLockTimeout

void setLockTimeout(long lockTimeout)
Determines the time in miliseconds how much one should wait for acquiring locks.

Parameters:
lockTimeout - the amount of time in miliseconds to wait for a lock (-1 means wait forever)

getDuplicateAxiomsThrowException

boolean getDuplicateAxiomsThrowException()
                                         throws KAON2Exception
Returns true if duplicate additions of axioms to this ontology result in an exception. By default this property is always true.

Returns:
true if duplicate additions of axioms result in an exception
Throws:
KAON2Exception - thrown if there is an error (e.g. if value does not exist)

setDuplicateAxiomsThrowException

void setDuplicateAxiomsThrowException(boolean throwExceptionOnDuplicates)
                                      throws KAON2Exception
Determines if duplicate additions of axioms to this ontology should result in an exception.

Parameters:
throwExceptionOnDuplicates - true if duplicate additions of axioms should result in an exception
Throws:
KAON2Exception - thrown if there is an error (e.g. if value does not exist)

containsAxiom

boolean containsAxiom(Axiom axiom,
                      boolean checkIncludedOntologies)
                      throws KAON2Exception
Checks whether given axiom is contained in this ontology.

Parameters:
axiom - the axiom to be checked
checkIncludedOntologies - if true, then included ontologies are checked for the axiom as well
Returns:
true if the ontology contains the axiom
Throws:
KAON2Exception - thrown if there is an error

getDeclaringOntology

Ontology getDeclaringOntology(Axiom axiom)
                              throws KAON2Exception
Returns the ontology where the given axiom is declared. This method searches this and all included ontologies and returnes an ontology which contains the axiom. If no ontology contains the axiom, null is retruned. If more then one ontology contains the axiom, one of them is chosen non-deterministically.

Parameters:
axiom - the axiom whose declaring ontology should be determined
Returns:
the ontology containing the axiom
Throws:
KAON2Exception - thrown if there is an error

containsEntity

boolean containsEntity(Entity entity,
                       boolean checkIncludedOntologies)
                       throws KAON2Exception
Checks whether given entity is contained in this ontology. Notice that an entity is contained in an ontology as soon as some axiom uses it, i.e. there is no notion of "creating" an entity in an ontology.

Parameters:
entity - the entity to be checked
checkIncludedOntologies - if true, then included ontologies are checked for the entity as well
Returns:
true if the ontology contains the entity
Throws:
KAON2Exception - thrown if there is an error

createAxiomRequest

Request<Axiom> createAxiomRequest()
Returns an object that can be used to retrieve axioms.

Returns:
an object for retrieving axioms

createAxiomRequest

<E extends Axiom> Request<E> createAxiomRequest(java.lang.Class<E> axiomType)
Returns an object that can be used to retrieve axioms of given type.

Parameters:
axiomType - the type of the axioms to be retrieved
Returns:
an object for retrieving axioms of given type

createEntityRequest

Request<Entity> createEntityRequest()
Returns an object that can be used to retrieve existing entities.

Returns:
an object for retrieving entities

createEntityRequest

<E extends Entity> Request<E> createEntityRequest(java.lang.Class<E> entityType)
Returns an object that can be used to retrieve existing entities of given type.

Parameters:
entityType - the type of the entity
Returns:
an object for retrieving entities of given type

saveOntology

void saveOntology(OntologyFileFormat ontologyFileFormat,
                  java.io.Writer writer,
                  java.lang.String encoding)
                  throws KAON2Exception,
                         java.io.IOException,
                         java.lang.InterruptedException
Exports this ontolgy into specified format. The thread of the exporting process can be interrupted. Note that this saves only axioms from this ontology; included ontologies are not processed.

Parameters:
ontologyFileFormat - the format into which the ontology is exported
writer - the writer into which the ontology is exported
encoding - the encoding for XML
Throws:
KAON2Exception - thrown if there is an error
java.io.IOException - thrown if there is an I/O error
java.lang.InterruptedException - thrown if the export process is interrupted

saveOntology

void saveOntology(OntologyFileFormat ontologyFileFormat,
                  java.io.OutputStream outputStream,
                  java.lang.String encoding)
                  throws KAON2Exception,
                         java.io.IOException,
                         java.lang.InterruptedException
Exports this ontolgy into specified format. The thread of the exporting process can be interrupted. Note that this saves only axioms from this ontology; included ontologies are not processed.

Parameters:
ontologyFileFormat - the format into which the ontology is exported
outputStream - the output stream into which the ontology is exported
encoding - the encoding for XML
Throws:
KAON2Exception - thrown if there is an error
java.io.IOException - thrown if there is an I/O error
java.lang.InterruptedException - thrown if the export process is interrupted

saveOntology

void saveOntology(OntologyFileFormat ontologyFileFormat,
                  java.io.File file,
                  java.lang.String encoding)
                  throws KAON2Exception,
                         java.io.IOException,
                         java.lang.InterruptedException
Exports this ontolgy into specified format. The thread of the exporting process can be interrupted. Note that this saves only axioms from this ontology; included ontologies are not processed.

Parameters:
ontologyFileFormat - the format into which the ontology is exported
file - the file into which the ontology is exported
encoding - the encoding for XML
Throws:
KAON2Exception - thrown if there is an error
java.io.IOException - thrown if there is an I/O error
java.lang.InterruptedException - thrown if the export process is interrupted

saveOntology

void saveOntology(OntologyFileFormat ontologyFileFormat,
                  java.lang.String physicalURI,
                  java.lang.String encoding)
                  throws KAON2Exception,
                         java.io.IOException,
                         java.lang.InterruptedException
Exports this ontolgy into specified format. The thread of the exporting process can be interrupted. Note that this saves only axioms from this ontology; included ontologies are not processed.

Parameters:
ontologyFileFormat - the format into which the ontology is exported
physicalURI - the physical URI into which the ontology is exported (currently only file URIs are supproted)
encoding - the encoding for XML
Throws:
KAON2Exception - thrown if there is an error
java.io.IOException - thrown if there is an I/O error
java.lang.InterruptedException - thrown if the export process is interrupted

importContentsFrom

void importContentsFrom(java.io.Reader reader,
                        java.lang.String physicalURI)
                        throws KAON2Exception,
                               java.io.IOException,
                               java.lang.InterruptedException
Adds the contents from the supplied source into this ontology.

Parameters:
reader - the reader containing the ontology text
physicalURI - the physical URI of the ontology text
Throws:
KAON2Exception - thrown if there is an error
java.io.IOException - thrown if there is an I/O error
java.lang.InterruptedException - thrown if the export process is interrupted

importContentsFrom

void importContentsFrom(java.io.InputStream inputStream,
                        java.lang.String physicalURI)
                        throws KAON2Exception,
                               java.io.IOException,
                               java.lang.InterruptedException
Adds axioms from the supplied input stream into this ontology.

Parameters:
inputStream - the input stream containing the ontology text
physicalURI - the physical URI of the ontology text
Throws:
KAON2Exception - thrown if there is an error
java.io.IOException - thrown if there is an I/O error
java.lang.InterruptedException - thrown if the export process is interrupted

importContentsFrom

void importContentsFrom(java.io.File file)
                        throws KAON2Exception,
                               java.io.IOException,
                               java.lang.InterruptedException
Exports this ontolgy into specified format. The thread of the exporting process can be interrupted. Note that this saves only axioms from this ontology; included ontologies are not processed.

Parameters:
file - the file containing the ontology text
Throws:
KAON2Exception - thrown if there is an error
java.io.IOException - thrown if there is an I/O error
java.lang.InterruptedException - thrown if the export process is interrupted

importContentsFrom

void importContentsFrom(java.lang.String physicalURI)
                        throws KAON2Exception,
                               java.io.IOException,
                               java.lang.InterruptedException
Exports this ontolgy into specified format. The thread of the exporting process can be interrupted. Note that this saves only axioms from this ontology; included ontologies are not processed.

Parameters:
physicalURI - the physical URI containing the ontology text
Throws:
KAON2Exception - thrown if there is an error
java.io.IOException - thrown if there is an I/O error
java.lang.InterruptedException - thrown if the export process is interrupted

cancelPendingImportSave

void cancelPendingImportSave()
                             throws KAON2Exception
Cancels the import or save operation that is pending on this ontology. If no open operation is pending, this method has no effect.

Throws:
KAON2Exception - thrown if there is an error

persist

void persist()
             throws KAON2Exception
Ensures that the ontology is persisted. The type of persistent store is defined by the ontology type.

Throws:
KAON2Exception - thrown if there is an error

createReasoner

Reasoner createReasoner()
                        throws KAON2Exception
Creates a reasoner for this ontolgy. After the obtained reasoner is no longer needed, you should call dispose() on it to avoid serious resource leaks.

Returns:
the reasoner for this onology
Throws:
KAON2Exception - thrown if the reasoner cannot be created