Package org.semanticweb.owlapi.model
Interface OWLOntologyManager
- All Superinterfaces:
HasAddAxiom
,HasAddAxioms
,HasApplyChange
,HasApplyChanges
,HasContainsOntology
,HasDataFactory
,HasGetOntologies
,HasGetOntologyById
,HasOntologyChangeListeners
,HasOntologyConfigurator
,HasOntologyLoaderConfiguration
,HasOntologyWriterConfiguration
,HasRemoveAxiom
,HasRemoveAxioms
,OWLOntologySetProvider
,Serializable
- All Known Implementing Classes:
OWLOntologyManagerImpl
public interface OWLOntologyManager
extends OWLOntologySetProvider, HasDataFactory, HasGetOntologyById, HasApplyChanges, HasApplyChange, HasAddAxioms, HasAddAxiom, HasRemoveAxioms, HasRemoveAxiom, HasContainsOntology, HasOntologyChangeListeners, HasOntologyConfigurator, HasOntologyLoaderConfiguration, HasOntologyWriterConfiguration, Serializable
An
An
OWLOntologyManager
manages a set of ontologies. It is the main point for creating,
loading and accessing ontologies. An
OWLOntologyManager
also manages the mapping between an ontology and its ontology
document.- Since:
- 2.0.0
- Author:
- Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
addIRIMapper
(OWLOntologyIRIMapper mapper) Deprecated.void
In the case where silent missing imports handling is enabled, a listener can be attached via this method so that there is a mechanism that allows clients to be informed of the reason when an import cannot be loaded.void
addOntologyChangeListener
(OWLOntologyChangeListener listener, OWLOntologyChangeBroadcastStrategy strategy) Adds an ontology change listener, which listens to ontology changes.void
Adds an ontology change progress listener.void
void
Adds an ontology loaded listener to this manager.void
addOntologyStorer
(OWLStorerFactory storer) Deprecated.usegetOntologyStorers().add()
insteadvoid
Deprecated.usegetIRIMappers().clear()
insteadvoid
Clear all ontologies, listeners and maps from the manager.void
Deprecated.usegetOntologyStorers().clear()
insteadboolean
Determines if there is an ontology that has the specified ontology IRI, regardless of version IRI.boolean
contains
(OWLOntology ontology) boolean
Determines if there is an ontology with the specified id that is managed by this manager; this method works only with non anonymous ids.boolean
containsVersion
(IRI ontologyVersionIRI) Determines if there is an ontology with the specified version IRI, that is managed by this manager.copyOntology
(OWLOntology toCopy, OntologyCopy settings) Copy an ontology from another manager to this one.default OWLOntology
Creates a new (empty) ontology that does not have an ontology IRI (and therefore does not have a version IRI).default OWLOntology
createOntology
(Collection<OWLAxiom> axioms) Creates a new ontology that is initialised to contain specific axioms.default OWLOntology
createOntology
(Collection<OWLAxiom> axioms, IRI ontologyIRI) Creates a new ontology that has the specified ontology IRI and is initialised to contain specific axioms.default OWLOntology
createOntology
(Stream<OWLAxiom> axioms) Creates a new ontology that is initialised to contain specific axioms.createOntology
(Stream<OWLAxiom> axioms, IRI ontologyIRI) Creates a new ontology that has the specified ontology IRI and is initialised to contain specific axioms.default OWLOntology
createOntology
(IRI ontologyIRI) Creates a new (empty) ontology that has the specified ontology IRI (and no version IRI).default OWLOntology
createOntology
(IRI ontologyIRI, Collection<OWLOntology> ontologies) Creates a new ontology that has the specified ontology IRI and is initialised to contain the axioms that are contained in the specified ontologies.default OWLOntology
createOntology
(IRI ontologyIRI, Collection<OWLOntology> ontologies, boolean copyLogicalAxiomsOnly) Creates a new ontology that has the specified ontology IRI and is initialised to contain the axioms that are contained in the specified ontologies.createOntology
(IRI ontologyIRI, Stream<OWLOntology> ontologies, boolean copyLogicalAxiomsOnly) Creates a new ontology that has the specified ontology IRI and is initialised to contain the axioms that are contained in the specified ontologies.createOntology
(OWLOntologyID ontologyID) Creates a new (empty) ontology that has the specified ontology ID.directImports
(OWLOntology ontology) Stream of loaded ontologies that the specified ontology is related to via the directlyImports relation as defined in Section 3.4 of the OWL 2 Structural specificationdefault Set<OWLOntology>
getDirectImports
(OWLOntology ontology) Gets the set of loaded ontologies that the specified ontology is related to via the directlyImports relation as defined in Section 3.4 of the OWL 2 Structural specificationgetImportedOntology
(OWLImportsDeclaration declaration) Given an imports declaration, obtains the ontology that this import has been resolved to.default Set<OWLOntology>
getImports
(OWLOntology ontology) Gets the set of ontologies that are in the transitive closure of the directly imports relation.default Set<OWLOntology>
getImportsClosure
(OWLOntology ontology) Gets the imports closure for the specified ontology.default OWLDocumentFormat
getNonnullOntologyFormat
(OWLOntology ontology) Gets the ontology format for the specified ontology, ensuring it is not null (an error is thrown if the ontology has no format).default Set<OWLOntology>
getOntologies
(OWLAxiom axiom) Gets the ontologies that are managed by this manager that contain the specified axiom.getOntology
(IRI ontologyIRI) Gets a previously loaded/created ontology that has the specified ontology IRI, regardless of version IRI.getOntology
(OWLOntologyID ontologyID) Get a previously loaded/created ontology that has the specified ontology ID.getOntologyDocumentIRI
(OWLOntology ontology) Gets the document IRI for a given ontology.getOntologyFormat
(OWLOntology ontology) Gets the ontology format for the specified ontology.default Set<OWLOntologyID>
getOntologyIDsByVersion
(IRI ontologyVersionIRI) Gets a set of OWLOntologyIDs representing ontologies that are managed by this manager.getSortedImportsClosure
(OWLOntology ontology) Gets the topologically ordered imports closure.default Set<OWLOntology>
getVersions
(IRI ontology) Deprecated.useversions(IRI)
imports
(OWLOntology ontology) Gets the stream of ontologies that are in the transitive closure of the directly imports relation.importsClosure
(OWLOntology ontology) Imports closure stream for the specified ontology.loadOntology
(IRI ontologyIRI) Loads an ontology that is assumed to have the specifiedontologyIRI
as its IRI or version IRI.default OWLOntology
Loads an ontology from an ontology document contained in a local file.default OWLOntology
loadOntologyFromOntologyDocument
(InputStream inputStream) Loads an ontology from an ontology document obtained from an input stream.default OWLOntology
loadOntologyFromOntologyDocument
(OWLOntologyDocumentSource documentSource) A convenience method that load an ontology from an input source.loadOntologyFromOntologyDocument
(OWLOntologyDocumentSource documentSource, OWLOntologyLoaderConfiguration config) A convenience method that load an ontology from an input source with specified configuration.default OWLOntology
loadOntologyFromOntologyDocument
(IRI documentIRI) Loads an ontology from an ontology document specified by an IRI.default void
makeLoadImportRequest
(OWLImportsDeclaration declaration) Requests that the manager loads an imported ontology that is described by an imports statement.void
makeLoadImportRequest
(OWLImportsDeclaration declaration, OWLOntologyLoaderConfiguration configuration) Requests that the manager loads an imported ontology that is described by an imports statement.default Stream<OWLOntology>
ontologies
(OWLAxiom axiom) Gets the ontologies that are managed by this manager that contain the specified axiom.ontologyIDsByVersion
(IRI ontologyVersionIRI) Gets a stream of OWLOntologyIDs representing ontologies that are managed by this manager.void
void
removeIRIMapper
(OWLOntologyIRIMapper mapper) Deprecated.usegetIRIMappers().remove()
insteadvoid
Removes a previously added missing import listener.default void
removeOntology
(OWLOntology ontology) Attempts to remove an ontology.void
removeOntology
(OWLOntologyID ontologyID) Attempts to remove an ontology.void
Removes a previously added ontology change listener.void
void
Removes a previously added ontology loaded listener.void
removeOntologyStorer
(OWLStorerFactory storer) Deprecated.usegetOntologyStorers().remove()
insteaddefault void
saveOntology
(OWLOntology ontology) Saves the specified ontology.default void
saveOntology
(OWLOntology ontology, OutputStream outputStream) Saves the specified ontology, to the specified output streamdefault void
saveOntology
(OWLOntology ontology, OWLOntologyDocumentTarget documentTarget) Saves the specified ontology to the specifiedOWLOntologyDocumentTarget
.default void
saveOntology
(OWLOntology ontology, IRI documentIRI) Saves the specified ontology, using the specified document IRI to determine where/how the ontology should be saved.default void
saveOntology
(OWLOntology ontology, OWLDocumentFormat ontologyFormat) Saves the specified ontology in the specified ontology format to its document URI.default void
saveOntology
(OWLOntology ontology, OWLDocumentFormat ontologyFormat, OutputStream outputStream) Saves the specified ontology to the specified output stream in the specified ontology format.void
saveOntology
(OWLOntology ontology, OWLDocumentFormat ontologyFormat, OWLOntologyDocumentTarget documentTarget) Saves the specified ontology to the specified output target in the specified ontology format.void
saveOntology
(OWLOntology ontology, OWLDocumentFormat ontologyFormat, IRI documentIRI) Saves the specified ontology to the specified document IRI in the specified ontology format.void
Sets the default strategy that is used to broadcast ontology changes.void
setIRIMappers
(Set<OWLOntologyIRIMapper> mappers) Set the collection of IRI mappers.void
setOntologyDocumentIRI
(OWLOntology ontology, IRI documentIRI) Overrides the current document IRI for a given ontology.void
setOntologyFactories
(Set<OWLOntologyFactory> factories) Set the collection of ontology factories.void
setOntologyFormat
(OWLOntology ontology, OWLDocumentFormat ontologyFormat) Sets the format for the specified ontology.void
setOntologyParsers
(Set<OWLParserFactory> parsers) Set the collection of parsers.void
setOntologyStorers
(Set<OWLStorerFactory> storers) Set the list of ontology storers.default Stream<OWLOntology>
Gets the versions (if any) of the ontology that have the specified IRIMethods inherited from interface org.semanticweb.owlapi.model.HasAddAxiom
addAxiom
Methods inherited from interface org.semanticweb.owlapi.model.HasAddAxioms
addAxioms, addAxioms
Methods inherited from interface org.semanticweb.owlapi.model.HasApplyChange
applyChange
Methods inherited from interface org.semanticweb.owlapi.model.HasApplyChanges
applyChanges, applyChanges, applyChangesAndGetDetails, applyChangesAndGetDetails
Methods inherited from interface org.semanticweb.owlapi.model.HasDataFactory
getOWLDataFactory
Methods inherited from interface org.semanticweb.owlapi.model.HasGetOntologies
getOntologies, ontologies
Methods inherited from interface org.semanticweb.owlapi.model.HasOntologyChangeListeners
addOntologyChangeListener, removeOntologyChangeListener
Methods inherited from interface org.semanticweb.owlapi.model.HasOntologyConfigurator
getOntologyConfigurator, setOntologyConfigurator
Methods inherited from interface org.semanticweb.owlapi.model.HasOntologyLoaderConfiguration
getOntologyLoaderConfiguration, setOntologyLoaderConfiguration
Methods inherited from interface org.semanticweb.owlapi.model.HasOntologyWriterConfiguration
getOntologyWriterConfiguration, setOntologyWriterConfiguration
Methods inherited from interface org.semanticweb.owlapi.model.HasRemoveAxiom
removeAxiom
Methods inherited from interface org.semanticweb.owlapi.model.HasRemoveAxioms
removeAxioms, removeAxioms
-
Method Details
-
clearOntologies
void clearOntologies()Clear all ontologies, listeners and maps from the manager. Leave injected factories, storers and parsers. -
getOntologies
Gets the ontologies that are managed by this manager that contain the specified axiom.- Parameters:
axiom
- The axioms- Returns:
- The set of ontologies such that for each ontology O the specified axiom is contained in O. The set that is returned is a copy; modifications to the returned set will not be reflected in this object.
-
ontologies
Gets the ontologies that are managed by this manager that contain the specified axiom.- Parameters:
axiom
- The axioms- Returns:
- The stream of ontologies such that for each ontology O the specified axiom is contained in O.
-
getVersions
Deprecated.useversions(IRI)
Gets the versions (if any) of the ontology that have the specified IRI- Parameters:
ontology
- The ontology IRI- Returns:
- The set of ontologies that have the specified ontology IRI.
-
versions
Gets the versions (if any) of the ontology that have the specified IRI- Parameters:
ontology
- The ontology IRI- Returns:
- The set of ontologies that have the specified ontology IRI.
-
contains
- Parameters:
ontology
- ontology to check- Returns:
- true if the ontology is contained
-
contains
Determines if there is an ontology that has the specified ontology IRI, regardless of version IRI. If there is no ontology which has the input IRI as ontology IRI, the IRI is matched against the version IRI.- Parameters:
ontologyIRI
- The IRI of the ontology to test for.- Returns:
true
if there is an ontology with the specified IRI or version IRI, that is managed by this manager, otherwisefalse
.
-
contains
Determines if there is an ontology with the specified id that is managed by this manager; this method works only with non anonymous ids.- Specified by:
contains
in interfaceHasContainsOntology
- Parameters:
id
- The id of the ontology to test for- Returns:
true
if there is an ontology with the specified id that is managed by this manager, otherwisefalse
.
-
containsVersion
Determines if there is an ontology with the specified version IRI, that is managed by this manager.- Parameters:
ontologyVersionIRI
- The version IRI of the ontology to test for (the ontology IRI may be anything)- Returns:
true
if there is an ontology with the specified version IRI, that is managed by this manager, otherwisefalse
.
-
getOntologyIDsByVersion
Gets a set of OWLOntologyIDs representing ontologies that are managed by this manager.- Parameters:
ontologyVersionIRI
- The version IRI to match against all of the known ontologies.- Returns:
- A set of OWLOntologyIDs where the version matches the given version or the empty set if none match. The set that is returned is a copy; modifications to the returned set will not be reflected in this object.
-
ontologyIDsByVersion
Gets a stream of OWLOntologyIDs representing ontologies that are managed by this manager.- Parameters:
ontologyVersionIRI
- The version IRI to match against all of the known ontologies.- Returns:
- A stream of OWLOntologyIDs where the version matches the given version or the empty set if none match.
-
getOntology
Gets a previously loaded/created ontology that has the specified ontology IRI, regardless of version IRI. If there is no ontology which has the input IRI as ontology IRI, the IRI is matched against the version IRI.- Parameters:
ontologyIRI
- The IRI of the ontology to be retrieved.- Returns:
- The ontology that has the specified IRI,
null
if none found.
-
getOntology
Description copied from interface:HasGetOntologyById
Get a previously loaded/created ontology that has the specified ontology ID. For anonymous ids, this method tries to locate the ontology by document IRI.- Specified by:
getOntology
in interfaceHasGetOntologyById
- Parameters:
ontologyID
- The ID of the ontology to retrieve.- Returns:
- The ontology with the specified ID, or
null
if there is no ontology with the specified ID.
-
getImportedOntology
Given an imports declaration, obtains the ontology that this import has been resolved to.- Parameters:
declaration
- The declaration that points to the imported ontology.- Returns:
- The ontology that the imports declaration resolves to, or
null
if the imports declaration could not be resolved to an ontology, because the ontology was not loaded or has been removed from this manager
-
getDirectImports
Gets the set of loaded ontologies that the specified ontology is related to via the directlyImports relation as defined in Section 3.4 of the OWL 2 Structural specification- Parameters:
ontology
- The ontology whose direct imports are to be retrieved.- Returns:
- The set of loaded ontologies that the specified ontology is related to via the directlyImports relation. If the ontology is not managed by this manager then the empty set will be returned. The set that is returned is a copy; modifications to the returned set will not be reflected in this object.
-
directImports
Stream of loaded ontologies that the specified ontology is related to via the directlyImports relation as defined in Section 3.4 of the OWL 2 Structural specification- Parameters:
ontology
- The ontology whose direct imports are to be retrieved.- Returns:
- Stream of loaded ontologies that the specified ontology is related to via the directlyImports relation. If the ontology is not managed by this manager then the empty set will be returned.
-
getImports
Gets the set of ontologies that are in the transitive closure of the directly imports relation.- Parameters:
ontology
- The ontology whose imports are to be retrieved.- Returns:
- A set of
OWLOntology
instances that are in the transitive closure of the directly imports relation of this ontology. If, for what ever reason, an imported ontology could not be loaded, then it will not be contained in the returned set of ontologies. If the ontology is not managed by this manager then the empty set will be returned. The set that is returned is a copy; modifications to the returned set will not be reflected in this object.
-
imports
Gets the stream of ontologies that are in the transitive closure of the directly imports relation.- Parameters:
ontology
- The ontology whose imports are to be retrieved.- Returns:
- Sorted stream of
OWLOntology
ies that are in the transitive closure of the directly imports relation of this ontology. If, for what ever reason, an imported ontology could not be loaded, then it will not be contained in the returned set of ontologies. If the ontology is not managed by this manager then the empty set will be returned.
-
getImportsClosure
Gets the imports closure for the specified ontology.- Parameters:
ontology
- The ontology whose imports closure is to be retrieved.- Returns:
- A
Set
of ontologies that contains the imports closure for the specified ontology. This set will also include the specified ontology. Example: if A imports B and B imports C, then calling this method with A will return the set consisting of A, B and C. If, for what ever reason, an imported ontology could not be loaded, then it will not be contained in the returned set of ontologies. If the ontology is not managed by this manager then the empty set will be returned. The set that is returned is a copy; modifications to the returned set will not be reflected in this object.
-
importsClosure
Imports closure stream for the specified ontology.- Parameters:
ontology
- The ontology whose imports closure is to be retrieved.- Returns:
- Sorted stream of ontologies that contains the imports closure for the specified ontology. It includes the specified ontology.
-
getSortedImportsClosure
Gets the topologically ordered imports closure.- Parameters:
ontology
- The ontology whose imports closure is to be determined.- Returns:
- A list that represents a topological ordering of the imports closure. The first element in the list will be the specified ontology. If the ontology is not managed by this manager then an empty list will be returned.
-
createOntology
Creates a new (empty) ontology that does not have an ontology IRI (and therefore does not have a version IRI). A document IRI will automatically be generated.- Returns:
- The newly created ontology
- Throws:
OWLOntologyCreationException
- if there was a problem creating the ontology
-
createOntology
Creates a new ontology that is initialised to contain specific axioms. The ontology will not have an IRI. The document IRI of the created ontology will be auto-generated.- Parameters:
axioms
- The axioms that should be copied into the new ontology- Returns:
- An ontology without an IRI that contains all of the specified axioms
- Throws:
OWLOntologyCreationException
- if there was a problem creating the new ontology.OWLOntologyChangeException
- if there was a problem copying the axioms.
-
createOntology
Creates a new ontology that is initialised to contain specific axioms. The ontology will not have an IRI. The document IRI of the created ontology will be auto-generated.- Parameters:
axioms
- The axioms that should be copied into the new ontology- Returns:
- An ontology without an IRI that contains all of the specified axioms
- Throws:
OWLOntologyCreationException
- if there was a problem creating the new ontology.OWLOntologyChangeException
- if there was a problem copying the axioms.
-
createOntology
default OWLOntology createOntology(Collection<OWLAxiom> axioms, IRI ontologyIRI) throws OWLOntologyCreationException Creates a new ontology that has the specified ontology IRI and is initialised to contain specific axioms.- Parameters:
ontologyIRI
- The IRI of the new ontology.
The ontology document IRI of the created ontology will be set to the value returned by any installedOWLOntologyIRIMapper
s. If no mappers are installed or the ontology IRI was not mapped to a document IRI by any of the installed mappers, then the ontology document IRI will be set to the value ofontologyIRI
.axioms
- The axioms that should be copied into the new ontology- Returns:
- An ontology that has the specified IRI and contains all of the specified axioms
- Throws:
OWLOntologyCreationException
- if there was a problem creating the new ontology, if the new ontology already exists in this manager.OWLOntologyChangeException
- if there was a problem copying the axioms.OWLOntologyAlreadyExistsException
- if the manager already contains an ontology with the specifiedontologyIRI
.OWLOntologyDocumentAlreadyExistsException
- if the specifiedontologyIRI
is mapped to a ontology document IRI for which there already exists a mapping in this manager.
-
createOntology
OWLOntology createOntology(Stream<OWLAxiom> axioms, IRI ontologyIRI) throws OWLOntologyCreationException Creates a new ontology that has the specified ontology IRI and is initialised to contain specific axioms.- Parameters:
ontologyIRI
- The IRI of the new ontology.
The ontology document IRI of the created ontology will be set to the value returned by any installedOWLOntologyIRIMapper
s. If no mappers are installed or the ontology IRI was not mapped to a document IRI by any of the installed mappers, then the ontology document IRI will be set to the value ofontologyIRI
.axioms
- The axioms that should be copied into the new ontology- Returns:
- An ontology that has the specified IRI and contains all of the specified axioms
- Throws:
OWLOntologyCreationException
- if there was a problem creating the new ontology, if the new ontology already exists in this manager.OWLOntologyChangeException
- if there was a problem copying the axioms.OWLOntologyAlreadyExistsException
- if the manager already contains an ontology with the specifiedontologyIRI
.OWLOntologyDocumentAlreadyExistsException
- if the specifiedontologyIRI
is mapped to a ontology document IRI for which there already exists a mapping in this manager.
-
createOntology
Creates a new (empty) ontology that has the specified ontology IRI (and no version IRI).
The ontology document IRI of the created ontology will be set to the value returned by any installedOWLOntologyIRIMapper
s. If no mappers are installed or the ontology IRI was not mapped to a document IRI by any of the installed mappers, then the ontology document IRI will be set to the value ofontologyIRI
.- Parameters:
ontologyIRI
- The IRI of the ontology to be created. The ontology IRI will be mapped to a document IRI in order to determine the type of ontology factory that will be used to create the ontology. If this mapping isnull
then a default (in memory) implementation of the ontology will most likely be created.- Returns:
- The newly created ontology, or if an ontology with the specified IRI already exists then this existing ontology will be returned.
- Throws:
OWLOntologyCreationException
- If the ontology could not be created.OWLOntologyAlreadyExistsException
- if the manager already contains an ontology with the specifiedontologyIRI
(and no version IRI).OWLOntologyDocumentAlreadyExistsException
- if the specifiedontologyIRI
is mapped to a ontology document IRI for which there already exists a mapping in this manager.
-
createOntology
Creates a new (empty) ontology that has the specified ontology ID.- Parameters:
ontologyID
- The ID of the ontology to be created.
The ontology document IRI of the created ontology will be set to the value returned by any installedOWLOntologyIRIMapper
s. If no mappers are installed or the ontology IRI was not mapped to a document IRI by any of the installed mappers, then the ontology document IRI will be set to the value ofontologyIRI
.- Returns:
- The newly created ontology, or if an ontology with the specified IRI already exists then this existing ontology will be returned.
- Throws:
OWLOntologyCreationException
- If the ontology could not be created.OWLOntologyAlreadyExistsException
- if the manager already contains an ontology with the specifiedontologyID
(and no version IRI).OWLOntologyDocumentAlreadyExistsException
- if the specifiedontologyID
is mapped to a ontology document IRI for which there already exists a mapping in this manager.
-
createOntology
default OWLOntology createOntology(IRI ontologyIRI, Collection<OWLOntology> ontologies, boolean copyLogicalAxiomsOnly) throws OWLOntologyCreationException Creates a new ontology that has the specified ontology IRI and is initialised to contain the axioms that are contained in the specified ontologies. Note that the specified ontologies need not be managed by this manager.
The ontology document IRI of the created ontology will be set to the value returned by any installedOWLOntologyIRIMapper
s. If no mappers are installed or the ontology IRI was not mapped to a document IRI by any of the installed mappers, then the ontology document IRI will be set to the value ofontologyIRI
.- Parameters:
ontologyIRI
- The IRI of the new ontology.ontologies
- The ontologies whose axioms should be copied into the new ontologycopyLogicalAxiomsOnly
- If set totrue
only logical axioms are copied into the new ontology. If set tofalse
then all axioms (including annotation axioms) are copied into the new ontology.- Returns:
- An ontology that has the specified IRI and contains all of the axioms that are contained in the specified ontologies possibly minus all non-logical axioms
- Throws:
OWLOntologyCreationException
- if there was a problem creating the new ontology, if the new ontology already exists in this manager.OWLOntologyAlreadyExistsException
- if the manager already contains an ontology with the specifiedontologyIRI
(and no ontology version IRI).OWLOntologyDocumentAlreadyExistsException
- if the specifiedontologyIRI
is mapped to a ontology document IRI for which there already exists a mapping in this manager.
-
createOntology
OWLOntology createOntology(IRI ontologyIRI, Stream<OWLOntology> ontologies, boolean copyLogicalAxiomsOnly) throws OWLOntologyCreationException Creates a new ontology that has the specified ontology IRI and is initialised to contain the axioms that are contained in the specified ontologies. Note that the specified ontologies need not be managed by this manager.
The ontology document IRI of the created ontology will be set to the value returned by any installedOWLOntologyIRIMapper
s. If no mappers are installed or the ontology IRI was not mapped to a document IRI by any of the installed mappers, then the ontology document IRI will be set to the value ofontologyIRI
.- Parameters:
ontologyIRI
- The IRI of the new ontology.ontologies
- The ontologies whose axioms should be copied into the new ontologycopyLogicalAxiomsOnly
- If set totrue
only logical axioms are copied into the new ontology. If set tofalse
then all axioms (including annotation axioms) are copied into the new ontology.- Returns:
- An ontology that has the specified IRI and contains all of the axioms that are contained in the specified ontologies possibly minus all non-logical axioms
- Throws:
OWLOntologyCreationException
- if there was a problem creating the new ontology, if the new ontology already exists in this manager.OWLOntologyAlreadyExistsException
- if the manager already contains an ontology with the specifiedontologyIRI
(and no ontology version IRI).OWLOntologyDocumentAlreadyExistsException
- if the specifiedontologyIRI
is mapped to a ontology document IRI for which there already exists a mapping in this manager.
-
createOntology
default OWLOntology createOntology(IRI ontologyIRI, Collection<OWLOntology> ontologies) throws OWLOntologyCreationException Creates a new ontology that has the specified ontology IRI and is initialised to contain the axioms that are contained in the specified ontologies. Note that the specified ontologies need not be managed by this manager.
The ontology document IRI of the created ontology will be set to the value returned by any installedOWLOntologyIRIMapper
s. If no mappers are installed or the ontology IRI was not mapped to a document IRI by any of the installed mappers, then the ontology document IRI will be set to the value ofontologyIRI
.- Parameters:
ontologyIRI
- The IRI of the new ontology.ontologies
- The ontologies whose axioms should be copied into the new ontology- Returns:
- An ontology that has the specified IRI and contains all of the axioms that are contained in the specified ontologies
- Throws:
OWLOntologyCreationException
- if there was a problem creating the new ontology, if the new ontology already exists in this manager.OWLOntologyAlreadyExistsException
- if the manager already contains an ontology with the specifiedontologyIRI
(and no version IRI).OWLOntologyDocumentAlreadyExistsException
- if the specifiedontologyIRI
is mapped to a ontology document IRI for which there already exists a mapping in this manager.
-
copyOntology
OWLOntology copyOntology(OWLOntology toCopy, OntologyCopy settings) throws OWLOntologyCreationException Copy an ontology from another manager to this one. The returned OWLOntology will return this manager when getOWLOntologyManager() is invoked. The copy mode is defined by the OntologyCopy parameter: SHALLOW for simply creating a new ontology containing the same axioms and same id, DEEP for copying across format and document IRI, MOVE to remove the ontology from its previous manager.- Parameters:
toCopy
- ontology to copysettings
- settings for the copy- Returns:
- copied ontology. This is the same object as toCopy only for MOVE copies
- Throws:
OWLOntologyCreationException
- if this manager cannot add the new ontology
-
loadOntology
Loads an ontology that is assumed to have the specifiedontologyIRI
as its IRI or version IRI.
The ontology IRI will be mapped to an ontology document IRI. The mapping will be determined using one of the loadedOWLOntologyIRIMapper
objects. By default, if no customOWLOntologyIRIMapper
s have been registered using thegetIRIMappers()
PriorityCollectionPriorityCollection.add(Serializable...)
method, or no mapping can be found, the ontology document IRI is taken to be the specified ontology IRI.- Parameters:
ontologyIRI
- The IRI that identifies the ontology. It is expected that the ontology will also have this IRI (although the OWL API will tolerated situations where this is not the case).- Returns:
- The
OWLOntology
representation of the ontology that was loaded. - Throws:
OWLOntologyCreationException
- If there was a problem in creating and loading the ontology.UnparsableOntologyException
- if the ontology was being parsed from a document and the document contained syntax errors.UnloadableImportException
- if the ontology imports ontologies and one of the imports could not be loaded for what ever reason. If theMissingImportHandlingStrategy
is set toMissingImportHandlingStrategy.SILENT
then this exception will not be thrown. TheUnloadableImportException
contains information about the import declaration that triggered the import and the cause of this exception is anOWLOntologyCreationException
which contains information about why the import could not be loaded.OWLOntologyCreationIOException
- if there was anIOException
when trying to load the ontology.OWLOntologyAlreadyExistsException
- if the manager already contains an ontology with the specifiedontologyIRI
(where the ontology doesn't have a version IRI).OWLOntologyDocumentAlreadyExistsException
- if the specifiedontologyIRI
is mapped to a ontology document IRI for which there already exists a mapping in this manager.
-
loadOntologyFromOntologyDocument
default OWLOntology loadOntologyFromOntologyDocument(IRI documentIRI) throws OWLOntologyCreationException Loads an ontology from an ontology document specified by an IRI. In contrast the theloadOntology(IRI)
method, no mapping is performed on the specified IRI.- Parameters:
documentIRI
- The ontology document IRI where the ontology will be loaded from.- Returns:
- The ontology that was loaded.
- Throws:
OWLOntologyCreationException
- If there was a problem in creating and loading the ontology.UnparsableOntologyException
- if the ontology was being parsed from a document and the document contained syntax errors.UnloadableImportException
- if the ontology imports ontologies and one of the imports could not be loaded for what ever reason. If theMissingImportHandlingStrategy
is set toMissingImportHandlingStrategy.SILENT
then this exception will not be thrown. TheUnloadableImportException
contains information about the import declaration that triggered the import and the cause of this exception is anOWLOntologyCreationException
which contains information about why the import could not be loaded.OWLOntologyCreationIOException
- if there was anIOException
when trying to load the ontology.OWLOntologyDocumentAlreadyExistsException
- if the specifieddocumentIRI
is already the document IRI for a loaded ontology.OWLOntologyAlreadyExistsException
- if the manager already contains an ontology whose ontology IRI and version IRI is the same as the ontology IRI and version IRI of the ontology contained in the document pointed to bydocumentIRI
.
-
loadOntologyFromOntologyDocument
Loads an ontology from an ontology document contained in a local file. The loaded ontology will be assigned a document IRI that corresponds to the file IRI.- Parameters:
file
- The file that contains a representation of an ontology- Returns:
- The ontology that was parsed from the file.
- Throws:
OWLOntologyCreationException
- If there was a problem in creating and loading the ontology.UnparsableOntologyException
- if the ontology could not be parsed.UnloadableImportException
- if the ontology imports ontologies and one of the imports could not be loaded for what ever reason. If theMissingImportHandlingStrategy
is set toMissingImportHandlingStrategy.SILENT
then this exception will not be thrown. TheUnloadableImportException
contains information about the import declaration that triggered the import and the cause of this exception is anOWLOntologyCreationException
which contains information about why the import could not be loaded.OWLOntologyCreationIOException
- if there was anIOException
when trying to load the ontology.OWLOntologyDocumentAlreadyExistsException
- if the IRI of the specified file is already the document IRI for a loaded ontology.OWLOntologyAlreadyExistsException
- if the manager already contains an ontology whose ontology IRI and version IRI is the same as the ontology IRI and version IRI of the ontology contained in the document pointed to bydocumentIRI
.
-
loadOntologyFromOntologyDocument
default OWLOntology loadOntologyFromOntologyDocument(InputStream inputStream) throws OWLOntologyCreationException Loads an ontology from an ontology document obtained from an input stream. The loaded ontology will be assigned an auto-generated document IRI with "inputstream" as its scheme.- Parameters:
inputStream
- The input stream that can be used to obtain a representation of an ontology- Returns:
- The ontology that was parsed from the input stream.
- Throws:
OWLOntologyCreationException
- If there was a problem in creating and loading the ontology.UnparsableOntologyException
- if the ontology could not be parsed.UnloadableImportException
- if the ontology imports ontologies and one of the imports could not be loaded for what ever reason. If theMissingImportHandlingStrategy
is set toMissingImportHandlingStrategy.SILENT
then this exception will not be thrown. TheUnloadableImportException
contains information about the import declaration that triggered the import and the cause of this exception is anOWLOntologyCreationException
which contains information about why the import could not be loaded.OWLOntologyCreationIOException
- if there was anIOException
when trying to load the ontology.OWLOntologyAlreadyExistsException
- if the manager already contains an ontology whose ontology IRI and version IRI is the same as the ontology IRI and version IRI of the ontology obtained from parsing the content of the input stream.
-
loadOntologyFromOntologyDocument
default OWLOntology loadOntologyFromOntologyDocument(OWLOntologyDocumentSource documentSource) throws OWLOntologyCreationException A convenience method that load an ontology from an input source.- Parameters:
documentSource
- The input source that describes where the ontology should be loaded from.- Returns:
- The ontology that was loaded.
- Throws:
OWLOntologyCreationException
- If there was a problem in creating and loading the ontology.UnparsableOntologyException
- if the ontology was being parsed from a document and the document contained syntax errors.UnloadableImportException
- if the ontology imports ontologies and one of the imports could not be loaded for what ever reason. If theMissingImportHandlingStrategy
is set toMissingImportHandlingStrategy.SILENT
then this exception will not be thrown. TheUnloadableImportException
contains information about the import declaration that triggered the import and the cause of this exception is anOWLOntologyCreationException
which contains information about why the import could not be loaded.OWLOntologyCreationIOException
- if there was anIOException
when trying to load the ontology.OWLOntologyDocumentAlreadyExistsException
- if the document IRI of the input source is already the document IRI for a loaded ontology.OWLOntologyAlreadyExistsException
- if the manager already contains an ontology whose ontology IRI and version IRI is the same as the ontology IRI and version IRI of the ontology contained in the document represented by the input source.
-
loadOntologyFromOntologyDocument
OWLOntology loadOntologyFromOntologyDocument(OWLOntologyDocumentSource documentSource, OWLOntologyLoaderConfiguration config) throws OWLOntologyCreationException A convenience method that load an ontology from an input source with specified configuration.- Parameters:
documentSource
- The input source that describes where the ontology should be loaded from.config
- the configuration to use- Returns:
- The ontology that was loaded.
- Throws:
OWLOntologyCreationException
- If there was a problem in creating and loading the ontology.UnparsableOntologyException
- if the ontology was being parsed from a document and the document contained syntax errors.UnloadableImportException
- if the ontology imports ontologies and one of the imports could not be loaded for what ever reason. If theMissingImportHandlingStrategy
is set toMissingImportHandlingStrategy.SILENT
then this exception will not be thrown. TheUnloadableImportException
contains information about the import declaration that triggered the import and the cause of this exception is anOWLOntologyCreationException
which contains information about why the import could not be loaded.OWLOntologyCreationIOException
- if there was anIOException
when trying to load the ontology.OWLOntologyDocumentAlreadyExistsException
- if the document IRI of the input source is already the document IRI for a loaded ontology.OWLOntologyAlreadyExistsException
- if the manager already contains an ontology whose ontology IRI and version IRI is the same as the ontology IRI and version IRI of the ontology contained in the document represented by the input source.
-
removeOntology
Attempts to remove an ontology. The ontology which is identified by the specified IRI is removed regardless of whether it is referenced by other ontologies via imports statements.- Parameters:
ontology
- The ontology to be removed. If this manager does not manage the ontology then nothing happens.
-
removeOntology
Attempts to remove an ontology. The ontology which is identified by the specified IRI is removed regardless of whether it is referenced by other ontologies via imports statements.- Parameters:
ontologyID
- The ontology to be removed. If this manager does not manage the ontology then nothing happens.
-
getOntologyDocumentIRI
Gets the document IRI for a given ontology. This will either be the document IRI from where the ontology was obtained from during loading, or the document IRI which was specified (via a mapper) when the (empty) ontology was created. Note that this may not correspond to the first document IRI found in the list of mappings from ontology IRI to document IRI. The reason for this is that it might not have been possible to load the ontology from the first document IRI found in the mapping table.- Parameters:
ontology
- The ontology whose document IRI is to be obtained.- Returns:
- The document IRI of the ontology.
- Throws:
UnknownOWLOntologyException
- If the specified ontology is not managed by this manager.
-
setOntologyDocumentIRI
Overrides the current document IRI for a given ontology. This method does not alter the IRI mappers which are installed, but alters the actual document IRI of an ontology that has already been loaded.- Parameters:
ontology
- The ontology that has already been loaded.documentIRI
- The new ontology document IRI- Throws:
UnknownOWLOntologyException
- If the specified ontology is not managed by this manager.
-
getOntologyFormat
Gets the ontology format for the specified ontology.- Parameters:
ontology
- The ontology whose format is to be obtained.- Returns:
- The format of the ontology, or
null
if the ontology has no format (e.g., programmatically created ontology)
-
getNonnullOntologyFormat
Gets the ontology format for the specified ontology, ensuring it is not null (an error is thrown if the ontology has no format). Do not use this method to check if an ontology has a format associated with it; prefergetOntologyFormat(OWLOntology)
.- Parameters:
ontology
- The ontology whose format is to be obtained.- Returns:
- The format of the ontology
-
setOntologyFormat
Sets the format for the specified ontology.- Parameters:
ontology
- The ontology whose format is to be set.ontologyFormat
- The format for the specified ontology.- Throws:
UnknownOWLOntologyException
- If the specified ontology is not managed by this manager.
-
saveOntology
Saves the specified ontology. The ontology will be saved to the location that it was loaded from, or if it was created programmatically, it will be saved to the location specified by an ontology IRI mapper at creation time. The ontology will be saved in the same format which it was loaded from, or the default ontology format if the ontology was created programmatically.- Parameters:
ontology
- The ontology to be saved.- Throws:
OWLOntologyStorageException
- An exception will be thrown if there is a problem with saving the ontology, or the ontology can't be saved in the format it was loaded from.UnknownOWLOntologyException
- if this manager does not manage the specified ontology
-
saveOntology
Saves the specified ontology, using the specified document IRI to determine where/how the ontology should be saved.- Parameters:
ontology
- The ontology to be saved.documentIRI
- The document IRI where the ontology should be saved to- Throws:
OWLOntologyStorageException
- If the ontology cannot be savedUnknownOWLOntologyException
- if the specified ontology is not managed by this manager.
-
saveOntology
default void saveOntology(OWLOntology ontology, OutputStream outputStream) throws OWLOntologyStorageException Saves the specified ontology, to the specified output stream- Parameters:
ontology
- The ontology to be saved.outputStream
- The output stream where the ontology will be saved to- Throws:
OWLOntologyStorageException
- If there was a problem saving this ontology to the specified output streamUnknownOWLOntologyException
- if this manager does not manage the specified ontology.
-
saveOntology
default void saveOntology(OWLOntology ontology, OWLDocumentFormat ontologyFormat) throws OWLOntologyStorageException Saves the specified ontology in the specified ontology format to its document URI.- Parameters:
ontology
- The ontology to be saved.ontologyFormat
- The format in which the ontology should be saved.- Throws:
OWLOntologyStorageException
- If the ontology cannot be saved.UnknownOWLOntologyException
- if the specified ontology is not managed by this manager
-
saveOntology
void saveOntology(OWLOntology ontology, OWLDocumentFormat ontologyFormat, IRI documentIRI) throws OWLOntologyStorageException Saves the specified ontology to the specified document IRI in the specified ontology format.- Parameters:
ontology
- The ontology to be savedontologyFormat
- The format in which to save the ontologydocumentIRI
- The document IRI where the ontology should be saved to- Throws:
OWLOntologyStorageException
- If the ontology could not be saved.UnknownOWLOntologyException
- if the specified ontology is not managed by the manager.
-
saveOntology
default void saveOntology(OWLOntology ontology, OWLDocumentFormat ontologyFormat, OutputStream outputStream) throws OWLOntologyStorageException Saves the specified ontology to the specified output stream in the specified ontology format.- Parameters:
ontology
- The ontology to be savedontologyFormat
- The format in which to save the ontologyoutputStream
- The output stream where the ontology will be saved to.- Throws:
OWLOntologyStorageException
- If the ontology could not be saved.UnknownOWLOntologyException
- if the specified ontology is not managed by the manager.
-
saveOntology
default void saveOntology(OWLOntology ontology, OWLOntologyDocumentTarget documentTarget) throws OWLOntologyStorageException Saves the specified ontology to the specifiedOWLOntologyDocumentTarget
.- Parameters:
ontology
- The ontology to be saved.documentTarget
- The output target where the ontology will be saved to.- Throws:
OWLOntologyStorageException
- If the ontology could not be saved.UnknownOWLOntologyException
- if the specified ontology is not managed by this manager.
-
saveOntology
void saveOntology(OWLOntology ontology, OWLDocumentFormat ontologyFormat, OWLOntologyDocumentTarget documentTarget) throws OWLOntologyStorageException Saves the specified ontology to the specified output target in the specified ontology format.- Parameters:
ontology
- The ontology to be saved.ontologyFormat
- The output format in which to save the ontologydocumentTarget
- The output target where the ontology will be saved to- Throws:
OWLOntologyStorageException
- If the ontology could not be saved.UnknownOWLOntologyException
- If the specified ontology is not managed by this manager.
-
addIRIMapper
Deprecated.usegetIRIMappers().add()
insteadAdd an IRI mapper to the manager- Parameters:
mapper
- the mapper to add
-
removeIRIMapper
Deprecated.usegetIRIMappers().remove()
insteadRemove an IRI mapper from the manager- Parameters:
mapper
- the mapper to remove
-
clearIRIMappers
Deprecated.usegetIRIMappers().clear()
insteadClear the manager mappers -
addOntologyStorer
Deprecated.usegetOntologyStorers().add()
insteadAdd a storer to the manager- Parameters:
storer
- the storer to add
-
removeOntologyStorer
Deprecated.usegetOntologyStorers().remove()
insteadRemove a storer from the manager- Parameters:
storer
- the storer to remove
-
clearOntologyStorers
Deprecated.usegetOntologyStorers().clear()
insteadClear the manager storers -
getIRIMappers
PriorityCollection<OWLOntologyIRIMapper> getIRIMappers()- Returns:
- the collection of IRI mappers. This allows for iteration and modification of the list.
-
setIRIMappers
Set the collection of IRI mappers. The mappers are used to obtain ontology document IRIs for ontology IRIs. If their type is annotated with a HasPriority type, this will be used to decide the order they are used. Otherwise, the order in which the collection is iterated will determine the order in which the mappers are used.- Parameters:
mappers
- the mappers to be injected
-
getOntologyParsers
PriorityCollection<OWLParserFactory> getOntologyParsers()- Returns:
- the collection of parsers. This allows for iteration and modification of the list.
-
setOntologyParsers
Set the collection of parsers. If the parsers are annotated with a HasPriority type, this will be used to decide the order they are used. Otherwise, the order in which the collection is iterated will determine the order in which the parsers are used.- Parameters:
parsers
- the factories to be injected
-
getOntologyFactories
PriorityCollection<OWLOntologyFactory> getOntologyFactories()- Returns:
- the collection of ontology factories. This allows for iteration and modification of the list.
-
setOntologyFactories
Set the collection of ontology factories. If the factories are annotated with a HasPriority type, this will be used to decide the order they are used. Otherwise, the order in which the collection is iterated will determine the order in which the parsers are used.- Parameters:
factories
- the factories to be injected
-
getOntologyStorers
PriorityCollection<OWLStorerFactory> getOntologyStorers()- Returns:
- the collection of storers. This allows for iteration and modification of the list.
-
setOntologyStorers
Set the list of ontology storers. If their type is annotated with a HasPriority type, this will be used to decide the order they are used. Otherwise, the order in which the collection is iterated will determine the order in which the storers are used.- Parameters:
storers
- The storers to be used
-
addOntologyChangeListener
void addOntologyChangeListener(OWLOntologyChangeListener listener, OWLOntologyChangeBroadcastStrategy strategy) Adds an ontology change listener, which listens to ontology changes. An ontology change broadcast strategy must be specified, which determines the changes that are broadcast to the listener.- Parameters:
listener
- The listener to be added.strategy
- The strategy that should be used for broadcasting changes to the listener.
-
addImpendingOntologyChangeListener
- Parameters:
listener
- the listener to add
-
removeImpendingOntologyChangeListener
- Parameters:
listener
- the listener to remove
-
addOntologyChangesVetoedListener
- Parameters:
listener
- the listener to add
-
removeOntologyChangesVetoedListener
- Parameters:
listener
- the listener to remove
-
setDefaultChangeBroadcastStrategy
Sets the default strategy that is used to broadcast ontology changes.- Parameters:
strategy
- The strategy to be used for broadcasting changes. This strategy will override any previously set broadcast strategy.- See Also:
-
makeLoadImportRequest
Requests that the manager loads an imported ontology that is described by an imports statement. This method is generally used by parsers and other kinds of loaders. For simply loading an ontology, use the loadOntologyXXX methods. The method respects the list of ignored imports in the specified configuration. In other words, if this methods is called for an ignored import as specified by the configuration object then the import won't be loaded. The ontology loader configuration used is the default one for this manager.- Parameters:
declaration
- The declaration that describes the import to be loaded.- Throws:
UnloadableImportException
- if there was a problem creating and loading the import and silent missing imports handling is not turned on. If silent missing import handling is turned on then this exception will not be thrown.
-
makeLoadImportRequest
void makeLoadImportRequest(OWLImportsDeclaration declaration, OWLOntologyLoaderConfiguration configuration) Requests that the manager loads an imported ontology that is described by an imports statement. This method is generally used by parsers and other kinds of loaders. For simply loading an ontology, use the loadOntologyXXX methods. The method respects the list of ignored imports in the specified configuration. In other words, if this methods is called for an ignored import as specified by the configuration object then the import won't be loaded.- Parameters:
declaration
- The declaration that describes the import to be loaded.configuration
- The configuration object that passes arguments to the mechanism used for loading.- Throws:
UnloadableImportException
- if there was a problem creating and loading the import and silent missing imports handling is not turned on. If silent missing import handling is turned on then this exception will not be thrown.
-
addMissingImportListener
In the case where silent missing imports handling is enabled, a listener can be attached via this method so that there is a mechanism that allows clients to be informed of the reason when an import cannot be loaded.- Parameters:
listener
- The listener to be added.
-
removeMissingImportListener
Removes a previously added missing import listener.- Parameters:
listener
- The listener to be removed.
-
addOntologyLoaderListener
Adds an ontology loaded listener to this manager.- Parameters:
listener
- The listener to be added.
-
removeOntologyLoaderListener
Removes a previously added ontology loaded listener.- Parameters:
listener
- The listener to be removed.
-
addOntologyChangeProgessListener
Adds an ontology change progress listener.- Parameters:
listener
- The listener to be added.
-
removeOntologyChangeProgessListener
Removes a previously added ontology change listener.- Parameters:
listener
- The listener to be removed.
-
getIRIMappers().add()
instead