public class OntModelImpl extends ModelCom implements OntModel
Implementation of a model that can process general ontologies in OWL and similar languages.
PrefixMapping.Factory, PrefixMapping.IllegalPrefixException, PrefixMapping.JenaLockedException
Modifier and Type | Field and Description |
---|---|
static String |
owlSyntaxCheckerClassName
This variable is how the OntModel knows how to construct
a syntax checker.
|
Extended, Standard
Constructor and Description |
---|
OntModelImpl(OntModelSpec spec)
Construct a new ontology model from the given specification.
|
OntModelImpl(OntModelSpec spec,
Model model)
Construct a new ontology model, using the given model as a base.
|
Modifier and Type | Method and Description |
---|---|
void |
addLoadedImport(String uri)
Record that this model has now imported the document with the given
URI, so that it will not be re-imported in the future.
|
void |
addSubModel(Model model)
Add the given model as one of the sub-models of the enclosed ontology union model.
|
void |
addSubModel(Model model,
boolean rebind)
Add the given model as one of the sub-models of the enclosed ontology union model.
|
int |
countSubModels()
Answer the number of sub-models of this model, not including the
base model.
|
AllDifferent |
createAllDifferent()
Answer a new, anonymous node representing the fact that a given set of classes are all
pair-wise distinct.
|
AllDifferent |
createAllDifferent(RDFList differentMembers)
Answer a new, anonymous node representing the fact that a given set of classes are all
pair-wise distinct.
|
AllValuesFromRestriction |
createAllValuesFromRestriction(String uri,
Property prop,
Resource cls)
Answer a class description defined as the class of those individuals for which all values
of the given property belong to the given class
|
AnnotationProperty |
createAnnotationProperty(String uri)
Answer a resource that represents an annotation property in this model.
|
CardinalityQRestriction |
createCardinalityQRestriction(String uri,
Property prop,
int cardinality,
OntClass cls)
Answer a class description defined as the class of those individuals that have exactly
the given number of values for the given property, all values of which belong to the given
class.
|
CardinalityRestriction |
createCardinalityRestriction(String uri,
Property prop,
int cardinality)
Answer a class description defined as the class of those individuals that have exactly
the given number of values for the given property.
|
OntClass |
createClass()
Answer a resource that represents an anonymous class description in this model.
|
OntClass |
createClass(String uri)
Answer a resource that represents a class description node in this model.
|
ComplementClass |
createComplementClass(String uri,
Resource cls)
Answer a resource representing the class that is the complement of the given argument class
|
DataRange |
createDataRange(RDFList literals)
Answer a data range defined as the given set of concrete data values.
|
DatatypeProperty |
createDatatypeProperty(String uri)
Answer a resource that represents datatype property in this model, and that is
not a functional property.
|
DatatypeProperty |
createDatatypeProperty(String uri,
boolean functional)
Answer a resource that represents datatype property in this model.
|
EnumeratedClass |
createEnumeratedClass(String uri,
RDFList members)
Answer a resource representing the class that is the enumeration of the given list of individuals
|
HasValueRestriction |
createHasValueRestriction(String uri,
Property prop,
RDFNode value)
Answer a class description defined as the class of those individuals that have the given
resource as the value of the given property
|
Individual |
createIndividual(Resource cls)
Answer a resource that represents an Indvidual node in this model.
|
Individual |
createIndividual(String uri,
Resource cls)
Answer a resource that represents an Individual node in this model.
|
IntersectionClass |
createIntersectionClass(String uri,
RDFList members)
Answer a resource representing the class that is the intersection of the given list of class descriptions.
|
InverseFunctionalProperty |
createInverseFunctionalProperty(String uri)
Answer a resource representing an inverse functional property
|
InverseFunctionalProperty |
createInverseFunctionalProperty(String uri,
boolean functional)
Answer a resource representing an inverse functional property, which is optionally
also functional.
|
RDFList |
createList()
Answer a new empty list.
|
MaxCardinalityQRestriction |
createMaxCardinalityQRestriction(String uri,
Property prop,
int cardinality,
OntClass cls)
Answer a class description defined as the class of those individuals that have at most
the given number of values for the given property, all values of which belong to the given
class.
|
MaxCardinalityRestriction |
createMaxCardinalityRestriction(String uri,
Property prop,
int cardinality)
Answer a class description defined as the class of those individuals that have at most
the given number of values for the given property.
|
MinCardinalityQRestriction |
createMinCardinalityQRestriction(String uri,
Property prop,
int cardinality,
OntClass cls)
Answer a class description defined as the class of those individuals that have at least
the given number of values for the given property, all values of which belong to the given
class.
|
MinCardinalityRestriction |
createMinCardinalityRestriction(String uri,
Property prop,
int cardinality)
Answer a class description defined as the class of those individuals that have at least
the given number of values for the given property.
|
ObjectProperty |
createObjectProperty(String uri)
Answer a resource representing an object property in this model,
and that is not a functional property.
|
ObjectProperty |
createObjectProperty(String uri,
boolean functional)
Answer a resource that represents an object property in this model.
|
Ontology |
createOntology(String uri)
Answer a resource that represents an ontology description node in this model.
|
OntProperty |
createOntProperty(String uri)
Answer a resource representing an generic property in this model.
|
<T extends OntResource> |
createOntResource(Class<T> javaClass,
Resource rdfType,
String uri)
Answer a resource that represents a generic ontology node in this model.
|
OntResource |
createOntResource(String uri)
Answer a resource presenting the
OntResource facet, which has the
given URI. |
Restriction |
createRestriction(Property p)
Answer a resource that represents an anonymous property restriction in this model.
|
Restriction |
createRestriction(String uri,
Property p)
Answer a resource that represents a property restriction in this model.
|
SomeValuesFromRestriction |
createSomeValuesFromRestriction(String uri,
Property prop,
Resource cls)
Answer a class description defined as the class of those individuals that have at least
one property with a value belonging to the given class
|
SymmetricProperty |
createSymmetricProperty(String uri)
Answer a resource representing a symmetric property
|
SymmetricProperty |
createSymmetricProperty(String uri,
boolean functional)
Answer a resource representing a symmetric property, which is optionally
also functional.
|
TransitiveProperty |
createTransitiveProperty(String uri)
Answer a resource representing a transitive property
|
TransitiveProperty |
createTransitiveProperty(String uri,
boolean functional)
Answer a resource representing a transitive property, which is optionally
also functional.
|
UnionClass |
createUnionClass(String uri,
RDFList members)
Answer a resource representing the class that is the union of the given list of class desctiptions
|
AllValuesFromRestriction |
getAllValuesFromRestriction(String uri)
Answer a class description defined as the class of those individuals for which all values
of the given property belong to the given class.
|
AnnotationProperty |
getAnnotationProperty(String uri)
Answer a resource that represents an annotation property in this model.
|
Graph |
getBaseGraph()
Answer the base-graph of this model.
|
Model |
getBaseModel()
Answer the base model of this model.
|
CardinalityQRestriction |
getCardinalityQRestriction(String uri)
Answer a class description defined as the class of those individuals that have a property
p, with cardinality N, all values of which are members of a given class.
|
CardinalityRestriction |
getCardinalityRestriction(String uri)
Answer a class description defined as the class of those individuals that have exactly
the given number of values for the given property.
|
ComplementClass |
getComplementClass(String uri)
Answer a resource representing the class that is the complement of another class.
|
DatatypeProperty |
getDatatypeProperty(String uri)
Answer a resource that represents datatype property in this model.
|
Model |
getDeductionsModel()
Returns a derivations model.
|
Iterator<Derivation> |
getDerivation(Statement statement)
Return the derivation of the given statement (which should be the result of
some previous list operation).
|
OntDocumentManager |
getDocumentManager()
Answer a reference to the document manager that this model is using to manage
ontology <-> mappings, and to load the imports closure.
|
boolean |
getDynamicImports()
Answer true if the imports closure of the model will be dynamically
updated as imports statements are added and removed.
|
EnumeratedClass |
getEnumeratedClass(String uri)
Answer a resource representing the class that is the enumeration of a list of individuals.
|
HasValueRestriction |
getHasValueRestriction(String uri)
Answer a class description defined as the class of those individuals that have the given
resource as the value of the given property.
|
OntModel |
getImportedModel(String uri)
Answer an
OntModel representing the imported ontology
with the given URI. |
ModelMaker |
getImportModelMaker()
Answer the model maker associated with this model (used for constructing the
constituent models of the imports closure).
|
Individual |
getIndividual(String uri)
Answer a resource that represents an Individual node in this model.
|
IntersectionClass |
getIntersectionClass(String uri)
Answer a resource representing the class that is the intersection of a list of class descriptions.
|
InverseFunctionalProperty |
getInverseFunctionalProperty(String uri)
Answer a resource representing an inverse functional property.
|
MaxCardinalityQRestriction |
getMaxCardinalityQRestriction(String uri)
Answer a class description defined as the class of those individuals that have a property
p, with max cardinality N, all values of which are members of a given class.
|
MaxCardinalityRestriction |
getMaxCardinalityRestriction(String uri)
Answer a class description defined as the class of those individuals that have at most
the given number of values for the given property.
|
MinCardinalityQRestriction |
getMinCardinalityQRestriction(String uri)
Answer a class description defined as the class of those individuals that have a property
p, with min cardinality N, all values of which are members of a given class.
|
MinCardinalityRestriction |
getMinCardinalityRestriction(String uri)
Answer a class description defined as the class of those individuals that have at least
the given number of values for the given property.
|
ModelMaker |
getModelMaker()
Deprecated.
use getImportModelMaker instead.
|
ObjectProperty |
getObjectProperty(String uri)
Answer a resource representing an object property in this model.
|
OntClass |
getOntClass(String uri)
Answer a resource that represents a class description node in this model.
|
Ontology |
getOntology(String uri)
Answer a resource that represents an ontology description node in this model.
|
OntProperty |
getOntProperty(String uri)
Answer a resource representing an generic property in this model.
|
OntResource |
getOntResource(Resource res)
Answer a resource presenting the
OntResource facet, which
corresponds to the given resource but attached to this model. |
OntResource |
getOntResource(String uri)
Answer a resource presenting the
OntResource facet, which has the given
URI. |
Profile |
getProfile()
Answer the language profile (for example, OWL or DAML+OIL) that this model is
working to.
|
QualifiedRestriction |
getQualifiedRestriction(String uri)
Answer a class description defined as the class of those individuals that have a property
p, all values of which are members of a given class.
|
Model |
getRawModel()
Return the raw RDF model being processed (i.e.
|
Reasoner |
getReasoner()
Return the Reasoner which is being used to answer queries to this graph.
|
Restriction |
getRestriction(String uri)
Answer a resource that represents a property restriction in this model.
|
SomeValuesFromRestriction |
getSomeValuesFromRestriction(String uri)
Answer a class description defined as the class of those individuals that have at least
one property with a value belonging to the given class.
|
OntModelSpec |
getSpecification()
Answer the ontology model specification that was used to construct this model
|
List<Graph> |
getSubGraphs()
Answer the sub-graphs of this model.
|
SymmetricProperty |
getSymmetricProperty(String uri)
Answer a resource representing a symmetric property.
|
TransitiveProperty |
getTransitiveProperty(String uri)
Answer a resource representing a transitive property.
|
UnionClass |
getUnionClass(String uri)
Answer a resource representing the class that is the union of a list of class desctiptions.
|
boolean |
hasLoadedImport(String uri)
Answer true if this model has had the given URI document imported into it.
|
boolean |
isInBaseModel(RDFNode node)
Answer true if the given node is a member of the base model of this ontology model.
|
boolean |
isInBaseModel(Statement stmt)
Answer true if the given statement is defined in the base model of this ontology model.
|
ExtendedIterator<AllDifferent> |
listAllDifferent()
Answer an iterator that ranges over the nodes that denote pair-wise disjointness between
sets of classes.
|
ExtendedIterator<OntProperty> |
listAllOntProperties()
Answer an iterator over all of the ontology properties in this model, including
object properties, datatype properties, annotation properties, etc.
|
ExtendedIterator<AnnotationProperty> |
listAnnotationProperties()
Answer an iterator that ranges over the properties in this model that are declared
to be annotation properties.
|
ExtendedIterator<OntClass> |
listClasses()
Answer an iterator that ranges over all of the various forms of class description resource
in this model.
|
ExtendedIterator<ComplementClass> |
listComplementClasses()
Answer an iterator that ranges over the complement class-descriptions
in this model, i.e. the class resources specified to have a property
complementOf (or equivalent) and a list of values. |
ExtendedIterator<DataRange> |
listDataRanges()
Answer an iterator over the DataRange objects in this ontology, if there
are any.
|
ExtendedIterator<DatatypeProperty> |
listDatatypeProperties()
Answer an iterator that ranges over the datatype property resources in this model, i.e.
the resources with
rdf:type DatatypeProperty or equivalent. |
ExtendedIterator<EnumeratedClass> |
listEnumeratedClasses()
Answer an iterator that ranges over the enumerated class class-descriptions
in this model, i.e. the class resources specified to have a property
oneOf (or equivalent) and a list of values. |
ExtendedIterator<FunctionalProperty> |
listFunctionalProperties()
Answer an iterator that ranges over the functional property resources in this model, i.e.
the resources with
rdf:type FunctionalProperty or equivalent. |
ExtendedIterator<OntClass> |
listHierarchyRootClasses()
Answer an iterator over the classes in this ontology model that represent
the uppermost nodes of the class hierarchy.
|
ExtendedIterator<OntModel> |
listImportedModels()
Deprecated.
This method has been re-named to
listSubModels ,
but note that to obtain the same behaviour as listImportedModels
from Jena 2.4 and earlier, callers should invoke listSubModels(boolean)
with parameter true . |
Set<String> |
listImportedOntologyURIs()
Answer a list of the imported URI's in this ontology model.
|
Set<String> |
listImportedOntologyURIs(boolean closure)
Answer a list of the imported URI's in this ontology model, and optionally in the closure
of this model's imports.
|
ExtendedIterator<Individual> |
listIndividuals()
Answer an iterator over the individuals in this model.
|
ExtendedIterator<Individual> |
listIndividuals(Resource cls)
Answer an iterator that ranges over the resources in this model that are
instances of the given class.
|
ExtendedIterator<IntersectionClass> |
listIntersectionClasses()
Answer an iterator that ranges over the intersection class-descriptions
in this model, i.e. the class resources specified to have a property
intersectionOf (or equivalent) and a list of values. |
ExtendedIterator<InverseFunctionalProperty> |
listInverseFunctionalProperties()
Answer an iterator that ranges over the inverse functional property resources in this model, i.e.
the resources with
rdf:type InverseFunctionalProperty or equivalent. |
ExtendedIterator<OntClass> |
listNamedClasses()
Answer an iterator that ranges over the named class-descriptions
in this model, i.e. resources with
rdf:type
Class (or equivalent) and a node URI. |
ExtendedIterator<ObjectProperty> |
listObjectProperties()
Answer an iterator that ranges over the object property resources in this model, i.e.
the resources with
rdf:type ObjectProperty or equivalent. |
ExtendedIterator<Ontology> |
listOntologies()
Answer an iterator that ranges over the ontology resources in this model, i.e.
the resources with
rdf:type Ontology or equivalent. |
ExtendedIterator<OntProperty> |
listOntProperties()
Answer an iterator that ranges over the property resources in this model, i.e.
the resources with
rdf:type Property or equivalent. |
ExtendedIterator<Restriction> |
listRestrictions()
Answer an iterator that ranges over the property restriction class-descriptions
in this model, i.e. resources with
rdf:type
Restriction (or equivalent). |
StmtIterator |
listStatements(Resource subject,
Property predicate,
RDFNode object,
Model posit)
Find all the statements matching a pattern.
|
ExtendedIterator<OntModel> |
listSubModels()
Answer an iterator over the ontology models that are sub-models of
this model.
|
ExtendedIterator<OntModel> |
listSubModels(boolean withImports)
Answer an iterator over the ontology models that are sub-models of
this model.
|
ExtendedIterator<SymmetricProperty> |
listSymmetricProperties()
Answer an iterator that ranges over the symmetric property resources in this model, i.e.
the resources with
rdf:type SymmetricProperty or equivalent. |
ExtendedIterator<TransitiveProperty> |
listTransitiveProperties()
Answer an iterator that ranges over the transitive property resources in this model, i.e.
the resources with
rdf:type TransitiveProperty or equivalent. |
ExtendedIterator<UnionClass> |
listUnionClasses()
Answer an iterator that ranges over the union class-descriptions
in this model, i.e. the class resources specified to have a property
unionOf (or equivalent) and a list of values. |
void |
loadImports()
Determine which models this model imports (by looking for, for example,
owl:imports statements, and load each of those models as an
import. |
void |
prepare()
Perform any initial processing and caching.
|
Model |
read(InputStream reader,
String base)
Read statements into the model from the given source, and then load
imported ontologies (according to the document manager policy).
|
Model |
read(InputStream reader,
String base,
String syntax)
Read statements into the model from the given source, and then load
imported ontologies (according to the document manager policy).
|
Model |
read(Reader reader,
String base)
Read statements into the model from the given source, and then load
imported ontologies (according to the document manager policy).
|
Model |
read(Reader reader,
String base,
String syntax)
Read statements into the model from the given source, and then load
imported ontologies (according to the document manager policy).
|
Model |
read(String uri)
Read statements into the model from the given source, and then load
imported ontologies (according to the document manager policy).
|
Model |
read(String uri,
String syntax)
Read statements into the model from the given source, and then load
imported ontologies (according to the document manager policy).
|
Model |
read(String uri,
String base,
String syntax)
Read statements into the model from the given source, and then load
imported ontologies (according to the document manager policy).
|
void |
rebind()
Cause the inference model to reconsult the underlying data to take
into account changes.
|
void |
removeLoadedImport(String uri)
Record that this model no longer imports the document with the given
URI.
|
void |
removeSubModel(Model model)
Remove the given model as one of the sub-models of the enclosed ontology union model.
|
void |
removeSubModel(Model model,
boolean rebind)
Remove the given model as one of the sub-models of the enclosed ontology union model.
|
void |
reset()
Reset any internal caches.
|
void |
setDerivationLogging(boolean logOn)
Switch on/off drivation logging.
|
void |
setDynamicImports(boolean dynamic)
Set the flag that controls whether adding or removing imports
statements into the
model will result in the imports closure changing dynamically.
|
void |
setStrictMode(boolean strict)
Set the checking mode to strict or non-strict.
|
boolean |
strictMode()
Answer true if this model is currently in strict checking mode.
|
ValidityReport |
validate()
Test the consistency of the underlying data.
|
Model |
write(OutputStream out)
Write a serialization of this model as an XML document.
|
Model |
write(OutputStream out,
String lang)
Write a serialized representation of this model in a specified language.
|
Model |
write(OutputStream out,
String lang,
String base)
Write a serialized representation of a model in a specified language.
|
Model |
write(Writer writer)
Write the model as an XML document.
|
Model |
write(Writer writer,
String lang)
Write a serialized representation of a model in a specified language.
|
Model |
write(Writer writer,
String lang,
String base)
Write a serialized representation of a model in a specified language.
|
Model |
writeAll(OutputStream out,
String lang)
Write a serialized representation of all of the contents of the model,
including inferred statements and statements imported from other
documents.
|
Model |
writeAll(OutputStream out,
String lang,
String base)
Write a serialized representation of all of the contents of the model,
including inferred statements and statements imported from other
documents.
|
Model |
writeAll(Writer writer,
String lang)
Write a serialized representation of all of the contents of the model,
including inferred statements and statements imported from other
documents.
|
Model |
writeAll(Writer writer,
String lang,
String base)
Write a serialized representation of all of the contents of the model,
including inferred statements and statements imported from other
documents.
|
abort, adapt, add, add, add, add, add, add, add, add, add, add, add, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addNamespaces, asModel, asNode, asRDFNode, asStatement, asStatements, asStatements, asStatements, begin, calculateInTxn, clearNsPrefixMap, close, commit, contains, contains, contains, contains, contains, containsAll, containsAll, containsAny, containsAny, containsLiteral, containsLiteral, containsLiteral, containsLiteral, containsLiteral, containsLiteral, containsLiteral, containsResource, createAlt, createAlt, createBag, createBag, createList, createList, createLiteral, createLiteral, createLiteral, createLiteral, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createProperty, createProperty, createReifiedStatement, createReifiedStatement, createResource, createResource, createResource, createResource, createResource, createResource, createResource, createSeq, createSeq, createStatement, createStatement, createStatement, createStatement, createStatement, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, difference, enterCriticalSection, executeInTransaction, executeInTxn, expandPrefix, findTriplesFrom, getAlt, getAlt, getAnyReifiedStatement, getBag, getBag, getDefaultModelPrefixes, getGraph, getList, getList, getLock, getModelLock, getNsPrefixMap, getNsPrefixURI, getNsURIPrefix, getProperty, getProperty, getProperty, getProperty, getRDFNode, getReader, getReader, getRequiredProperty, getRequiredProperty, getResource, getResource, getSeq, getSeq, getWriter, getWriter, hasNoMappings, independent, intersect, intersection, isClosed, isEmpty, isIsomorphicWith, isReified, leaveCriticalSection, listBySubject, listLiteralStatements, listLiteralStatements, listLiteralStatements, listLiteralStatements, listLiteralStatements, listLiteralStatements, listNameSpaces, listObjects, listObjectsOfProperty, listObjectsOfProperty, listReifiedStatements, listReifiedStatements, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listStatements, listStatements, listStatements, listStatements, listStatements, listSubjects, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, lock, notifyEvent, numPrefixes, qnameFor, query, register, reifiedToString, remove, remove, remove, remove, remove, remove, removeAll, removeAll, removeAllReifications, removeNsPrefix, removeReader, removeReification, removeWriter, resetRDFReaderF, resetRDFWriterF, samePrefixMappingAs, setDefaultModelPrefixes, setNsPrefix, setNsPrefixes, setNsPrefixes, setReaderClassName, setWriterClassName, shortForm, size, supportsSetOperations, supportsTransactions, toString, union, unregister, withDefaultMappings, wrapAsResource
asGraph, equals, getNodeAs, hashCode, isIsomorphicWith, setNodeCache
abort, add, add, add, add, add, begin, calculateInTxn, clearNsPrefixMap, close, commit, contains, contains, contains, containsAll, containsAll, containsAny, containsAny, containsResource, createList, createList, createLiteral, createLiteral, createProperty, createReifiedStatement, createReifiedStatement, createResource, createResource, createResource, createStatement, createTypedLiteral, createTypedLiteral, createTypedLiteral, difference, equals, executeInTransaction, executeInTxn, getAnyReifiedStatement, getLock, getProperty, getProperty, getProperty, getRequiredProperty, getRequiredProperty, getResource, independent, intersection, isClosed, isEmpty, isIsomorphicWith, isReified, listNameSpaces, listObjects, listObjectsOfProperty, listObjectsOfProperty, listReifiedStatements, listReifiedStatements, listResourcesWithProperty, listResourcesWithProperty, listStatements, listStatements, listStatements, listSubjects, listSubjectsWithProperty, listSubjectsWithProperty, notifyEvent, query, register, remove, remove, remove, removeAll, removeAll, removeAllReifications, removeNsPrefix, removeReification, setNsPrefix, setNsPrefixes, setNsPrefixes, size, supportsSetOperations, supportsTransactions, union, unregister, withDefaultMappings
add, add, add, add, add, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, contains, contains, containsLiteral, containsLiteral, containsLiteral, containsLiteral, containsLiteral, containsLiteral, containsLiteral, createAlt, createAlt, createBag, createBag, createLiteral, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createProperty, createResource, createResource, createResource, createResource, createSeq, createSeq, createStatement, createStatement, createStatement, createStatement, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, getAlt, getAlt, getBag, getBag, getList, getList, getProperty, getRDFNode, getResource, getSeq, getSeq, listLiteralStatements, listLiteralStatements, listLiteralStatements, listLiteralStatements, listLiteralStatements, listLiteralStatements, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listStatements, listStatements, listSubjectsWithProperty, listSubjectsWithProperty, remove, remove, remove
asRDFNode, asStatement, getGraph, wrapAsResource
getReader, getReader, removeReader, resetRDFReaderF, setReaderClassName
getWriter, getWriter, removeWriter, resetRDFWriterF, setWriterClassName
expandPrefix, getNsPrefixMap, getNsPrefixURI, getNsURIPrefix, hasNoMappings, lock, numPrefixes, qnameFor, samePrefixMappingAs, shortForm
enterCriticalSection, leaveCriticalSection
public static String owlSyntaxCheckerClassName
public OntModelImpl(OntModelSpec spec, Model model)
Construct a new ontology model, using the given model as a base. The document manager given in the specification object will be used to build the imports closure of the model if its policy permits.
model
- The base model that may contain existing statements for the ontology.
if it is null, a fresh model is created as the base.spec
- A specification object that allows us to specify parameters and structure for the
ontology model to be constructed.public OntModelImpl(OntModelSpec spec)
public OntDocumentManager getDocumentManager()
Answer a reference to the document manager that this model is using to manage ontology <-> mappings, and to load the imports closure. Note the default ontology model specifications each have a contained default document manager. Changing the document managers specified by these default specification may (in fact, probably will) affect other models built with the same specification policy. This may or may not be as desired by the programmer!
getDocumentManager
in interface OntModel
public ExtendedIterator<Ontology> listOntologies()
Answer an iterator that ranges over the ontology resources in this model, i.e.
the resources with rdf:type Ontology
or equivalent. These resources
typically contain metadata about the ontology document that contains them.
Specifically, the resources in this iterator will those whose type corresponds
to the value given in the ontology vocabulary associated with this model, see
Profile.ONTOLOGY()
.
Note: the number of nodes returned by this iterator will vary according to the completeness of the deductive extension of the underlying graph. See class overview for more details.
listOntologies
in interface OntModel
public ExtendedIterator<OntProperty> listOntProperties()
Answer an iterator that ranges over the property resources in this model, i.e.
the resources with rdf:type Property
or equivalent. An OntProperty
is equivalent to an rdfs:Property
in a normal RDF graph; this type is
provided as a common super-type for the more specific ObjectProperty
and
DatatypeProperty
property types.
Note This method searches for nodes in the underlying model whose
rdf:type
is rdf:Property
. This type is entailed by
specific property sub-types, such as owl:ObjectProperty
. An important
consequence of this is that in models without an attached reasoner (e.g. in the
OWL_MEM
OntModelSpec
), the entailed type will not be present
and this method will omit such properties from the returned iterator.
Solution There are two
ways to address to this issue: either use a reasoning engine to ensure that type entailments
are taking place correctly, or call listAllOntProperties()
. Note
that listAllOntProperties
is potentially less efficient than this method.
The resources returned by this iterator will those whose type corresponds to the value given in the ontology vocabulary associated with this model.
listOntProperties
in interface OntModel
public ExtendedIterator<OntProperty> listAllOntProperties()
Answer an iterator over all of the ontology properties in this model, including
object properties, datatype properties, annotation properties, etc. This method
takes a different approach to calculating the set of property resources to return,
and is robust against the absence of a reasoner attached to the model (see note
in listOntProperties()
for explanation). However, the calculation used by
this method is potentially less efficient than the alternative listOntProperties()
.
Users whose models have an attached reasoner are recommended to use
listOntProperties()
.
listAllOntProperties
in interface OntModel
rdf:type
entailments.
Each property will appear exactly once in the iterator.public ExtendedIterator<ObjectProperty> listObjectProperties()
Answer an iterator that ranges over the object property resources in this model, i.e.
the resources with rdf:type ObjectProperty
or equivalent. An object
property is a property that is defined in the ontology language semantics as a
one whose range comprises individuals (rather than datatyped literals).
Specifically, the resources in this iterator will those whose type corresponds
to the value given in the ontology vocabulary associated with this model: see
Profile.OBJECT_PROPERTY()
.
Note: the number of nodes returned by this iterator will vary according to the completeness of the deductive extension of the underlying graph. See class overview for more details.
listObjectProperties
in interface OntModel
public ExtendedIterator<DatatypeProperty> listDatatypeProperties()
Answer an iterator that ranges over the datatype property resources in this model, i.e.
the resources with rdf:type DatatypeProperty
or equivalent. An datatype
property is a property that is defined in the ontology language semantics as a
one whose range comprises datatyped literals (rather than individuals).
Specifically, the resources in this iterator will those whose type corresponds
to the value given in the ontology vocabulary associated with this model: see
Profile.DATATYPE_PROPERTY()
.
Note: the number of nodes returned by this iterator will vary according to the completeness of the deductive extension of the underlying graph. See class overview for more details.
listDatatypeProperties
in interface OntModel
public ExtendedIterator<FunctionalProperty> listFunctionalProperties()
Answer an iterator that ranges over the functional property resources in this model, i.e.
the resources with rdf:type FunctionalProperty
or equivalent. A functional
property is a property that is defined in the ontology language semantics as having
a unique domain element for each instance of the relationship.
Specifically, the resources in this iterator will those whose type corresponds
to the value given in the ontology vocabulary associated with this model: see
Profile.FUNCTIONAL_PROPERTY()
.
listFunctionalProperties
in interface OntModel
public ExtendedIterator<TransitiveProperty> listTransitiveProperties()
Answer an iterator that ranges over the transitive property resources in this model, i.e.
the resources with rdf:type TransitiveProperty
or equivalent.
Specifically, the resources in this iterator will those whose type corresponds
to the value given in the ontology vocabulary associated with this model: see
Profile.TRANSITIVE_PROPERTY()
.
listTransitiveProperties
in interface OntModel
public ExtendedIterator<SymmetricProperty> listSymmetricProperties()
Answer an iterator that ranges over the symmetric property resources in this model, i.e.
the resources with rdf:type SymmetricProperty
or equivalent.
Specifically, the resources in this iterator will those whose type corresponds
to the value given in the ontology vocabulary associated with this model: see
Profile.SYMMETRIC_PROPERTY()
.
listSymmetricProperties
in interface OntModel
public ExtendedIterator<InverseFunctionalProperty> listInverseFunctionalProperties()
Answer an iterator that ranges over the inverse functional property resources in this model, i.e.
the resources with rdf:type InverseFunctionalProperty
or equivalent.
Specifically, the resources in this iterator will those whose type corresponds
to the value given in the ontology vocabulary associated with this model: see
Profile.INVERSE_FUNCTIONAL_PROPERTY()
.
listInverseFunctionalProperties
in interface OntModel
public ExtendedIterator<Individual> listIndividuals()
Answer an iterator over the individuals in this model. Where possible, an individual
is defined as an instance of the top class in an ontology, i.e. owl:Thing
or daml:Thing
. However, since this test relies on the presence of an inference
capability, and is not defined in cases where there is no top class (such as RDFS),
a secondary heuristic is used when needed: an individual is an instance of a class defined
in the ontology (i.e. it is a resource with an rdf:type
, where the
rdf:type
of that resource is a class or restriction in the ontology.
listIndividuals
in interface OntModel
public ExtendedIterator<Individual> listIndividuals(Resource cls)
Answer an iterator that ranges over the resources in this model that are instances of the given class.
listIndividuals
in interface OntModel
rdf:type
is cls
.public ExtendedIterator<OntClass> listClasses()
Answer an iterator that ranges over all of the various forms of class description resource
in this model. Class descriptions include enumerated
classes, union
classes, complement
classes, intersection
classes, named
classes and property restrictions
.
Note: the number of nodes returned by this iterator will vary according to the completeness of the deductive extension of the underlying graph. See class overview for more details.
listClasses
in interface OntModel
public ExtendedIterator<OntClass> listHierarchyRootClasses()
Answer an iterator over the classes in this ontology model that represent
the uppermost nodes of the class hierarchy. Depending on the underlying
reasoner configuration, if any, these will be calculated as the classes
that have Top (i.e. owl:Thing
or daml:Thing
)
as a direct super-class, or the classes which have no declared super-class.
listHierarchyRootClasses
in interface OntModel
public ExtendedIterator<EnumeratedClass> listEnumeratedClasses()
Answer an iterator that ranges over the enumerated class class-descriptions
in this model, i.e. the class resources specified to have a property
oneOf
(or equivalent) and a list of values.
Note: the number of nodes returned by this iterator will vary according to the completeness of the deductive extension of the underlying graph. See class overview for more details.
listEnumeratedClasses
in interface OntModel
Profile.ONE_OF()
public ExtendedIterator<UnionClass> listUnionClasses()
Answer an iterator that ranges over the union class-descriptions
in this model, i.e. the class resources specified to have a property
unionOf
(or equivalent) and a list of values.
Note: the number of nodes returned by this iterator will vary according to the completeness of the deductive extension of the underlying graph. See class overview for more details.
listUnionClasses
in interface OntModel
Profile.UNION_OF()
public ExtendedIterator<ComplementClass> listComplementClasses()
Answer an iterator that ranges over the complement class-descriptions
in this model, i.e. the class resources specified to have a property
complementOf
(or equivalent) and a list of values.
Note: the number of nodes returned by this iterator will vary according to the completeness of the deductive extension of the underlying graph. See class overview for more details.
listComplementClasses
in interface OntModel
Profile.COMPLEMENT_OF()
public ExtendedIterator<IntersectionClass> listIntersectionClasses()
Answer an iterator that ranges over the intersection class-descriptions
in this model, i.e. the class resources specified to have a property
intersectionOf
(or equivalent) and a list of values.
Note: the number of nodes returned by this iterator will vary according to the completeness of the deductive extension of the underlying graph. See class overview for more details.
listIntersectionClasses
in interface OntModel
Profile.INTERSECTION_OF()
public ExtendedIterator<OntClass> listNamedClasses()
Answer an iterator that ranges over the named class-descriptions
in this model, i.e. resources with rdf:type
Class
(or equivalent) and a node URI.
Note: the number of nodes returned by this iterator will vary according to the completeness of the deductive extension of the underlying graph. See class overview for more details.
listNamedClasses
in interface OntModel
public ExtendedIterator<Restriction> listRestrictions()
Answer an iterator that ranges over the property restriction class-descriptions
in this model, i.e. resources with rdf:type
Restriction
(or equivalent).
Note: the number of nodes returned by this iterator will vary according to the completeness of the deductive extension of the underlying graph. See class overview for more details.
listRestrictions
in interface OntModel
Profile.RESTRICTION()
public ExtendedIterator<AllDifferent> listAllDifferent()
Answer an iterator that ranges over the nodes that denote pair-wise disjointness between sets of classes.
Note: the number of nodes returned by this iterator will vary according to the completeness of the deductive extension of the underlying graph. See class overview for more details.
listAllDifferent
in interface OntModel
public ExtendedIterator<DataRange> listDataRanges()
Answer an iterator over the DataRange objects in this ontology, if there are any.
listDataRanges
in interface OntModel
DataRange
objects.public ExtendedIterator<AnnotationProperty> listAnnotationProperties()
Answer an iterator that ranges over the properties in this model that are declared to be annotation properties. Not all supported languages define annotation properties (the category of annotation properties is chiefly an OWL innovation).
Note: the number of nodes returned by this iterator will vary according to the completeness of the deductive extension of the underlying graph. See class overview for more details.
listAnnotationProperties
in interface OntModel
Profile.getAnnotationProperties()
public Ontology getOntology(String uri)
Answer a resource that represents an ontology description node in this model. If a resource with the given uri exists in the model, and can be viewed as an Ontology, return the Ontology facet, otherwise return null.
getOntology
in interface OntModel
uri
- The uri for the ontology node. Conventionally, this corresponds to the base URI
of the document itself.public Individual getIndividual(String uri)
Answer a resource that represents an Individual node in this model. If a resource with the given uri exists in the model, and can be viewed as an Individual, return the Individual facet, otherwise return null.
getIndividual
in interface OntModel
uri
- The URI for the requried individualpublic OntProperty getOntProperty(String uri)
Answer a resource representing an generic property in this model. If a property with the given uri exists in the model, return the OntProperty facet, otherwise return null.
getOntProperty
in interface OntModel
uri
- The uri for the property.public ObjectProperty getObjectProperty(String uri)
Answer a resource representing an object property in this model. If a resource with the given uri exists in the model, and can be viewed as an ObjectProperty, return the ObjectProperty facet, otherwise return null.
getObjectProperty
in interface OntModel
uri
- The uri for the object property. May not be null.public TransitiveProperty getTransitiveProperty(String uri)
Answer a resource representing a transitive property. If a resource with the given uri exists in the model, and can be viewed as a TransitiveProperty, return the TransitiveProperty facet, otherwise return null.
getTransitiveProperty
in interface OntModel
uri
- The uri for the property. May not be null.public SymmetricProperty getSymmetricProperty(String uri)
Answer a resource representing a symmetric property. If a resource with the given uri exists in the model, and can be viewed as a SymmetricProperty, return the SymmetricProperty facet, otherwise return null.
getSymmetricProperty
in interface OntModel
uri
- The uri for the property. May not be null.public InverseFunctionalProperty getInverseFunctionalProperty(String uri)
Answer a resource representing an inverse functional property. If a resource with the given uri exists in the model, and can be viewed as a InverseFunctionalProperty, return the InverseFunctionalProperty facet, otherwise return null.
getInverseFunctionalProperty
in interface OntModel
uri
- The uri for the property. May not be null.public DatatypeProperty getDatatypeProperty(String uri)
Answer a resource that represents datatype property in this model. . If a resource with the given uri exists in the model, and can be viewed as a DatatypeProperty, return the DatatypeProperty facet, otherwise return null.
getDatatypeProperty
in interface OntModel
uri
- The uri for the datatype property. May not be null.public AnnotationProperty getAnnotationProperty(String uri)
Answer a resource that represents an annotation property in this model. If a resource with the given uri exists in the model, and can be viewed as an AnnotationProperty, return the AnnotationProperty facet, otherwise return null.
getAnnotationProperty
in interface OntModel
uri
- The uri for the annotation property. May not be null.public OntClass getOntClass(String uri)
Answer a resource that represents a class description node in this model. If a resource with the given uri exists in the model, and can be viewed as an OntClass, return the OntClass facet, otherwise return null.
getOntClass
in interface OntModel
uri
- The uri for the class node, or null for an anonymous class.public ComplementClass getComplementClass(String uri)
Answer a resource representing the class that is the complement of another class. If a resource with the given uri exists in the model, and can be viewed as a ComplementClass, return the ComplementClass facet, otherwise return null.
getComplementClass
in interface OntModel
uri
- The URI of the new complement class.public EnumeratedClass getEnumeratedClass(String uri)
Answer a resource representing the class that is the enumeration of a list of individuals. If a resource with the given uri exists in the model, and can be viewed as an EnumeratedClass, return the EnumeratedClass facet, otherwise return null.
getEnumeratedClass
in interface OntModel
uri
- The URI of the new enumeration class.public UnionClass getUnionClass(String uri)
Answer a resource representing the class that is the union of a list of class desctiptions. If a resource with the given uri exists in the model, and can be viewed as a UnionClass, return the UnionClass facet, otherwise return null.
getUnionClass
in interface OntModel
uri
- The URI of the new union class.public IntersectionClass getIntersectionClass(String uri)
Answer a resource representing the class that is the intersection of a list of class descriptions. If a resource with the given uri exists in the model, and can be viewed as a IntersectionClass, return the IntersectionClass facet, otherwise return null.
getIntersectionClass
in interface OntModel
uri
- The URI of the new intersection class.public Restriction getRestriction(String uri)
Answer a resource that represents a property restriction in this model. If a resource with the given uri exists in the model, and can be viewed as a Restriction, return the Restriction facet, otherwise return null.
getRestriction
in interface OntModel
uri
- The uri for the restriction node.public HasValueRestriction getHasValueRestriction(String uri)
Answer a class description defined as the class of those individuals that have the given resource as the value of the given property. If a resource with the given uri exists in the model, and can be viewed as a HasValueRestriction, return the HasValueRestriction facet, otherwise return null.
getHasValueRestriction
in interface OntModel
uri
- The URI for the restrictionpublic SomeValuesFromRestriction getSomeValuesFromRestriction(String uri)
Answer a class description defined as the class of those individuals that have at least one property with a value belonging to the given class. If a resource with the given uri exists in the model, and can be viewed as a SomeValuesFromRestriction, return the SomeValuesFromRestriction facet, otherwise return null.
getSomeValuesFromRestriction
in interface OntModel
uri
- The URI for the restrictionpublic AllValuesFromRestriction getAllValuesFromRestriction(String uri)
Answer a class description defined as the class of those individuals for which all values of the given property belong to the given class. If a resource with the given uri exists in the model, and can be viewed as an AllValuesFromResriction, return the AllValuesFromRestriction facet, otherwise return null.
getAllValuesFromRestriction
in interface OntModel
uri
- The URI for the restrictionpublic CardinalityRestriction getCardinalityRestriction(String uri)
Answer a class description defined as the class of those individuals that have exactly the given number of values for the given property. If a resource with the given uri exists in the model, and can be viewed as a CardinalityRestriction, return the CardinalityRestriction facet, otherwise return null.
getCardinalityRestriction
in interface OntModel
uri
- The URI for the restrictionpublic MinCardinalityRestriction getMinCardinalityRestriction(String uri)
Answer a class description defined as the class of those individuals that have at least the given number of values for the given property. If a resource with the given uri exists in the model, and can be viewed as a MinCardinalityRestriction, return the MinCardinalityRestriction facet, otherwise return null.
getMinCardinalityRestriction
in interface OntModel
uri
- The URI for the restrictionpublic MaxCardinalityRestriction getMaxCardinalityRestriction(String uri)
Answer a class description defined as the class of those individuals that have at most the given number of values for the given property. If a resource with the given uri exists in the model, and can be viewed as a MaxCardinalityRestriction, return the MaxCardinalityRestriction facet, otherwise return null.
getMaxCardinalityRestriction
in interface OntModel
uri
- The URI for the restrictionpublic QualifiedRestriction getQualifiedRestriction(String uri)
Answer a class description defined as the class of those individuals that have a property p, all values of which are members of a given class. Typically used with a cardinality constraint. If a resource with the given uri exists in the model, and can be viewed as a QualifiedRestriction, return the QualifiedRestriction facet, otherwise return null.
getQualifiedRestriction
in interface OntModel
uri
- The URI for the restrictionpublic CardinalityQRestriction getCardinalityQRestriction(String uri)
Answer a class description defined as the class of those individuals that have a property p, with cardinality N, all values of which are members of a given class. If a resource with the given uri exists in the model, and can be viewed as a CardinalityQRestriction, return the CardinalityQRestriction facet, otherwise return null.
getCardinalityQRestriction
in interface OntModel
uri
- The URI for the restrictionpublic MinCardinalityQRestriction getMinCardinalityQRestriction(String uri)
Answer a class description defined as the class of those individuals that have a property p, with min cardinality N, all values of which are members of a given class. If a resource with the given uri exists in the model, and can be viewed as a MinCardinalityQRestriction, return the MinCardinalityQRestriction facet, otherwise return null.
getMinCardinalityQRestriction
in interface OntModel
uri
- The URI for the restrictionpublic MaxCardinalityQRestriction getMaxCardinalityQRestriction(String uri)
Answer a class description defined as the class of those individuals that have a property p, with max cardinality N, all values of which are members of a given class. If a resource with the given uri exists in the model, and can be viewed as a MaxCardinalityQRestriction, return the MaxCardinalityQRestriction facet, otherwise return null.
getMaxCardinalityQRestriction
in interface OntModel
uri
- The URI for the restrictionpublic Ontology createOntology(String uri)
Answer a resource that represents an ontology description node in this model. If a resource with the given uri exists in the model, it will be re-used. If not, a new one is created in the updateable sub-graph of the ontology model.
createOntology
in interface OntModel
uri
- The uri for the ontology node. Conventionally, this corresponds to the base URI
of the document itself.public Individual createIndividual(Resource cls)
Answer a resource that represents an Indvidual node in this model. A new anonymous resource will be created in the updateable sub-graph of the ontology model.
createIndividual
in interface OntModel
cls
- Resource representing the ontology class to which the individual belongspublic Individual createIndividual(String uri, Resource cls)
Answer a resource that represents an Individual node in this model. If a resource with the given uri exists in the model, it will be re-used. If not, a new one is created in the updateable sub-graph of the ontology model.
createIndividual
in interface OntModel
cls
- Resource representing the ontology class to which the individual belongsuri
- The uri for the individual, or null for an anonymous individual.public OntProperty createOntProperty(String uri)
Answer a resource representing an generic property in this model. Effectively
this method is an alias for ModelCom.createProperty( String )
, except that
the return type is OntProperty
, which allow more convenient access to
a property's position in the property hierarchy, domain, range, etc.
createOntProperty
in interface OntModel
uri
- The uri for the property. May not be null.public ObjectProperty createObjectProperty(String uri)
Answer a resource representing an object property in this model, and that is not a functional property.
createObjectProperty
in interface OntModel
uri
- The uri for the object property. May not be null.createObjectProperty( String, boolean )
public ObjectProperty createObjectProperty(String uri, boolean functional)
Answer a resource that represents an object property in this model. An object property is defined to have a range of individuals, rather than datatypes. If a resource with the given uri exists in the model, it will be re-used. If not, a new one is created in the updateable sub-graph of the ontology model.
createObjectProperty
in interface OntModel
uri
- The uri for the object property. May not be null.functional
- If true, the resource will also be typed as a FunctionalProperty
,
that is, a property that has a unique range value for any given domain value.public TransitiveProperty createTransitiveProperty(String uri)
Answer a resource representing a transitive property
createTransitiveProperty
in interface OntModel
uri
- The uri for the property. May not be null.createTransitiveProperty( String, boolean )
public TransitiveProperty createTransitiveProperty(String uri, boolean functional)
Answer a resource representing a transitive property, which is optionally also functional. Note: although it is permitted in OWL full to have functional transitive properties, it makes the language undecideable. Functional transitive properties are not permitted in OWL Lite or OWL DL.
createTransitiveProperty
in interface OntModel
uri
- The uri for the property. May not be null.functional
- If true, the property is also functionalpublic SymmetricProperty createSymmetricProperty(String uri)
Answer a resource representing a symmetric property
createSymmetricProperty
in interface OntModel
uri
- The uri for the property. May not be null.createSymmetricProperty( String, boolean )
public SymmetricProperty createSymmetricProperty(String uri, boolean functional)
Answer a resource representing a symmetric property, which is optionally also functional.
createSymmetricProperty
in interface OntModel
uri
- The uri for the property. May not be null.functional
- If true, the property is also functionalpublic InverseFunctionalProperty createInverseFunctionalProperty(String uri)
Answer a resource representing an inverse functional property
createInverseFunctionalProperty
in interface OntModel
uri
- The uri for the property. May not be null.createInverseFunctionalProperty( String, boolean )
public InverseFunctionalProperty createInverseFunctionalProperty(String uri, boolean functional)
Answer a resource representing an inverse functional property, which is optionally also functional.
createInverseFunctionalProperty
in interface OntModel
uri
- The uri for the property. May not be null.functional
- If true, the property is also functionalpublic DatatypeProperty createDatatypeProperty(String uri)
Answer a resource that represents datatype property in this model, and that is not a functional property.
createDatatypeProperty
in interface OntModel
uri
- The uri for the datatype property. May not be null.createDatatypeProperty( String, boolean )
public DatatypeProperty createDatatypeProperty(String uri, boolean functional)
Answer a resource that represents datatype property in this model. A datatype property is defined to have a range that is a concrete datatype, rather than an individual. If a resource with the given uri exists in the model, it will be re-used. If not, a new one is created in the updateable sub-graph of the ontology model.
createDatatypeProperty
in interface OntModel
uri
- The uri for the datatype property. May not be null.functional
- If true, the resource will also be typed as a FunctionalProperty
,
that is, a property that has a unique range value for any given domain value.public AnnotationProperty createAnnotationProperty(String uri)
Answer a resource that represents an annotation property in this model. If a resource with the given uri exists in the model, it will be re-used. If not, a new one is created in the updateable sub-graph of the ontology model.
createAnnotationProperty
in interface OntModel
uri
- The uri for the annotation property.public OntClass createClass()
Answer a resource that represents an anonymous class description in this model. A new
anonymous resource of rdf:type C
, where C is the class type from the
language profile.
createClass
in interface OntModel
public OntClass createClass(String uri)
Answer a resource that represents a class description node in this model. If a resource with the given uri exists in the model, it will be re-used. If not, a new one is created in the updateable sub-graph of the ontology model.
createClass
in interface OntModel
uri
- The uri for the class node, or null for an anonymous class.public ComplementClass createComplementClass(String uri, Resource cls)
Answer a resource representing the class that is the complement of the given argument class
createComplementClass
in interface OntModel
uri
- The URI of the new complement class, or null for an anonymous class description.cls
- Resource denoting the class that the new class is a complement ofpublic EnumeratedClass createEnumeratedClass(String uri, RDFList members)
Answer a resource representing the class that is the enumeration of the given list of individuals
createEnumeratedClass
in interface OntModel
uri
- The URI of the new enumeration class, or null for an anonymous class description.members
- An optional list of resources denoting the individuals in the enumerationpublic UnionClass createUnionClass(String uri, RDFList members)
Answer a resource representing the class that is the union of the given list of class desctiptions
createUnionClass
in interface OntModel
uri
- The URI of the new union class, or null for an anonymous class description.members
- A list of resources denoting the classes that comprise the unionpublic IntersectionClass createIntersectionClass(String uri, RDFList members)
Answer a resource representing the class that is the intersection of the given list of class descriptions.
createIntersectionClass
in interface OntModel
uri
- The URI of the new intersection class, or null for an anonymous class description.members
- A list of resources denoting the classes that comprise the intersectionpublic Restriction createRestriction(Property p)
Answer a resource that represents an anonymous property restriction in this model. A new
anonymous resource of rdf:type R
, where R is the restriction type from the
language profile.
createRestriction
in interface OntModel
p
- The property that is restricted by this restrictionpublic Restriction createRestriction(String uri, Property p)
Answer a resource that represents a property restriction in this model. If a resource with the given uri exists in the model, it will be re-used. If not, a new one is created in the updateable sub-graph of the ontology model.
createRestriction
in interface OntModel
uri
- The uri for the restriction node, or null for an anonymous restriction.p
- The property that is restricted by this restrictionpublic HasValueRestriction createHasValueRestriction(String uri, Property prop, RDFNode value)
Answer a class description defined as the class of those individuals that have the given resource as the value of the given property
createHasValueRestriction
in interface OntModel
uri
- The optional URI for the restriction, or null for an anonymous restriction (which
should be the normal case)prop
- The property the restriction applies tovalue
- The value of the property, as a resource or RDF literalpublic SomeValuesFromRestriction createSomeValuesFromRestriction(String uri, Property prop, Resource cls)
Answer a class description defined as the class of those individuals that have at least one property with a value belonging to the given class
createSomeValuesFromRestriction
in interface OntModel
uri
- The optional URI for the restriction, or null for an anonymous restriction (which
should be the normal case)prop
- The property the restriction applies tocls
- The class to which at least one value of the property belongspublic AllValuesFromRestriction createAllValuesFromRestriction(String uri, Property prop, Resource cls)
Answer a class description defined as the class of those individuals for which all values of the given property belong to the given class
createAllValuesFromRestriction
in interface OntModel
uri
- The optional URI for the restriction, or null for an anonymous restriction (which
should be the normal case)prop
- The property the restriction applies tocls
- The class to which any value of the property belongspublic CardinalityRestriction createCardinalityRestriction(String uri, Property prop, int cardinality)
Answer a class description defined as the class of those individuals that have exactly the given number of values for the given property.
createCardinalityRestriction
in interface OntModel
uri
- The optional URI for the restriction, or null for an anonymous restriction (which
should be the normal case)prop
- The property the restriction applies tocardinality
- The exact cardinality of the propertypublic MinCardinalityRestriction createMinCardinalityRestriction(String uri, Property prop, int cardinality)
Answer a class description defined as the class of those individuals that have at least the given number of values for the given property.
createMinCardinalityRestriction
in interface OntModel
uri
- The optional URI for the restriction, or null for an anonymous restriction (which
should be the normal case)prop
- The property the restriction applies tocardinality
- The minimum cardinality of the propertypublic MaxCardinalityRestriction createMaxCardinalityRestriction(String uri, Property prop, int cardinality)
Answer a class description defined as the class of those individuals that have at most the given number of values for the given property.
createMaxCardinalityRestriction
in interface OntModel
uri
- The optional URI for the restriction, or null for an anonymous restriction (which
should be the normal case)prop
- The property the restriction applies tocardinality
- The maximum cardinality of the propertypublic MaxCardinalityQRestriction createMaxCardinalityQRestriction(String uri, Property prop, int cardinality, OntClass cls)
Answer a class description defined as the class of those individuals that have at most the given number of values for the given property, all values of which belong to the given class.
createMaxCardinalityQRestriction
in interface OntModel
uri
- The optional URI for the restriction, or null for an anonymous restriction (which
should be the normal case)prop
- The property the restriction applies tocardinality
- The maximum cardinality of the propertycls
- The class to which all values of the restricted property should belongpublic MinCardinalityQRestriction createMinCardinalityQRestriction(String uri, Property prop, int cardinality, OntClass cls)
Answer a class description defined as the class of those individuals that have at least the given number of values for the given property, all values of which belong to the given class.
createMinCardinalityQRestriction
in interface OntModel
uri
- The optional URI for the restriction, or null for an anonymous restriction (which
should be the normal case)prop
- The property the restriction applies tocardinality
- The minimun cardinality of the propertycls
- The class to which all values of the restricted property should belongpublic CardinalityQRestriction createCardinalityQRestriction(String uri, Property prop, int cardinality, OntClass cls)
Answer a class description defined as the class of those individuals that have exactly the given number of values for the given property, all values of which belong to the given class.
createCardinalityQRestriction
in interface OntModel
uri
- The optional URI for the restriction, or null for an anonymous restriction (which
should be the normal case)prop
- The property the restriction applies tocardinality
- The cardinality of the propertycls
- The class to which all values of the restricted property should belongpublic DataRange createDataRange(RDFList literals)
Answer a data range defined as the given set of concrete data values. DataRange resources are necessarily bNodes.
createDataRange
in interface OntModel
literals
- An iterator over a set of literals that will be the members of the data range,
or null to define an empty data rangepublic AllDifferent createAllDifferent()
Answer a new, anonymous node representing the fact that a given set of classes are all
pair-wise distinct. AllDifferent
is a feature of OWL only, and is something
of an anomaly in that it exists only to give a place to anchor the distinctMembers
property, which is the actual expression of the fact.
createAllDifferent
in interface OntModel
public AllDifferent createAllDifferent(RDFList differentMembers)
Answer a new, anonymous node representing the fact that a given set of classes are all
pair-wise distinct. AllDifferent
is a feature of OWL only, and is something
of an anomaly in that it exists only to give a place to anchor the distinctMembers
property, which is the actual expression of the fact.
createAllDifferent
in interface OntModel
differentMembers
- A list of the class expressions that denote a set of mutually disjoint classespublic <T extends OntResource> T createOntResource(Class<T> javaClass, Resource rdfType, String uri)
Answer a resource that represents a generic ontology node in this model. If a resource with the given uri exists in the model, it will be re-used. If not, a new one is created in the updateable sub-graph of the ontology model.
This is a generic method for creating any known ontology value. The selector that determines
which resource to create is the same as as the argument to the as()
method: the Java class object of the desired abstraction. For example, to create an
ontology class via this mechanism, use:
OntClass c = (OntClass) myModel.createOntResource( OntClass.class, null,
"http://example.org/ex#Parrot" );
createOntResource
in interface OntModel
javaClass
- The Java class object that represents the ontology abstraction to createrdfType
- Optional resource denoting the ontology class to which an individual or
axiom belongs, if that is the type of resource being created.uri
- The uri for the ontology resource, or null for an anonymous resource.javaClass
public OntResource createOntResource(String uri)
Answer a resource presenting the OntResource
facet, which has the
given URI.
createOntResource
in interface OntModel
uri
- The URI of the resource, or null for an anonymous resource (aka bNode)public RDFList createList()
Answer a new empty list. This method overrides the list create method in ModelCom, to allow both DAML and RDFS lists to be created.
createList
in interface Model
createList
in class ModelCom
public Profile getProfile()
Answer the language profile (for example, OWL or DAML+OIL) that this model is working to.
getProfile
in interface OntModel
public void loadImports()
Determine which models this model imports (by looking for, for example,
owl:imports
statements, and load each of those models as an
import. A check is made to determine if a model has already been imported,
if so, the import is ignored. Thus this method is safe against circular
sets of import statements. Note that actual implementation is delegated to
the associated OntDocumentManager
.
loadImports
in interface OntModel
public boolean hasLoadedImport(String uri)
Answer true if this model has had the given URI document imported into it. This is important to know since an import only occurs once, and we also want to be able to detect cycles of imports.
hasLoadedImport
in interface OntModel
uri
- An ontology URIpublic void addLoadedImport(String uri)
Record that this model has now imported the document with the given URI, so that it will not be re-imported in the future.
addLoadedImport
in interface OntModel
uri
- A document URI that has now been imported into the model.public void removeLoadedImport(String uri)
Record that this model no longer imports the document with the given URI.
removeLoadedImport
in interface OntModel
uri
- A document URI that is no longer imported into the model.public Set<String> listImportedOntologyURIs()
Answer a list of the imported URI's in this ontology model. Detection of imports
statments will be according to the local language profile
listImportedOntologyURIs
in interface OntModel
public Set<String> listImportedOntologyURIs(boolean closure)
Answer a list of the imported URI's in this ontology model, and optionally in the closure
of this model's imports. Detection of imports
statments will be according to the local language profile. Note that, in order to allow this
method to be called during the imports closure process, we only query the base model,
thus side-stepping the any attached reasoner.
listImportedOntologyURIs
in interface OntModel
closure
- If true, the set of uri's returned will include not only those directly
imported by this model, but those imported by the model's imports transitively.public ModelMaker getImportModelMaker()
Answer the model maker associated with this model (used for constructing the constituent models of the imports closure).
getImportModelMaker
in interface OntModel
@Deprecated public ModelMaker getModelMaker()
OntModel
Answer the model maker associated with this model (used for constructing the constituent models of the imports closure).
getModelMaker
in interface OntModel
public Model read(String uri)
Read statements into the model from the given source, and then load imported ontologies (according to the document manager policy).
public Model read(Reader reader, String base)
Read statements into the model from the given source, and then load imported ontologies (according to the document manager policy).
public Model read(InputStream reader, String base)
Read statements into the model from the given source, and then load imported ontologies (according to the document manager policy).
public Model read(String uri, String syntax)
Read statements into the model from the given source, and then load imported ontologies (according to the document manager policy).
public Model read(String uri, String base, String syntax)
Read statements into the model from the given source, and then load imported ontologies (according to the document manager policy).
public Model read(Reader reader, String base, String syntax)
Read statements into the model from the given source, and then load imported ontologies (according to the document manager policy).
public Model read(InputStream reader, String base, String syntax)
Read statements into the model from the given source, and then load imported ontologies (according to the document manager policy).
public List<Graph> getSubGraphs()
Answer the sub-graphs of this model. A sub-graph is defined as a graph that is used to contain the triples from an imported document.
getSubGraphs
in interface OntModel
@Deprecated public ExtendedIterator<OntModel> listImportedModels()
listSubModels
,
but note that to obtain the same behaviour as listImportedModels
from Jena 2.4 and earlier, callers should invoke listSubModels(boolean)
with parameter true
.Answer an iterator over the ontologies that this ontology imports,
each of which will have been wrapped as an ontology model using the same
OntModelSpec
as this model. If this model has no imports,
the iterator will be non-null but will not have any values.
listImportedModels
in interface OntModel
OntModel
representing an imported ontology.listSubModels()
,
listSubModels(boolean)
public ExtendedIterator<OntModel> listSubModels(boolean withImports)
Answer an iterator over the ontology models that are sub-models of
this model. Sub-models are used, for example, to represent composite
documents such as the imports of a model. So if ontology A imports
ontologies B and C, each of B and C will be available as one of
the sub-models of the model containing A. This method replaces the
older listImportedModels()
. Note that to fully replicate
the behaviour of listImportedModels
, the
withImports
flag must be set to true. Each model
returned by this method will have been wrapped as an ontology model using the same
OntModelSpec
as this model. If this model has no sub-models,
the returned iterator will be non-null but will not have any values.
listSubModels
in interface OntModel
withImports
- If true, each sub-model returned by this method
will also include its import models. So if model A imports D, and D
imports D, when called with withImports
set to true, the
return value for modelA.listSubModels(true)
will be an
iterator, whose only value is a model for D, and that model will contain
a sub-model representing the import of E. If withImports
is false, E will not be included as a sub-model of D.OntModel
representing a sub-model of this ontology.public ExtendedIterator<OntModel> listSubModels()
Answer an iterator over the ontology models that are sub-models of
this model. Sub-models are used, for example, to represent composite
documents such as the imports of a model. So if ontology A imports
ontologies B and C, each of B and C will be available as one of
the sub-models of the model containing A.
Important note on behaviour change: please see
the comment on listSubModels(boolean)
for explanation
of the withImports
flag. This zero-argument form
of listSubModels
sets withImports
to
false, so the returned models will not themselves contain imports.
This behaviour differs from the zero-argument method
listImportedModels()
in Jena 2.4 an earlier.
listSubModels
in interface OntModel
OntModel
representing a sub-model of this ontology.listSubModels(boolean)
public int countSubModels()
Answer the number of sub-models of this model, not including the base model.
countSubModels
in interface OntModel
public OntModel getImportedModel(String uri)
Answer an OntModel
representing the imported ontology
with the given URI. If an ontology with that URI has not been imported,
answer null.
getImportedModel
in interface OntModel
uri
- The URI of an ontology that may have been imported into the
ontology represented by this modelpublic Graph getBaseGraph()
Answer the base-graph of this model. The base-graph is the graph that contains the triples read from the source document for this ontology.
public Model getBaseModel()
Answer the base model of this model. The base model is the model wrapping
the graph that contains the triples read from the source document for this
ontology. It is therefore the model that will be updated if statements are
added to a model that is built from a union of documents (via the
imports
statements in the source document).
getBaseModel
in interface OntModel
public void addSubModel(Model model)
Add the given model as one of the sub-models of the enclosed ontology union model.
Note that if model
is a composite model (i.e. an
OntModel
or InfModel
), the model and all of its submodels will
be added to the union of sub-models of this model. If this is not required,
callers should explicitly add only the base model:
parent.addSubModel( child.getBaseModel() );
addSubModel
in interface OntModel
model
- A sub-model to addOntModel.addSubModel( Model, boolean )
public void addSubModel(Model model, boolean rebind)
Add the given model as one of the sub-models of the enclosed ontology union model.
Note that if model
is a composite model (i.e. an
OntModel
or InfModel
), the model and all of its submodels will
be added to the union of sub-models of this model. If this is not required,
callers should explicitly add only the base model:
parent.addSubModel( child.getBaseModel(), true );
addSubModel
in interface OntModel
model
- A sub-model to addrebind
- If true, rebind any associated inferencing engine to the new data (which
may be an expensive operation)public void removeSubModel(Model model)
Remove the given model as one of the sub-models of the enclosed ontology union model. Will cause the associated infererence engine (if any) to update, so this may be an expensive operation in some cases.
removeSubModel
in interface OntModel
model
- A sub-model to removeaddSubModel( Model, boolean )
public void removeSubModel(Model model, boolean rebind)
Remove the given model as one of the sub-models of the enclosed ontology union model.
removeSubModel
in interface OntModel
model
- A sub-model to removerebind
- If true, rebind any associated inferencing engine to the new data (which
may be an expensive operation)public boolean isInBaseModel(RDFNode node)
Answer true if the given node is a member of the base model of this ontology model. This is an important distiction, because only the base model receives updates when the ontology model is updated. Thus, removing properties of a resource that is not in the base model will not actually side-effect the overall model.
isInBaseModel
in interface OntModel
node
- An RDF node (Resource, Property or Literal) to testpublic boolean isInBaseModel(Statement stmt)
Answer true if the given statement is defined in the base model of this ontology model. This is an important distiction, because only the base model receives updates when the ontology model is updated. Thus, removing a statement that is not in the base model will not actually side-effect the overall model.
isInBaseModel
in interface OntModel
stmt
- A statement to testpublic boolean strictMode()
Answer true if this model is currently in strict checking mode. Strict mode means that converting a common resource to a particular language element, such as an ontology class, will be subject to some simple syntactic-level checks for appropriateness.
strictMode
in interface OntModel
public void setStrictMode(boolean strict)
Set the checking mode to strict or non-strict.
setStrictMode
in interface OntModel
strict
- strictMode()
public void setDynamicImports(boolean dynamic)
Set the flag that controls whether adding or removing imports statements into the model will result in the imports closure changing dynamically.
setDynamicImports
in interface OntModel
dynamic
- If true, adding or removing an imports statement to the
model will result in a change in the imports closure. If false, changes
to the imports are not monitored dynamically. Default false.public boolean getDynamicImports()
Answer true if the imports closure of the model will be dynamically updated as imports statements are added and removed.
getDynamicImports
in interface OntModel
public OntModelSpec getSpecification()
Answer the ontology model specification that was used to construct this model
getSpecification
in interface OntModel
public Model write(Writer writer)
Model
Write the model as an XML document. It is often better to use an OutputStream rather than a Writer, since this will avoid character encoding errors.
public Model write(Writer writer, String lang)
Model
Write a serialized representation of a model in a specified language. It is often better to use an OutputStream rather than a Writer, since this will avoid character encoding errors.
The language in which to write the model is specified by the
lang
argument. Predefined values are "RDF/XML",
"RDF/XML-ABBREV", "N-TRIPLE", "TURTLE", (and "TTL") and "N3". The default value,
represented by null
is "RDF/XML".
public Model write(Writer writer, String lang, String base)
Model
Write a serialized representation of a model in a specified language. It is often better to use an OutputStream rather than a Writer, since this will avoid character encoding errors.
The language in which to write the model is specified by the
lang
argument. Predefined values are "RDF/XML",
"RDF/XML-ABBREV", "N-TRIPLE", "TURTLE", (and "TTL") and "N3". The default value,
represented by null
, is "RDF/XML".
write
in interface OntModel
write
in interface Model
write
in class ModelCom
writer
- The output writerlang
- The language in which the RDF should be writtenbase
- The base uri for relative URI calculations.
null
means use only absolute URI's.public Model write(OutputStream out)
Model
Write a serialization of this model as an XML document.
The language in which to write the model is specified by the
lang
argument. Predefined values are "RDF/XML",
"RDF/XML-ABBREV", "N-TRIPLE" and "N3". The default value is
represented by null
is "RDF/XML".
public Model write(OutputStream out, String lang)
Model
Write a serialized representation of this model in a specified language.
The language in which to write the model is specified by the
lang
argument. Predefined values are "RDF/XML",
"RDF/XML-ABBREV", "N-TRIPLE", "TURTLE", (and "TTL") and "N3". The default value,
represented by null
, is "RDF/XML".
public Model write(OutputStream out, String lang, String base)
Model
Write a serialized representation of a model in a specified language.
The language in which to write the model is specified by the
lang
argument. Predefined values are "RDF/XML",
"RDF/XML-ABBREV", "N-TRIPLE", "TURTLE", (and "TTL") and "N3". The default value,
represented by null
, is "RDF/XML".
write
in interface OntModel
write
in interface Model
write
in class ModelCom
out
- The output stream to which the RDF is writtenlang
- The language in which the RDF should be writtenbase
- The base uri to use when writing relative URI's. null
means use only absolute URI's. This is used for relative
URIs that would be resolved against the document retrieval URL.
For some values of lang
, this value may be included in the output.public Model writeAll(Writer writer, String lang, String base)
OntModel
Write a serialized representation of all of the contents of the model,
including inferred statements and statements imported from other
documents. To write only the data asserted in the base model, use
write
.
It is often better to use an OutputStream rather than a Writer,
since this will avoid character encoding errors.
The language in which to write the model is specified by the
lang
argument. Predefined values are "RDF/XML",
"RDF/XML-ABBREV", "N-TRIPLE" and "TURTLE". The default value,
represented by null
, is "RDF/XML".
public Model writeAll(OutputStream out, String lang, String base)
OntModel
Write a serialized representation of all of the contents of the model,
including inferred statements and statements imported from other
documents. To write only the data asserted in the base model, use
write
.
The language in which to write the model is specified by the
lang
argument. Predefined values are "RDF/XML",
"RDF/XML-ABBREV", "N-TRIPLE" and "TURTLE". The default value,
represented by null
, is "RDF/XML".
public Model writeAll(Writer writer, String lang)
OntModel
Write a serialized representation of all of the contents of the model,
including inferred statements and statements imported from other
documents. To write only the data asserted in the base model, use
write
.
It is often better to use an OutputStream rather than a Writer,
since this will avoid character encoding errors.
The language in which to write the model is specified by the
lang
argument. Predefined values are "RDF/XML",
"RDF/XML-ABBREV", "N-TRIPLE" and "TURTLE". The default value,
represented by null
, is "RDF/XML".
public Model writeAll(OutputStream out, String lang)
OntModel
Write a serialized representation of all of the contents of the model,
including inferred statements and statements imported from other
documents. To write only the data asserted in the base model, use
write
.
The language in which to write the model is specified by the
lang
argument. Predefined values are "RDF/XML",
"RDF/XML-ABBREV", "N-TRIPLE" and "TURTLE". The default value,
represented by null
, is "RDF/XML".
public Model getRawModel()
getRawModel
in interface InfModel
public Reasoner getReasoner()
getReasoner
in interface InfModel
public void rebind()
public void prepare()
public void reset()
public Model getDeductionsModel()
Returns a derivations model. The rule reasoners typically create a graph containing those triples added to the base graph due to rule firings. In some applications it can useful to be able to access those deductions directly, without seeing the raw data which triggered them. In particular, this allows the forward rules to be used as if they were rewrite transformation rules.
getDeductionsModel
in interface InfModel
public ValidityReport validate()
public StmtIterator listStatements(Resource subject, Property predicate, RDFNode object, Model posit)
Return an iterator over all the statements in a model
that match a pattern. The statements selected are those
whose subject matches the subject
argument,
whose predicate matches the predicate
argument
and whose object matches the object
argument.
If an argument is null
it matches anything.
The s/p/o terms may refer to resources which are temporarily defined in the "posit" model. This allows one, for example, to query what resources are of type CE where CE is a class expression rather than a named class - put CE in the posit arg.
listStatements
in interface InfModel
subject
- The subject soughtpredicate
- The predicate soughtobject
- The value soughtposit
- Model containing additional assertions to be considered when matching statementspublic void setDerivationLogging(boolean logOn)
setDerivationLogging
in interface InfModel
public Iterator<Derivation> getDerivation(Statement statement)
getDerivation
in interface InfModel
Derviation
public OntResource getOntResource(String uri)
Answer a resource presenting the OntResource
facet, which has the given
URI. If no such resource is currently present in the model, return null.
getOntResource
in interface OntModel
uri
- The URI of a resourcepublic OntResource getOntResource(Resource res)
Answer a resource presenting the OntResource
facet, which
corresponds to the given resource but attached to this model.
getOntResource
in interface OntModel
res
- An existing resourceOntResource
attached to this model that has the same URI
or anonID as the given resourceLicenced under the Apache License, Version 2.0