Class OntModelImpl

All Implemented Interfaces:
OntModel, InfModel, Model, ModelCon, ModelGraphInterface, RDFReaderF, RDFWriterF, Lock, PrefixMapping

public class OntModelImpl extends ModelCom implements OntModel

Implementation of a model that can process general ontologies in OWL and similar languages.

  • Field Details

    • owlSyntaxCheckerClassName

      public static String owlSyntaxCheckerClassName
      This variable is how the OntModel knows how to construct a syntax checker. This part of the design may change.
  • Constructor Details

    • OntModelImpl

      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.

      Parameters:
      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.
    • OntModelImpl

      public OntModelImpl(OntModelSpec spec)
      Construct a new ontology model from the given specification. The base model is produced using the baseModelMaker.
  • Method Details

    • getDocumentManager

      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!

      Specified by:
      getDocumentManager in interface OntModel
      Returns:
      A reference to this model's document manager, obtained from the specification object
    • listOntologies

      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.

      Specified by:
      listOntologies in interface OntModel
      Returns:
      An iterator over ontology resources.
    • listOntProperties

      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.

      Specified by:
      listOntProperties in interface OntModel
      Returns:
      An iterator over property resources.
    • listAllOntProperties

      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().

      Specified by:
      listAllOntProperties in interface OntModel
      Returns:
      An iterator over all available properties in a model, irrespective of whether a reasoner is available to perform rdf:type entailments. Each property will appear exactly once in the iterator.
    • listObjectProperties

      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.

      Specified by:
      listObjectProperties in interface OntModel
      Returns:
      An iterator over object property resources.
    • listDatatypeProperties

      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.

      Specified by:
      listDatatypeProperties in interface OntModel
      Returns:
      An iterator over datatype property resources.
    • listFunctionalProperties

      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().

      Specified by:
      listFunctionalProperties in interface OntModel
      Returns:
      An iterator over functional property resources.
    • listTransitiveProperties

      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().

      Specified by:
      listTransitiveProperties in interface OntModel
      Returns:
      An iterator over transitive property resources.
    • listSymmetricProperties

      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().

      Specified by:
      listSymmetricProperties in interface OntModel
      Returns:
      An iterator over symmetric property resources.
    • listInverseFunctionalProperties

      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().

      Specified by:
      listInverseFunctionalProperties in interface OntModel
      Returns:
      An iterator over inverse functional property resources.
    • listIndividuals

      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.

      Specified by:
      listIndividuals in interface OntModel
      Returns:
      An iterator over Individuals.
    • listIndividuals

      public ExtendedIterator<Individual> listIndividuals(Resource cls)

      Answer an iterator that ranges over the resources in this model that are instances of the given class.

      Specified by:
      listIndividuals in interface OntModel
      Returns:
      An iterator over individual resources whose rdf:type is cls.
    • listClasses

      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.

      Specified by:
      listClasses in interface OntModel
      Returns:
      An iterator over class description resources.
    • listHierarchyRootClasses

      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.

      Specified by:
      listHierarchyRootClasses in interface OntModel
      Returns:
      An iterator of the root classes in the local class hierarchy
    • listEnumeratedClasses

      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.

      Specified by:
      listEnumeratedClasses in interface OntModel
      Returns:
      An iterator over enumerated class resources.
      See Also:
    • listUnionClasses

      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.

      Specified by:
      listUnionClasses in interface OntModel
      Returns:
      An iterator over union class resources.
      See Also:
    • listComplementClasses

      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.

      Specified by:
      listComplementClasses in interface OntModel
      Returns:
      An iterator over complement class resources.
      See Also:
    • listIntersectionClasses

      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.

      Specified by:
      listIntersectionClasses in interface OntModel
      Returns:
      An iterator over complement class resources.
      See Also:
    • listNamedClasses

      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.

      Specified by:
      listNamedClasses in interface OntModel
      Returns:
      An iterator over named class resources.
    • listRestrictions

      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.

      Specified by:
      listRestrictions in interface OntModel
      Returns:
      An iterator over restriction class resources.
      See Also:
    • listAllDifferent

      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.

      Specified by:
      listAllDifferent in interface OntModel
      Returns:
      An iterator over AllDifferent nodes.
    • listDataRanges

      public ExtendedIterator<DataRange> listDataRanges()

      Answer an iterator over the DataRange objects in this ontology, if there are any.

      Specified by:
      listDataRanges in interface OntModel
      Returns:
      An iterator, whose values are DataRange objects.
    • listAnnotationProperties

      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.

      Specified by:
      listAnnotationProperties in interface OntModel
      Returns:
      An iterator over annotation properties.
      See Also:
    • getOntology

      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.

      Specified by:
      getOntology in interface OntModel
      Parameters:
      uri - The uri for the ontology node. Conventionally, this corresponds to the base URI of the document itself.
      Returns:
      An Ontology resource or null.
    • getIndividual

      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.

      Specified by:
      getIndividual in interface OntModel
      Parameters:
      uri - The URI for the requried individual
      Returns:
      An Individual resource or null.
    • getOntProperty

      public 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.

      Specified by:
      getOntProperty in interface OntModel
      Parameters:
      uri - The uri for the property.
      Returns:
      An OntProperty resource or null.
    • getObjectProperty

      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.

      Specified by:
      getObjectProperty in interface OntModel
      Parameters:
      uri - The uri for the object property. May not be null.
      Returns:
      An ObjectProperty resource or null.
    • getTransitiveProperty

      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.

      Specified by:
      getTransitiveProperty in interface OntModel
      Parameters:
      uri - The uri for the property. May not be null.
      Returns:
      A TransitiveProperty resource or null
    • getSymmetricProperty

      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.

      Specified by:
      getSymmetricProperty in interface OntModel
      Parameters:
      uri - The uri for the property. May not be null.
      Returns:
      A SymmetricProperty resource or null
    • getInverseFunctionalProperty

      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.

      Specified by:
      getInverseFunctionalProperty in interface OntModel
      Parameters:
      uri - The uri for the property. May not be null.
      Returns:
      An InverseFunctionalProperty resource or null
    • getDatatypeProperty

      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.

      Specified by:
      getDatatypeProperty in interface OntModel
      Parameters:
      uri - The uri for the datatype property. May not be null.
      Returns:
      A DatatypeProperty resource or null
    • getAnnotationProperty

      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.

      Specified by:
      getAnnotationProperty in interface OntModel
      Parameters:
      uri - The uri for the annotation property. May not be null.
      Returns:
      An AnnotationProperty resource or null
    • getOntClass

      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.

      Specified by:
      getOntClass in interface OntModel
      Parameters:
      uri - The uri for the class node, or null for an anonymous class.
      Returns:
      An OntClass resource or null.
    • getComplementClass

      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.

      Specified by:
      getComplementClass in interface OntModel
      Parameters:
      uri - The URI of the new complement class.
      Returns:
      A complement class or null
    • getEnumeratedClass

      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.

      Specified by:
      getEnumeratedClass in interface OntModel
      Parameters:
      uri - The URI of the new enumeration class.
      Returns:
      An enumeration class or null
    • getUnionClass

      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.

      Specified by:
      getUnionClass in interface OntModel
      Parameters:
      uri - The URI of the new union class.
      Returns:
      A union class description or null
    • getIntersectionClass

      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.

      Specified by:
      getIntersectionClass in interface OntModel
      Parameters:
      uri - The URI of the new intersection class.
      Returns:
      An intersection class description or null
    • getRestriction

      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.

      Specified by:
      getRestriction in interface OntModel
      Parameters:
      uri - The uri for the restriction node.
      Returns:
      A Restriction resource or null
    • getHasValueRestriction

      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.

      Specified by:
      getHasValueRestriction in interface OntModel
      Parameters:
      uri - The URI for the restriction
      Returns:
      A resource representing a has-value restriction or null
    • getSomeValuesFromRestriction

      public 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.

      Specified by:
      getSomeValuesFromRestriction in interface OntModel
      Parameters:
      uri - The URI for the restriction
      Returns:
      A resource representing a some-values-from restriction, or null
    • getAllValuesFromRestriction

      public 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.

      Specified by:
      getAllValuesFromRestriction in interface OntModel
      Parameters:
      uri - The URI for the restriction
      Returns:
      A resource representing an all-values-from restriction or null
    • getCardinalityRestriction

      public 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.

      Specified by:
      getCardinalityRestriction in interface OntModel
      Parameters:
      uri - The URI for the restriction
      Returns:
      A resource representing a has-value restriction, or null
    • getMinCardinalityRestriction

      public 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.

      Specified by:
      getMinCardinalityRestriction in interface OntModel
      Parameters:
      uri - The URI for the restriction
      Returns:
      A resource representing a min-cardinality restriction, or null
    • getMaxCardinalityRestriction

      public 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.

      Specified by:
      getMaxCardinalityRestriction in interface OntModel
      Parameters:
      uri - The URI for the restriction
      Returns:
      A resource representing a mas-cardinality restriction, or null
    • getQualifiedRestriction

      public 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.

      Specified by:
      getQualifiedRestriction in interface OntModel
      Parameters:
      uri - The URI for the restriction
      Returns:
      A resource representing a qualified restriction, or null
    • getCardinalityQRestriction

      public 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.

      Specified by:
      getCardinalityQRestriction in interface OntModel
      Parameters:
      uri - The URI for the restriction
      Returns:
      A resource representing a qualified cardinality restriction, or null
    • getMinCardinalityQRestriction

      public 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.

      Specified by:
      getMinCardinalityQRestriction in interface OntModel
      Parameters:
      uri - The URI for the restriction
      Returns:
      A resource representing a qualified min cardinality restriction, or null
    • getMaxCardinalityQRestriction

      public 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.

      Specified by:
      getMaxCardinalityQRestriction in interface OntModel
      Parameters:
      uri - The URI for the restriction
      Returns:
      A resource representing a qualified max cardinality restriction, or null
    • createOntology

      public 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.

      Specified by:
      createOntology in interface OntModel
      Parameters:
      uri - The uri for the ontology node. Conventionally, this corresponds to the base URI of the document itself.
      Returns:
      An Ontology resource.
    • createIndividual

      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.

      Specified by:
      createIndividual in interface OntModel
      Parameters:
      cls - Resource representing the ontology class to which the individual belongs
      Returns:
      A new anoymous Individual of the given class.
    • createIndividual

      public 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.

      Specified by:
      createIndividual in interface OntModel
      Parameters:
      cls - Resource representing the ontology class to which the individual belongs
      uri - The uri for the individual, or null for an anonymous individual.
      Returns:
      An Individual resource.
    • createOntProperty

      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.

      Specified by:
      createOntProperty in interface OntModel
      Parameters:
      uri - The uri for the property. May not be null.
      Returns:
      An OntProperty resource.
    • createObjectProperty

      public ObjectProperty createObjectProperty(String uri)

      Answer a resource representing an object property in this model, and that is not a functional property.

      Specified by:
      createObjectProperty in interface OntModel
      Parameters:
      uri - The uri for the object property. May not be null.
      Returns:
      An ObjectProperty resource.
      See Also:
    • createObjectProperty

      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.

      Specified by:
      createObjectProperty in interface OntModel
      Parameters:
      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.
      Returns:
      An ObjectProperty resource, optionally also functional.
    • createTransitiveProperty

      public TransitiveProperty createTransitiveProperty(String uri)

      Answer a resource representing a transitive property

      Specified by:
      createTransitiveProperty in interface OntModel
      Parameters:
      uri - The uri for the property. May not be null.
      Returns:
      An TransitiveProperty resource
      See Also:
    • createTransitiveProperty

      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.

      Specified by:
      createTransitiveProperty in interface OntModel
      Parameters:
      uri - The uri for the property. May not be null.
      functional - If true, the property is also functional
      Returns:
      An TransitiveProperty resource, optionally also functional.
    • createSymmetricProperty

      public SymmetricProperty createSymmetricProperty(String uri)

      Answer a resource representing a symmetric property

      Specified by:
      createSymmetricProperty in interface OntModel
      Parameters:
      uri - The uri for the property. May not be null.
      Returns:
      An SymmetricProperty resource
      See Also:
    • createSymmetricProperty

      public SymmetricProperty createSymmetricProperty(String uri, boolean functional)

      Answer a resource representing a symmetric property, which is optionally also functional.

      Specified by:
      createSymmetricProperty in interface OntModel
      Parameters:
      uri - The uri for the property. May not be null.
      functional - If true, the property is also functional
      Returns:
      An SymmetricProperty resource, optionally also functional.
    • createInverseFunctionalProperty

      public InverseFunctionalProperty createInverseFunctionalProperty(String uri)

      Answer a resource representing an inverse functional property

      Specified by:
      createInverseFunctionalProperty in interface OntModel
      Parameters:
      uri - The uri for the property. May not be null.
      Returns:
      An InverseFunctionalProperty resource
      See Also:
    • createInverseFunctionalProperty

      public InverseFunctionalProperty createInverseFunctionalProperty(String uri, boolean functional)

      Answer a resource representing an inverse functional property, which is optionally also functional.

      Specified by:
      createInverseFunctionalProperty in interface OntModel
      Parameters:
      uri - The uri for the property. May not be null.
      functional - If true, the property is also functional
      Returns:
      An InverseFunctionalProperty resource, optionally also functional.
    • createDatatypeProperty

      public DatatypeProperty createDatatypeProperty(String uri)

      Answer a resource that represents datatype property in this model, and that is not a functional property.

      Specified by:
      createDatatypeProperty in interface OntModel
      Parameters:
      uri - The uri for the datatype property. May not be null.
      Returns:
      A DatatypeProperty resource.
      See Also:
    • createDatatypeProperty

      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.

      Specified by:
      createDatatypeProperty in interface OntModel
      Parameters:
      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.
      Returns:
      A DatatypeProperty resource.
    • createAnnotationProperty

      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.

      Specified by:
      createAnnotationProperty in interface OntModel
      Parameters:
      uri - The uri for the annotation property.
      Returns:
      An AnnotationProperty resource.
    • createClass

      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.

      Specified by:
      createClass in interface OntModel
      Returns:
      An anonymous Class resource.
    • createClass

      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.

      Specified by:
      createClass in interface OntModel
      Parameters:
      uri - The uri for the class node, or null for an anonymous class.
      Returns:
      A Class resource.
    • createComplementClass

      public ComplementClass createComplementClass(String uri, Resource cls)

      Answer a resource representing the class that is the complement of the given argument class

      Specified by:
      createComplementClass in interface OntModel
      Parameters:
      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 of
      Returns:
      A complement class
    • createEnumeratedClass

      public EnumeratedClass createEnumeratedClass(String uri, RDFList members)

      Answer a resource representing the class that is the enumeration of the given list of individuals

      Specified by:
      createEnumeratedClass in interface OntModel
      Parameters:
      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 enumeration
      Returns:
      An enumeration class
    • createUnionClass

      public UnionClass createUnionClass(String uri, RDFList members)

      Answer a resource representing the class that is the union of the given list of class desctiptions

      Specified by:
      createUnionClass in interface OntModel
      Parameters:
      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 union
      Returns:
      A union class description
    • createIntersectionClass

      public IntersectionClass createIntersectionClass(String uri, RDFList members)

      Answer a resource representing the class that is the intersection of the given list of class descriptions.

      Specified by:
      createIntersectionClass in interface OntModel
      Parameters:
      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 intersection
      Returns:
      An intersection class description
    • createRestriction

      public 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.

      Specified by:
      createRestriction in interface OntModel
      Parameters:
      p - The property that is restricted by this restriction
      Returns:
      An anonymous Restriction resource.
    • createRestriction

      public 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.

      Specified by:
      createRestriction in interface OntModel
      Parameters:
      uri - The uri for the restriction node, or null for an anonymous restriction.
      p - The property that is restricted by this restriction
      Returns:
      A Restriction resource.
    • createHasValueRestriction

      public 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

      Specified by:
      createHasValueRestriction in interface OntModel
      Parameters:
      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 to
      value - The value of the property, as a resource or RDF literal
      Returns:
      A new resource representing a has-value restriction
    • createSomeValuesFromRestriction

      public 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

      Specified by:
      createSomeValuesFromRestriction in interface OntModel
      Parameters:
      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 to
      cls - The class to which at least one value of the property belongs
      Returns:
      A new resource representing a some-values-from restriction
    • createAllValuesFromRestriction

      public 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

      Specified by:
      createAllValuesFromRestriction in interface OntModel
      Parameters:
      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 to
      cls - The class to which any value of the property belongs
      Returns:
      A new resource representing an all-values-from restriction
    • createCardinalityRestriction

      public 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.

      Specified by:
      createCardinalityRestriction in interface OntModel
      Parameters:
      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 to
      cardinality - The exact cardinality of the property
      Returns:
      A new resource representing a has-value restriction
    • createMinCardinalityRestriction

      public 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.

      Specified by:
      createMinCardinalityRestriction in interface OntModel
      Parameters:
      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 to
      cardinality - The minimum cardinality of the property
      Returns:
      A new resource representing a min-cardinality restriction
    • createMaxCardinalityRestriction

      public 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.

      Specified by:
      createMaxCardinalityRestriction in interface OntModel
      Parameters:
      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 to
      cardinality - The maximum cardinality of the property
      Returns:
      A new resource representing a mas-cardinality restriction
    • createMaxCardinalityQRestriction

      public 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.

      Specified by:
      createMaxCardinalityQRestriction in interface OntModel
      Parameters:
      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 to
      cardinality - The maximum cardinality of the property
      cls - The class to which all values of the restricted property should belong
      Returns:
      A new resource representing a mas-cardinality restriction
    • createMinCardinalityQRestriction

      public 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.

      Specified by:
      createMinCardinalityQRestriction in interface OntModel
      Parameters:
      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 to
      cardinality - The minimun cardinality of the property
      cls - The class to which all values of the restricted property should belong
      Returns:
      A new resource representing a mas-cardinality restriction
    • createCardinalityQRestriction

      public 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.

      Specified by:
      createCardinalityQRestriction in interface OntModel
      Parameters:
      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 to
      cardinality - The cardinality of the property
      cls - The class to which all values of the restricted property should belong
      Returns:
      A new resource representing a mas-cardinality restriction
    • createDataRange

      public DataRange createDataRange(RDFList literals)

      Answer a data range defined as the given set of concrete data values. DataRange resources are necessarily bNodes.

      Specified by:
      createDataRange in interface OntModel
      Parameters:
      literals - An iterator over a set of literals that will be the members of the data range, or null to define an empty data range
      Returns:
      A new data range containing the given literals as permissible values
    • createAllDifferent

      public 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.

      Specified by:
      createAllDifferent in interface OntModel
      Returns:
      A new AllDifferent resource
    • createAllDifferent

      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.

      Specified by:
      createAllDifferent in interface OntModel
      Parameters:
      differentMembers - A list of the class expressions that denote a set of mutually disjoint classes
      Returns:
      A new AllDifferent resource
    • createOntResource

      public <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" );

      Specified by:
      createOntResource in interface OntModel
      Parameters:
      javaClass - The Java class object that represents the ontology abstraction to create
      rdfType - 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.
      Returns:
      An ontology resource, of the type specified by the javaClass
    • createOntResource

      public OntResource createOntResource(String uri)

      Answer a resource presenting the OntResource facet, which has the given URI.

      Specified by:
      createOntResource in interface OntModel
      Parameters:
      uri - The URI of the resource, or null for an anonymous resource (aka bNode)
      Returns:
      An OntResource with the given URI
    • createList

      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.

      Specified by:
      createList in interface Model
      Overrides:
      createList in class ModelCom
      Returns:
      An RDF-encoded list of no elements, using the current language profile
    • getProfile

      public Profile getProfile()

      Answer the language profile (for example, OWL or DAML+OIL) that this model is working to.

      Specified by:
      getProfile in interface OntModel
      Returns:
      A language profile
    • loadImports

      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.

      Specified by:
      loadImports in interface OntModel
    • hasLoadedImport

      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.

      Specified by:
      hasLoadedImport in interface OntModel
      Parameters:
      uri - An ontology URI
      Returns:
      True if the document corresponding to the URI has been successfully loaded into this model
    • addLoadedImport

      public 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.

      Specified by:
      addLoadedImport in interface OntModel
      Parameters:
      uri - A document URI that has now been imported into the model.
    • removeLoadedImport

      public void removeLoadedImport(String uri)

      Record that this model no longer imports the document with the given URI.

      Specified by:
      removeLoadedImport in interface OntModel
      Parameters:
      uri - A document URI that is no longer imported into the model.
    • listImportedOntologyURIs

      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

      Specified by:
      listImportedOntologyURIs in interface OntModel
      Returns:
      The imported ontology URI's as a set. Note that since the underlying graph is not ordered, the order of values in the list in successive calls to this method is not guaranteed to be preserved.
    • listImportedOntologyURIs

      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.

      Specified by:
      listImportedOntologyURIs in interface OntModel
      Parameters:
      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.
      Returns:
      The imported ontology URI's as a list. Note that since the underlying graph is not ordered, the order of values in the list in successive calls to this method is not guaranteed to be preserved.
    • getImportModelMaker

      public ModelMaker getImportModelMaker()

      Answer the model maker associated with this model (used for constructing the constituent models of the imports closure).

      Specified by:
      getImportModelMaker in interface OntModel
      Returns:
      The local graph factory
    • read

      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).

      Specified by:
      read in interface Model
      Overrides:
      read in class ModelCom
      Parameters:
      uri - URI to read from, may be mapped to a local source by the document manager
      Returns:
      this model
    • read

      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).

      Specified by:
      read in interface Model
      Overrides:
      read in class ModelCom
      Parameters:
      reader - An input reader
      base - The base URI
      Returns:
      the current model
    • read

      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).

      Specified by:
      read in interface Model
      Overrides:
      read in class ModelCom
      Parameters:
      reader - An input stream
      base - The base URI
      Returns:
      the current model
    • read

      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).

      Specified by:
      read in interface Model
      Overrides:
      read in class ModelCom
      Parameters:
      uri - URI to read from, may be mapped to a local source by the document manager
      syntax - The source syntax
      Returns:
      This model, to allow chaining calls
    • read

      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).

      Specified by:
      read in interface Model
      Overrides:
      read in class ModelCom
      Parameters:
      uri - URI to read from, may be mapped to a local source by the document manager
      base - The base URI for this model
      syntax - The source syntax
      Returns:
      This model, to allow chaining calls
    • read

      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).

      Specified by:
      read in interface Model
      Overrides:
      read in class ModelCom
      Parameters:
      reader - An input reader
      base - The base URI
      syntax - The source syntax
      Returns:
      This model, to allow chaining calls
    • read

      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).

      Specified by:
      read in interface Model
      Overrides:
      read in class ModelCom
      Parameters:
      reader - An input stream
      base - The base URI
      syntax - The source syntax
      Returns:
      This model, to allow chaining calls
    • getSubGraphs

      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.

      Specified by:
      getSubGraphs in interface OntModel
      Returns:
      A list of sub graphs for this ontology model
    • listSubModels

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

      Specified by:
      listSubModels in interface OntModel
      Parameters:
      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.
      Returns:
      An iterator, each value of which will be an OntModel representing a sub-model of this ontology.
    • listSubModels

      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.

      Specified by:
      listSubModels in interface OntModel
      Returns:
      An iterator, each value of which will be an OntModel representing a sub-model of this ontology.
      See Also:
    • countSubModels

      public int countSubModels()

      Answer the number of sub-models of this model, not including the base model.

      Specified by:
      countSubModels in interface OntModel
      Returns:
      The number of sub-models, ≥ zero.
    • getImportedModel

      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.

      Specified by:
      getImportedModel in interface OntModel
      Parameters:
      uri - The URI of an ontology that may have been imported into the ontology represented by this model
      Returns:
      A model representing the imported ontology with the given URI, or null.
    • getBaseGraph

      public 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.

      Returns:
      The base-graph for this ontology model
    • getBaseModel

      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).

      Specified by:
      getBaseModel in interface OntModel
      Returns:
      The base model for this ontology model
    • addSubModel

      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() );
       
      Specified by:
      addSubModel in interface OntModel
      Parameters:
      model - A sub-model to add
      See Also:
    • addSubModel

      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 );
       
      Specified by:
      addSubModel in interface OntModel
      Parameters:
      model - A sub-model to add
      rebind - If true, rebind any associated inferencing engine to the new data (which may be an expensive operation)
    • removeSubModel

      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.

      Specified by:
      removeSubModel in interface OntModel
      Parameters:
      model - A sub-model to remove
      See Also:
    • removeSubModel

      public void removeSubModel(Model model, boolean rebind)

      Remove the given model as one of the sub-models of the enclosed ontology union model.

      Specified by:
      removeSubModel in interface OntModel
      Parameters:
      model - A sub-model to remove
      rebind - If true, rebind any associated inferencing engine to the new data (which may be an expensive operation)
    • isInBaseModel

      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.

      Specified by:
      isInBaseModel in interface OntModel
      Parameters:
      node - An RDF node (Resource, Property or Literal) to test
      Returns:
      True if the given node is from the base model
    • isInBaseModel

      public 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.

      Specified by:
      isInBaseModel in interface OntModel
      Parameters:
      stmt - A statement to test
      Returns:
      True if the given statement is from the base model
    • strictMode

      public 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.

      Specified by:
      strictMode in interface OntModel
      Returns:
      True if in strict checking mode
    • setStrictMode

      public void setStrictMode(boolean strict)

      Set the checking mode to strict or non-strict.

      Specified by:
      setStrictMode in interface OntModel
      Parameters:
      strict -
      See Also:
    • setDynamicImports

      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.

      Specified by:
      setDynamicImports in interface OntModel
      Parameters:
      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.
    • getDynamicImports

      public boolean getDynamicImports()

      Answer true if the imports closure of the model will be dynamically updated as imports statements are added and removed.

      Specified by:
      getDynamicImports in interface OntModel
      Returns:
      True if the imports closure is updated dynamically.
    • getSpecification

      public OntModelSpec getSpecification()

      Answer the ontology model specification that was used to construct this model

      Specified by:
      getSpecification in interface OntModel
      Returns:
      An ont model spec instance.
    • write

      public Model write(Writer writer)
      Description copied from interface: 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.

      Specified by:
      write in interface Model
      Specified by:
      write in interface OntModel
      Overrides:
      write in class ModelCom
      Parameters:
      writer - A writer to which the XML will be written
      Returns:
      this model
    • write

      public Model write(Writer writer, String lang)
      Description copied from interface: 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".

      Specified by:
      write in interface Model
      Specified by:
      write in interface OntModel
      Overrides:
      write in class ModelCom
      Parameters:
      writer - The output writer
      lang - The output language
      Returns:
      this model
    • write

      public Model write(Writer writer, String lang, String base)
      Description copied from interface: 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".

      Specified by:
      write in interface Model
      Specified by:
      write in interface OntModel
      Overrides:
      write in class ModelCom
      Parameters:
      writer - The output writer
      lang - The language in which the RDF should be written
      base - The base uri for relative URI calculations. null means use only absolute URI's.
      Returns:
      this model
    • write

      public Model write(OutputStream out)
      Description copied from interface: 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".

      Specified by:
      write in interface Model
      Specified by:
      write in interface OntModel
      Overrides:
      write in class ModelCom
      Parameters:
      out - The output stream to which the XML will be written
      Returns:
      This model
    • write

      public Model write(OutputStream out, String lang)
      Description copied from interface: 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".

      Specified by:
      write in interface Model
      Specified by:
      write in interface OntModel
      Overrides:
      write in class ModelCom
      Parameters:
      out - The output stream to which the RDF is written
      lang - The output language
      Returns:
      This model
    • write

      public Model write(OutputStream out, String lang, String base)
      Description copied from interface: 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".

      Specified by:
      write in interface Model
      Specified by:
      write in interface OntModel
      Overrides:
      write in class ModelCom
      Parameters:
      out - The output stream to which the RDF is written
      lang - The language in which the RDF should be written
      base - 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.
      Returns:
      This model
    • writeAll

      public Model writeAll(Writer writer, String lang, String base)
      Description copied from interface: 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".

      Specified by:
      writeAll in interface OntModel
      Parameters:
      writer - The output writer
      lang - The language in which the RDF should be written
      base - The base URI for relative URI calculations. null means use only absolute URI's.
      Returns:
      This model
    • writeAll

      public Model writeAll(OutputStream out, String lang, String base)
      Description copied from interface: 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".

      Specified by:
      writeAll in interface OntModel
      Parameters:
      out - The output stream to which the RDF is written
      lang - The language in which the RDF should be written
      base - The base URI to use when writing relative URI's. null means use only absolute URI's.
      Returns:
      This model
    • writeAll

      public Model writeAll(Writer writer, String lang)
      Description copied from interface: 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".

      Specified by:
      writeAll in interface OntModel
      Parameters:
      writer - The output writer
      lang - The language in which the RDF should be written
      Returns:
      This model
    • writeAll

      public Model writeAll(OutputStream out, String lang)
      Description copied from interface: 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".

      Specified by:
      writeAll in interface OntModel
      Parameters:
      out - The output stream to which the RDF is written
      lang - The language in which the RDF should be written
      Returns:
      This model
    • getRawModel

      public Model getRawModel()
      Return the raw RDF model being processed (i.e. the argument to the Reasonder.bind call that created this InfModel).
      Specified by:
      getRawModel in interface InfModel
    • getReasoner

      public Reasoner getReasoner()
      Return the Reasoner which is being used to answer queries to this graph.
      Specified by:
      getReasoner in interface InfModel
    • rebind

      public void rebind()
      Cause the inference model to reconsult the underlying data to take into account changes. Normally changes are made through the InfModel's add and remove calls are will be handled appropriately. However, in some cases changes are made "behind the InfModels's back" and this forces a full reconsult of the changed data.
      Specified by:
      rebind in interface InfModel
    • prepare

      public void prepare()
      Perform any initial processing and caching. This call is optional. Most engines either have negligable set up work or will perform an implicit "prepare" if necessary. The call is provided for those occasions where substantial preparation work is possible (e.g. running a forward chaining rule system) and where an application might wish greater control over when this prepration is done rather than just leaving to be done at first query time.
      Specified by:
      prepare in interface InfModel
    • reset

      public void reset()
      Reset any internal caches. Some systems, such as the tabled backchainer, retain information after each query. A reset will wipe this information preventing unbounded memory use at the expense of more expensive future queries. A reset does not cause the raw data to be reconsulted and so is less expensive than a rebind.
      Specified by:
      reset in interface InfModel
    • getDeductionsModel

      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.

      Specified by:
      getDeductionsModel in interface InfModel
      Returns:
      The derivations model, if one is defined, or else null
    • validate

      public ValidityReport validate()
      Test the consistency of the underlying data. This normally tests the validity of the bound instance data against the bound schema data.
      Specified by:
      validate in interface InfModel
      Returns:
      a ValidityReport structure
    • listStatements

      public StmtIterator listStatements(Resource subject, Property predicate, RDFNode object, Model posit)
      Find all the statements matching a pattern.

      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.

      Specified by:
      listStatements in interface InfModel
      Parameters:
      subject - The subject sought
      predicate - The predicate sought
      object - The value sought
      posit - Model containing additional assertions to be considered when matching statements
      Returns:
      an iterator over the subjects
    • setDerivationLogging

      public void setDerivationLogging(boolean logOn)
      Switch on/off drivation logging. If this is switched on then every time an inference is a made that fact is recorded and the resulting record can be access through a later getDerivation call. This may consume a lot of space!
      Specified by:
      setDerivationLogging in interface InfModel
    • getDerivation

      public Iterator<Derivation> getDerivation(Statement statement)
      Return the derivation of the given statement (which should be the result of some previous list operation). Not all reasoneers will support derivations.
      Specified by:
      getDerivation in interface InfModel
      Returns:
      an iterator over Derivation records or null if there is no derivation information available for this triple.
      See Also:
    • getOntResource

      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.

      Specified by:
      getOntResource in interface OntModel
      Parameters:
      uri - The URI of a resource
      Returns:
      An OntResource with the given URI, or null
    • getOntResource

      public OntResource getOntResource(Resource res)

      Answer a resource presenting the OntResource facet, which corresponds to the given resource but attached to this model.

      Specified by:
      getOntResource in interface OntModel
      Parameters:
      res - An existing resource
      Returns:
      An OntResource attached to this model that has the same URI or anonID as the given resource