/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Package
///////////////
package org.apache.jena.ontology;
// Imports
///////////////
import org.apache.jena.rdf.model.* ;
import org.apache.jena.util.iterator.ExtendedIterator ;
/**
* <p>
* Interface that represents an ontology node characterising a class description.
* </p>
*/
public interface OntClass
extends OntResource
{
// Constants
//////////////////////////////////
// External signature methods
//////////////////////////////////
// Enumerated class constructor
// subClassOf
/**
* <p>Assert that this class is sub-class of the given class. Any existing
* statements for <code>subClassOf</code> will be removed.</p>
* @param cls The class that this class is a sub-class of
* @exception ProfileException If the {@link Profile#SUB_CLASS_OF()} property is not supported in the current language profile.
*/
public void setSuperClass( Resource cls );
/**
* <p>Add a super-class of this class.</p>
* @param cls A class that is a super-class of this class.
* @exception ProfileException If the {@link Profile#SUB_CLASS_OF()} property is not supported in the current language profile.
*/
public void addSuperClass( Resource cls );
/**
* <p>Answer a class that is the super-class of this class. If there is
* more than one such class, an arbitrary selection is made. If there
* is no such super-class, return null.</p>
* @return A super-class of this class or null
* @exception ProfileException If the {@link Profile#SUB_CLASS_OF()}
* property is not supported in the current language profile.
*/
public OntClass getSuperClass();
/**
* <p>Answer an iterator over all of the classes that are super-classes of
* this class. Each element of the iterator will be an {@link OntClass}.</p>
* @return An iterator over the super-classes of this class.
* @exception ProfileException If the {@link Profile#SUB_CLASS_OF()} property is not supported in the current language profile.
*/
public ExtendedIterator<OntClass> listSuperClasses();
/**
* <p>Answer an iterator over all of the classes that are super-classes of
* this class. Each element of the iterator will be an {@link OntClass}.
* See {@link #listSubClasses( boolean )} for a full explanation of the <em>direct</em>
* parameter.
* </p>
*
* @param direct If true, only answer the directly adjacent classes in the
* super-class relation: i.e. eliminate any class for which there is a longer route
* to reach that child under the super-class relation.
* @return an iterator over the resources representing this class's sub-classes.
* @exception ProfileException If the {@link Profile#SUB_CLASS_OF()} property is not supported in the current language profile.
*/
public ExtendedIterator<OntClass> listSuperClasses( boolean direct );
/**
* <p>Answer true if the given class is a super-class of this class.</p>
* @param cls A class to test.
* @return True if the given class is a super-class of this class.
* @exception ProfileException If the {@link Profile#SUB_CLASS_OF()} property is not supported in the current language profile.
*/
public boolean hasSuperClass( Resource cls );
/**
* <p>Answer true if this class has any super-class in the model. Note that
* when using a reasoner, all OWL classes have owl:Thing as a super-class.</p>
* @return True if this class has any known super-class.
* @exception ProfileException If the {@link Profile#SUB_CLASS_OF()} property is not supported in the current language profile.
*/
public boolean hasSuperClass();
/**
* <p>Answer true if the given class is a super-class of this class.
* See {@link #listSubClasses( boolean )} for a full explanation of the <em>direct</em>
* parameter.
* </p>
* @param cls A class to test.
* @param direct If true, only search the classes that are directly adjacent to this
* class in the class hierarchy.
* @return True if the given class is a super-class of this class.
* @exception ProfileException If the {@link Profile#SUB_CLASS_OF()} property is not supported in the current language profile.
*/
public boolean hasSuperClass( Resource cls, boolean direct );
/**
* <p>Remove the given class from the super-classes of this class. If this statement
* is not true of the current model, nothing happens.</p>
* @param cls A class to be removed from the super-classes of this class
* @exception ProfileException If the {@link Profile#SUB_CLASS_OF()} class is not supported in the current language profile.
*/
public void removeSuperClass( Resource cls);
/**
* <p>Assert that this class is super-class of the given class. Any existing
* statements for <code>subClassOf</code> on <code>prop</code> will be removed.</p>
* @param cls The class that is a sub-class of this class
* @exception ProfileException If the {@link Profile#SUB_CLASS_OF()} property is not supported in the current language profile.
*/
public void setSubClass( Resource cls );
/**
* <p>Add a sub-class of this class.</p>
* @param cls A class that is a sub-class of this class.
* @exception ProfileException If the {@link Profile#SUB_CLASS_OF()} property is not supported in the current language profile.
*/
public void addSubClass( Resource cls );
/**
* <p>Answer a class that is the sub-class of this class. If there is
* more than one such class, an arbitrary selection is made. If
* there is no such class, return null.</p>
* @return A sub-class of this class or null
* @exception ProfileException If the {@link Profile#SUB_CLASS_OF()}
* property is not supported in the current language profile.
*/
public OntClass getSubClass();
/**
* <p>Answer an iterator over all of the classes that are declared to be sub-classes of
* this class. Each element of the iterator will be an {@link OntClass}.</p>
* @return An iterator over the sub-classes of this class.
* @exception ProfileException If the {@link Profile#SUB_CLASS_OF()} property is not supported in the current language profile.
*/
public ExtendedIterator<OntClass> listSubClasses();
/**
* <p>
* Answer an iterator over the classes that are declared to be sub-classes of
* this class. Each element of the iterator will be an {@link OntClass}. The
* distinguishing extra parameter for this method is the flag <code>direct</code>
* that allows some selectivity over the classes that appear in the iterator.
* Consider the following scenario:
* <code><pre>
* :B rdfs:subClassOf :A.
* :C rdfs:subClassOf :A.
* :D rdfs:subClassof :C.
* </pre></code>
* (so A has two sub-classes, B and C, and C has sub-class D). In a raw model, with
* no inference support, listing the sub-classes of A will answer B and C. In an
* inferencing model, <code>rdfs:subClassOf</code> is known to be transitive, so
* the sub-classes iterator will include D. The <code>direct</code> sub-classes
* are those members of the closure of the subClassOf relation, restricted to classes that
* cannot be reached by a longer route, i.e. the ones that are <em>directly</em> adjacent
* to the given root. Thus, the direct sub-classes of A are B and C only, and not D -
* even in an inferencing graph. Note that this is not the same as the entailments
* from the raw graph. Suppose we add to this example:
* <code><pre>
* :D rdfs:subClassof :A.
* </pre></code>
* Now, in the raw graph, A has sub-class C. But the direct sub-classes of A remain
* B and C, since there is a longer path A-C-D that means that D is not a direct sub-class
* of A. The assertion in the raw graph that A has sub-class D is essentially redundant,
* since this can be inferred from the closure of the graph.
* </p>
* <p>
* <strong>Note:</strong> This is is a change from the behaviour of Jena 1, which took a
* parameter <code>closed</code> to compute the closure over transitivity and equivalence
* of sub-classes. The closure capability in Jena2 is determined by the inference engine
* that is wrapped with the ontology model. The direct parameter is provided to allow,
* for example, a level-by-level traversal of the class hierarchy, starting at some given
* root. Observe that in Jena 1, passing <code>true</code> will tend to increase the number of
* results returned; in Jena 2 passing <code>true</code> will tend to reduce the number
* of results.
* </p>
*
* @param direct If true, only answer the directly adjacent classes in the
* sub-class relation: i.e. eliminate any class for which there is a longer route
* to reach that child under the sub-class relation.
* @return an iterator over the resources representing this class's sub-classes
* @exception ProfileException If the {@link Profile#SUB_CLASS_OF()} property is not supported in the current language profile.
*/
public ExtendedIterator<OntClass> listSubClasses( boolean direct );
/**
* <p>Answer true if the given class is a sub-class of this class.</p>
* @param cls A class to test.
* @return True if the given class is a sub-class of this class.
* @exception ProfileException If the {@link Profile#SUB_CLASS_OF()} property is not supported in the current language profile.
*/
public boolean hasSubClass( Resource cls );
/**
* <p>Answer true if this class has any sub-class in the model. Note that
* when using a reasoner, all OWL classes have owl:Nothing as a sub-class.</p>
* @return True if this class has any known sub-class.
* @exception ProfileException If the {@link Profile#SUB_CLASS_OF()} property is not supported in the current language profile.
*/
public boolean hasSubClass();
/**
* <p>Answer true if the given class is a sub-class of this class.
* See {@link #listSubClasses( boolean )} for a full explanation of the <em>direct</em>
* parameter.
* </p>
* @param cls A class to test.
* @param direct If true, only search the classes that are directly adjacent to this
* class in the class hierarchy.
* @return True if the given class is a sub-class of this class.
* @exception ProfileException If the {@link Profile#SUB_CLASS_OF()} property is not supported in the current language profile.
*/
public boolean hasSubClass( Resource cls, boolean direct );
/**
* <p>Remove the given class from the sub-classes of this class. If this statement
* is not true of the current model, nothing happens.</p>
* @param cls A class to be removed from the sub-classes of this class
* @exception ProfileException If the {@link Profile#SUB_CLASS_OF()} class is not supported in the current language profile.
*/
public void removeSubClass( Resource cls );
// equivalentClass
/**
* <p>Assert that the given class is equivalent to this class. Any existing
* statements for <code>equivalentClass</code> will be removed.</p>
* @param cls The class that this class is a equivalent to.
* @exception ProfileException If the {@link Profile#EQUIVALENT_CLASS()} property is not supported in the current language profile.
*/
public void setEquivalentClass( Resource cls );
/**
* <p>Add a class that is equivalent to this class.</p>
* @param cls A class that is equivalent to this class.
* @exception ProfileException If the {@link Profile#EQUIVALENT_CLASS()} property is not supported in the current language profile.
*/
public void addEquivalentClass( Resource cls );
/**
* <p>Answer a class that is equivalent to this class. If there is
* more than one such class, an arbitrary selection is made.
* See {@link #listEquivalentClasses()} for a note on equivalent classes
* when using a reasoner.
* </p>
* @return A class equivalent to this class
* @exception ProfileException If the {@link Profile#EQUIVALENT_CLASS()} property is not supported in the current language profile.
*/
public OntClass getEquivalentClass();
/**
* <p>Answer an iterator over all of the classes that are known to be equivalent to
* this class. Equivalence may be asserted in the model (using, for example,
* <code>owl:equivalentClass</code>, or may be inferred by the reasoner attached to the
* model. <strong>Note</strong> that the OWL semantics entails that every class is
* equivalent to itself, so when using a reasoning model clients should expect that
* this class will appear as a member of its own equivalent classes.</p><p>
* Each element of the returned iterator will be an {@link OntClass}.</p>
* @return An iterator over the classes equivalent to this class.
* @exception ProfileException If the {@link Profile#EQUIVALENT_CLASS()} property is not supported in the current language profile.
*/
public ExtendedIterator<OntClass> listEquivalentClasses();
/**
* <p>Answer true if the given class is equivalent to this class.</p>
* @param cls A class to test for
* @return True if the given property is equivalent to this class.
* @exception ProfileException If the {@link Profile#EQUIVALENT_CLASS()} property is not supported in the current language profile.
*/
public boolean hasEquivalentClass( Resource cls );
/**
* <p>Remove the statement that this class and the given class are
* equivalent. If this statement
* is not true of the current model, nothing happens.</p>
* @param cls A class that may be declared to be equivalent to this class, and which is no longer equivalent
* @exception ProfileException If the {@link Profile#EQUIVALENT_CLASS()} property is not supported in the current language profile.
*/
public void removeEquivalentClass( Resource cls );
// disjointWith
/**
* <p>Assert that this class is disjoint with the given class. Any existing
* statements for <code>disjointWith</code> will be removed.</p>
* @param cls The property that this class is disjoint with.
* @exception ProfileException If the {@link Profile#DISJOINT_WITH()} property is not supported in the current language profile.
*/
public void setDisjointWith( Resource cls );
/**
* <p>Add a class that this class is disjoint with.</p>
* @param cls A class that has no instances in common with this class.
* @exception ProfileException If the {@link Profile#DISJOINT_WITH()} property is not supported in the current language profile.
*/
public void addDisjointWith( Resource cls );
/**
* <p>Answer a class with which this class is disjoint. If there is
* more than one such class, an arbitrary selection is made.</p>
* @return A class disjoint with this class
* @exception ProfileException If the {@link Profile#DISJOINT_WITH()} property is not supported in the current language profile.
*/
public OntClass getDisjointWith();
/**
* <p>Answer an iterator over all of the classes that this class is declared to be disjoint with.
* Each element of the iterator will be an {@link OntClass}.</p>
* @return An iterator over the classes disjoint with this class.
* @exception ProfileException If the {@link Profile#DISJOINT_WITH()} property is not supported in the current language profile.
*/
public ExtendedIterator<OntClass> listDisjointWith();
/**
* <p>Answer true if this class is disjoint with the given class.</p>
* @param cls A class to test
* @return True if the this class is disjoint with the the given class.
* @exception ProfileException If the {@link Profile#DISJOINT_WITH()} property is not supported in the current language profile.
*/
public boolean isDisjointWith( Resource cls );
/**
* <p>Remove the statement that this class and the given class are
* disjoint. If this statement
* is not true of the current model, nothing happens.</p>
* @param cls A class that may be declared to be disjoint with this class, and which is no longer disjoint
* @exception ProfileException If the {@link Profile#DISJOINT_WITH()} property is not supported in the current language profile.
*/
public void removeDisjointWith( Resource cls );
// other utility methods
/**
* Equivalent to calling {@link #listDeclaredProperties(boolean)} with
* default value <code>direct = false</code>.
*
*/
public ExtendedIterator<OntProperty> listDeclaredProperties();
/**
* <p>Return an iterator over the properties associated with a frame-like
* view of this class. This captures an intuitive notion of the <em>
* properties of a class</em>. This can be useful in presenting an ontology
* class in a user interface, for example by automatically constructing a
* form to instantiate instances of the class. The properties in the frame-like
* view of the class are determined by comparing the domain of properties in
* this class's {@link OntModel} with the class itself. See:
* <a href="/documentation/notes/rdf-frames.html">Presenting RDF as frames</a>
* for more details.
* </p>
* <p>
* Note that many cases of determining whether a
* property is associated with a class depends on RDFS or OWL reasoning.
* This method may therefore return complete results only in models that
* have an attached reasoner.
* </p>
*
* @param direct If <code>true</code>, restrict the properties returned to those directly
* associated with this class. If <code>false</code>, the properties of super-classes of
* this class will not be listed among the declared properties of this class.
* @return An iteration of the properties that are associated with this class
* by their domain.
*/
public ExtendedIterator<OntProperty> listDeclaredProperties( boolean direct );
/**
* <p>Return an iteration of the properties associated with a frame-like
* view of this class. This captures an informal notion of the <em>properties
* of a class</em>, by looking at the domains of the properties in this
* class's model, and matching them to this class. A full description of
* the frame-like view of a class may be found in:
* <a href="//how-to/rdf-frames.html">RDF frames how-to</a>
* for full details.<p>
* Note that many cases of determining whether a
* property is associated with a class depends on RDFS or OWL reasoning.
* This method may therefore return complete results only in models that
* have an attached reasoner.
* See the
* @return An iteration of the properties that are associated with this class
* by their domain.
*/
public boolean hasDeclaredProperty( Property p, boolean direct );
/**
* <p>Answer an iterator over the individuals in the model that have this
* class among their types. Equivalent to {@link #listInstances(boolean)}
* with an argument <code>false</code>.<p>
*
* @return An iterator over those instances that have this class as one of
* the classes to which they belong
*/
public ExtendedIterator<? extends OntResource> listInstances();
/**
* <p>Answer an iterator over the individuals in the model that have this
* class among their types, optionally excluding sub-classes of this class.<p>
*
* @param direct If true, only direct instances are counted (i.e. not instances
* of sub-classes of this class)
* @return An iterator over those instances that have this class as one of
* the classes to which they belong
*/
public ExtendedIterator<? extends OntResource> listInstances( boolean direct );
/**
* <p>Answer a new individual that has this class as its <code>rdf:type</code></p>
* @return A new anonymous individual that is an instance of this class
*/
public Individual createIndividual();
/**
* <p>Answer a new individual that has this class as its <code>rdf:type</code></p>
* @param uri The URI of the new individual
* @return A new named individual that is an instance of this class
*/
public Individual createIndividual( String uri );
/**
* <p>Remove the given individual from the set of instances that are members of
* this class. This is effectively equivalent to the {@link Individual#removeOntClass} method,
* but invoked via the class resource rather than via the individual resource.</p>
* @param individual A resource denoting an individual that is no longer to be a member
* of this class
*/
public void dropIndividual( Resource individual );
/**
* <p>Answer true if this class is one of the roots of the local class hierarchy.
* This will be true if either (i) this class has <code>owl:Thing</code>
* as a direct super-class, or (ii) it has
* no declared super-classes (including anonymous class expressions).</p>
* @return True if this class is the root of the class hierarchy in the
* model it is attached to
*/
public boolean isHierarchyRoot();
// access to facets
/**
* <p>Answer a view of this class as an enumerated class</p>
* @return This class, but viewed as an EnumeratedClass facet
* @exception ConversionException if the class cannot be converted to an enumerated class
* given the language profile and the current state of the underlying model.
*/
public EnumeratedClass asEnumeratedClass();
/**
* <p>Answer a view of this class as a union class</p>
* @return This class, but viewed as a UnionClass facet
* @exception ConversionException if the class cannot be converted to a union class
* given the language profile and the current state of the underlying model.
*/
public UnionClass asUnionClass();
/**
* <p>Answer a view of this class as an intersection class</p>
* @return This class, but viewed as an IntersectionClass facet
* @exception ConversionException if the class cannot be converted to an intersection class
* given the language profile and the current state of the underlying model.
*/
public IntersectionClass asIntersectionClass();
/**
* <p>Answer a view of this class as a complement class</p>
* @return This class, but viewed as a ComplementClass facet
* @exception ConversionException if the class cannot be converted to a complement class
* given the language profile and the current state of the underlying model.
*/
public ComplementClass asComplementClass();
/**
* <p>Answer a view of this class as a restriction class expression</p>
* @return This class, but viewed as a Restriction facet
* @exception ConversionException if the class cannot be converted to a restriction
* given the language profile and the current state of the underlying model.
*/
public Restriction asRestriction();
// sub-type testing
/**
* <p>Answer true if this class is an enumerated class expression</p>
* @return True if this is an enumerated class expression
*/
public boolean isEnumeratedClass();
/**
* <p>Answer true if this class is a union class expression</p>
* @return True if this is a union class expression
*/
public boolean isUnionClass();
/**
* <p>Answer true if this class is an intersection class expression</p>
* @return True if this is an intersection class expression
*/
public boolean isIntersectionClass();
/**
* <p>Answer true if this class is a complement class expression</p>
* @return True if this is a complement class expression
*/
public boolean isComplementClass();
/**
* <p>Answer true if this class is a property restriction</p>
* @return True if this is a restriction
*/
public boolean isRestriction();
// conversion operations
/**
* <p>Answer a view of this class as an enumeration of the given individuals.</p>
* @param individuals A list of the individuals that will comprise the permitted values of this
* class converted to an enumeration
* @return This ontology class, converted to an enumeration of the given individuals
*/
public EnumeratedClass convertToEnumeratedClass( RDFList individuals );
/**
* <p>Answer a view of this class as an intersection of the given classes.</p>
* @param classes A list of the classes that will comprise the operands of the intersection
* @return This ontology class, converted to an intersection of the given classes
*/
public IntersectionClass convertToIntersectionClass( RDFList classes );
/**
* <p>Answer a view of this class as a union of the given classes.</p>
* @param classes A list of the classes that will comprise the operands of the union
* @return This ontology class, converted to an union of the given classes
*/
public UnionClass convertToUnionClass( RDFList classes );
/**
* <p>Answer a view of this class as an complement of the given class.</p>
* @param cls An ontology class that will be operand of the complement
* @return This ontology class, converted to an complement of the given class
*/
public ComplementClass convertToComplementClass( Resource cls );
/**
* <p>Answer a view of this class as an restriction on the given property.</p>
* @param prop A property this is the subject of a property restriction class expression
* @return This ontology class, converted to a restriction on the given property
*/
public Restriction convertToRestriction( Property prop );
}