com.hp.hpl.jena.ontology
Interface OntClass

All Superinterfaces:
OntResource, RDFNode, Resource
All Known Subinterfaces:
AllValuesFromRestriction, BooleanClassDescription, CardinalityRestriction, ComplementClass, EnumeratedClass, HasValueRestriction, IntersectionClass, MaxCardinalityRestriction, MinCardinalityRestriction, Restriction, SomeValuesFromRestriction, UnionClass

public interface OntClass
extends OntResource

Interface that represents an ontology node characterising a class description.

Version:
CVS $Id: OntClass.java,v 1.17 2003/07/15 14:44:11 chris-dollin Exp $
Author:
Ian Dickinson, HP Labs (email)

Method Summary
 void addDisjointWith(Resource cls)
          Add a class that this class is disjoint with.
 void addEquivalentClass(Resource cls)
          Add a class that is equivalent to this class.
 void addSubClass(Resource cls)
          Add a sub-class of this class.
 void addSuperClass(Resource cls)
          Add a super-class of this class.
 ComplementClass asComplementClass()
          Answer a view of this class as a complement class
 EnumeratedClass asEnumeratedClass()
          Answer a view of this class as an enumerated class
 IntersectionClass asIntersectionClass()
          Answer a view of this class as an intersection class
 Restriction asRestriction()
          Answer a view of this class as a restriction class expression
 UnionClass asUnionClass()
          Answer a view of this class as a union class
 ComplementClass convertToComplementClass(Resource cls)
          Answer a view of this class as an complement of the given class.
 EnumeratedClass convertToEnumeratedClass(RDFList individuals)
          Answer a view of this class as an enumeration of the given individuals.
 IntersectionClass convertToIntersectionClass(RDFList classes)
          Answer a view of this class as an intersection of the given classes.
 Restriction convertToRestriction(Property prop)
          Answer a view of this class as an resriction on the given property.
 UnionClass convertToUnionClass(RDFList classes)
          Answer a view of this class as a union of the given classes.
 OntClass getDisjointWith()
          Answer a class with which this class is disjoint.
 OntClass getEquivalentClass()
          Answer a class that is equivalent to this class.
 OntClass getSubClass()
          Answer a class that is the sub-class of this class.
 OntClass getSuperClass()
          Answer a class that is the super-class of this class.
 boolean hasEquivalentClass(Resource cls)
          Answer true if the given class is equivalent to this class.
 boolean hasSubClass(Resource cls)
          Answer true if the given class is a sub-class of this class.
 boolean hasSubClass(Resource cls, boolean direct)
          Answer true if the given class is a sub-class of this class.
 boolean hasSuperClass(Resource cls)
          Answer true if the given class is a super-class of this class.
 boolean hasSuperClass(Resource cls, boolean direct)
          Answer true if the given class is a super-class of this class.
 boolean isComplementClass()
          Answer true if this class is a complement class expression
 boolean isDisjointWith(Resource cls)
          Answer true if this class is disjoint with the given class.
 boolean isEnumeratedClass()
          Answer true if this class is an enumerated class expression
 boolean isIntersectionClass()
          Answer true if this class is an intersection class expression
 boolean isRestriction()
          Answer true if this class is a property restriction
 boolean isUnionClass()
          Answer true if this class is a union class expression
 ExtendedIterator listDeclaredProperties()
          Answer an iteration of the properties that may be used for instances of this class: i.e. the properties that have this class, or one of its super-classes, as domain.
 ExtendedIterator listDeclaredProperties(boolean all)
          Answer an iteration of the properties that may be used for instances of this class: i.e. the properties that have this class, or optionally one of its super-classes, as domain.
 ExtendedIterator listDisjointWith()
          Answer an iterator over all of the classes that this class is declared to be disjoint with.
 ExtendedIterator listEquivalentClasses()
          Answer an iterator over all of the classes that are declared to be equivalent classes to this class.
 ExtendedIterator listInstances()
          Answer an iterator over the individuals in the model that have this class among their types.
 ExtendedIterator listSubClasses()
          Answer an iterator over all of the classes that are declared to be sub-classes of this class.
 ExtendedIterator listSubClasses(boolean direct)
           Answer an iterator over the classes that are declared to be sub-classes of this class.
 ExtendedIterator listSuperClasses()
          Answer an iterator over all of the classes that are declared to be super-classes of this class.
 ExtendedIterator listSuperClasses(boolean direct)
          Answer an iterator over all of the classes that are declared to be super-classes of this class.
 void removeDisjointWith(Resource cls)
          Remove the statement that this class and the given class are disjoint.
 void removeEquivalentClass(Resource cls)
          Remove the statement that this class and the given class are equivalent.
 void removeSubClass(Resource cls)
          Remove the given class from the sub-classes of this class.
 void removeSuperClass(Resource cls)
          Remove the given class from the super-classes of this class.
 void setDisjointWith(Resource cls)
          Assert that this class is disjoint with the given class.
 void setEquivalentClass(Resource cls)
          Assert that the given class is equivalent to this class.
 void setSubClass(Resource cls)
          Assert that this class is super-class of the given class.
 void setSuperClass(Resource cls)
          Assert that this class is sub-class of the given class.
 
Methods inherited from interface com.hp.hpl.jena.ontology.OntResource
accessor, accessor, addComment, addComment, addDifferentFrom, addIsDefinedBy, addLabel, addLabel, addRDFType, addSameAs, addSeeAlso, addVersionInfo, asAllDifferent, asAnnotationProperty, asClass, asIndividual, asOntology, asProperty, getCardinality, getComment, getDifferentFrom, getIsDefinedBy, getLabel, getProfile, getPropertyValue, getRDFType, getRDFType, getSameAs, getSeeAlso, getVersionInfo, hasComment, hasComment, hasLabel, hasLabel, hasRDFType, hasRDFType, hasRDFType, hasSeeAlso, hasVersionInfo, isDefinedBy, isDifferentFrom, isSameAs, listComments, listDifferentFrom, listIsDefinedBy, listLabels, listPropertyValues, listRDFTypes, listSameAs, listSeeAlso, listVersionInfo, remove, removeComment, removeComment, removeDefinedBy, removeDifferentFrom, removeLabel, removeLabel, removeProperty, removeRDFType, removeSameAs, removeSeeAlso, removeVersionInfo, setComment, setDifferentFrom, setIsDefinedBy, setLabel, setPropertyValue, setRDFType, setSameAs, setSeeAlso, setVersionInfo
 
Methods inherited from interface com.hp.hpl.jena.rdf.model.Resource
abort, addProperty, addProperty, addProperty, addProperty, addProperty, addProperty, addProperty, addProperty, addProperty, begin, commit, equals, getId, getLocalName, getModel, getNameSpace, getNode, getProperty, getURI, hasProperty, hasProperty, hasProperty, hasProperty, hasProperty, hasProperty, hasProperty, hasProperty, hasProperty, hasProperty, isAnon, listProperties, listProperties, removeAll, removeProperties, toString
 
Methods inherited from interface com.hp.hpl.jena.rdf.model.RDFNode
as, asNode, canAs, inModel, visitWith
 

Method Detail

setSuperClass

public void setSuperClass(Resource cls)

Assert that this class is sub-class of the given class. Any existing statements for subClassOf will be removed.

Parameters:
cls - The class that this class is a sub-class of
Throws:
OntProfileException - If the Profile.SUB_CLASS_OF() property is not supported in the current language profile.

addSuperClass

public void addSuperClass(Resource cls)

Add a super-class of this class.

Parameters:
cls - A class that is a super-class of this class.
Throws:
OntProfileException - If the Profile.SUB_CLASS_OF() property is not supported in the current language profile.

getSuperClass

public OntClass getSuperClass()

Answer a class that is the super-class of this class. If there is more than one such class, an arbitrary selection is made.

Returns:
A super-class of this class
Throws:
OntProfileException - If the Profile.SUB_CLASS_OF() property is not supported in the current language profile.

listSuperClasses

public ExtendedIterator listSuperClasses()

Answer an iterator over all of the classes that are declared to be super-classes of this class. Each element of the iterator will be an OntClass.

Returns:
An iterator over the super-classes of this class.
Throws:
OntProfileException - If the Profile.SUB_CLASS_OF() property is not supported in the current language profile.

listSuperClasses

public ExtendedIterator listSuperClasses(boolean direct)

Answer an iterator over all of the classes that are declared to be super-classes of this class. Each element of the iterator will be an OntClass. See listSubClasses( boolean ) for a full explanation of the direct parameter.

Parameters:
direct - If true, only answer the direcly 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.
Returns:
an iterator over the resources representing this class's sub-classes.
Throws:
OntProfileException - If the Profile.SUB_CLASS_OF() property is not supported in the current language profile.

hasSuperClass

public boolean hasSuperClass(Resource cls)

Answer true if the given class is a super-class of this class.

Parameters:
cls - A class to test.
Returns:
True if the given class is a super-class of this class.
Throws:
OntProfileException - If the Profile.SUB_CLASS_OF() property is not supported in the current language profile.

hasSuperClass

public boolean hasSuperClass(Resource cls,
                             boolean direct)

Answer true if the given class is a super-class of this class. See listSubClasses( boolean ) for a full explanation of the direct parameter.

Parameters:
cls - A class to test.
direct - If true, only search the classes that are directly adjacent to this class in the class hierarchy.
Returns:
True if the given class is a super-class of this class.
Throws:
OntProfileException - If the Profile.SUB_CLASS_OF() property is not supported in the current language profile.

removeSuperClass

public void removeSuperClass(Resource cls)

Remove the given class from the super-classes of this class. If this statement is not true of the current model, nothing happens.

Parameters:
cls - A class to be removed from the super-classes of this class
Throws:
OntProfileException - If the Profile.SUB_CLASS_OF() class is not supported in the current language profile.

setSubClass

public void setSubClass(Resource cls)

Assert that this class is super-class of the given class. Any existing statements for subClassOf on prop will be removed.

Parameters:
cls - The class that is a sub-class of this class
Throws:
OntProfileException - If the Profile.SUB_CLASS_OF() property is not supported in the current language profile.

addSubClass

public void addSubClass(Resource cls)

Add a sub-class of this class.

Parameters:
cls - A class that is a sub-class of this class.
Throws:
OntProfileException - If the Profile.SUB_CLASS_OF() property is not supported in the current language profile.

getSubClass

public OntClass getSubClass()

Answer a class that is the sub-class of this class. If there is more than one such class, an arbitrary selection is made.

Returns:
A sub-class of this class
Throws:
OntProfileException - If the Profile.SUB_CLASS_OF() property is not supported in the current language profile.

listSubClasses

public ExtendedIterator listSubClasses()

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

Returns:
An iterator over the sub-classes of this class.
Throws:
OntProfileException - If the Profile.SUB_CLASS_OF() property is not supported in the current language profile.

listSubClasses

public ExtendedIterator listSubClasses(boolean direct)

Answer an iterator over the classes that are declared to be sub-classes of this class. Each element of the iterator will be an OntClass. The distinguishing extra parameter for this method is the flag direct that allows some selectivity over the classes that appear in the iterator. Consider the following scenario:

   :B rdfs:subClassOf :A.
   :C rdfs:subClassOf :A.
   :D rdfs:subClassof :C.
 
(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, rdfs:subClassOf is known to be transitive, so the sub-classes iterator will include D. The direct 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 directly 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:
   :D rdfs:subClassof :A.
 
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.

Note: This is is a change from the behaviour of Jena 1, which took a parameter closed 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 exmaple, a level-by-level traversal of the class hierarchy, starting at some given root. Observe that in Jena 1, passing true will tend to increase the number of results returned; in Jena 2 passing true will tend to reduce the number of results.

Parameters:
direct - If true, only answer the direcly 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.
Returns:
an iterator over the resources representing this class's sub-classes
Throws:
OntProfileException - If the Profile.SUB_CLASS_OF() property is not supported in the current language profile.

hasSubClass

public boolean hasSubClass(Resource cls)

Answer true if the given class is a sub-class of this class.

Parameters:
cls - A class to test.
Returns:
True if the given class is a sub-class of this class.
Throws:
OntProfileException - If the Profile.SUB_CLASS_OF() property is not supported in the current language profile.

hasSubClass

public boolean hasSubClass(Resource cls,
                           boolean direct)

Answer true if the given class is a sub-class of this class. See listSubClasses( boolean ) for a full explanation of the direct parameter.

Parameters:
cls - A class to test.
direct - If true, only search the classes that are directly adjacent to this class in the class hierarchy.
Returns:
True if the given class is a sub-class of this class.
Throws:
OntProfileException - If the Profile.SUB_CLASS_OF() property is not supported in the current language profile.

removeSubClass

public void removeSubClass(Resource cls)

Remove the given class from the sub-classes of this class. If this statement is not true of the current model, nothing happens.

Parameters:
cls - A class to be removed from the sub-classes of this class
Throws:
OntProfileException - If the Profile.SUB_CLASS_OF() class is not supported in the current language profile.

setEquivalentClass

public void setEquivalentClass(Resource cls)

Assert that the given class is equivalent to this class. Any existing statements for equivalentClass will be removed.

Parameters:
cls - The class that this class is a equivalent to.
Throws:
OntProfileException - If the Profile.EQUIVALENT_CLASS() property is not supported in the current language profile.

addEquivalentClass

public void addEquivalentClass(Resource cls)

Add a class that is equivalent to this class.

Parameters:
cls - A class that is equivalent to this class.
Throws:
OntProfileException - If the Profile.EQUIVALENT_CLASS() property is not supported in the current language profile.

getEquivalentClass

public OntClass getEquivalentClass()

Answer a class that is equivalent to this class. If there is more than one such class, an arbitrary selection is made.

Returns:
A class equivalent to this class
Throws:
OntProfileException - If the Profile.EQUIVALENT_CLASS() property is not supported in the current language profile.

listEquivalentClasses

public ExtendedIterator listEquivalentClasses()

Answer an iterator over all of the classes that are declared to be equivalent classes to this class. Each element of the iterator will be an OntClass.

Returns:
An iterator over the classes equivalent to this class.
Throws:
OntProfileException - If the Profile.EQUIVALENT_CLASS() property is not supported in the current language profile.

hasEquivalentClass

public boolean hasEquivalentClass(Resource cls)

Answer true if the given class is equivalent to this class.

Parameters:
cls - A class to test for
Returns:
True if the given property is equivalent to this class.
Throws:
OntProfileException - If the Profile.EQUIVALENT_CLASS() property is not supported in the current language profile.

removeEquivalentClass

public void removeEquivalentClass(Resource cls)

Remove the statement that this class and the given class are equivalent. If this statement is not true of the current model, nothing happens.

Parameters:
cls - A class that may be declared to be equivalent to this class, and which is no longer equivalent
Throws:
OntProfileException - If the Profile.EQUIVALENT_CLASS()() property is not supported in the current language profile.

setDisjointWith

public void setDisjointWith(Resource cls)

Assert that this class is disjoint with the given class. Any existing statements for disjointWith will be removed.

Parameters:
cls - The property that this class is disjoint with.
Throws:
OntProfileException - If the Profile.DISJOINT_WITH() property is not supported in the current language profile.

addDisjointWith

public void addDisjointWith(Resource cls)

Add a class that this class is disjoint with.

Parameters:
cls - A class that has no instances in common with this class.
Throws:
OntProfileException - If the Profile.DISJOINT_WITH() property is not supported in the current language profile.

getDisjointWith

public OntClass getDisjointWith()

Answer a class with which this class is disjoint. If there is more than one such class, an arbitrary selection is made.

Returns:
A class disjoint with this class
Throws:
OntProfileException - If the Profile.DISJOINT_WITH() property is not supported in the current language profile.

listDisjointWith

public ExtendedIterator listDisjointWith()

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

Returns:
An iterator over the classes disjoint with this class.
Throws:
OntProfileException - If the Profile.DISJOINT_WITH() property is not supported in the current language profile.

isDisjointWith

public boolean isDisjointWith(Resource cls)

Answer true if this class is disjoint with the given class.

Parameters:
cls - A class to test
Returns:
True if the this class is disjoint with the the given class.
Throws:
OntProfileException - If the Profile.DISJOINT_WITH() property is not supported in the current language profile.

removeDisjointWith

public void removeDisjointWith(Resource cls)

Remove the statement that this class and the given class are disjoint. If this statement is not true of the current model, nothing happens.

Parameters:
cls - A class that may be declared to be disjoint with this class, and which is no longer disjoint
Throws:
OntProfileException - If the Profile.DISJOINT_WITH()()() property is not supported in the current language profile.

listDeclaredProperties

public ExtendedIterator listDeclaredProperties()

Answer an iteration of the properties that may be used for instances of this class: i.e. the properties that have this class, or one of its super-classes, as domain.

Returns:
An iteration of the properties that have this class in the domain

listDeclaredProperties

public ExtendedIterator listDeclaredProperties(boolean all)

Answer an iteration of the properties that may be used for instances of this class: i.e. the properties that have this class, or optionally one of its super-classes, as domain.

Parameters:
all - If true, use all available information from the class hierarchy; if false, only use properties defined for this class alone.
Returns:
An iteration of the properties that have this class as domain

listInstances

public ExtendedIterator listInstances()

Answer an iterator over the individuals in the model that have this class among their types.

Returns:
An iterator over those instances that have this class as one of the classes to which they belong

asEnumeratedClass

public EnumeratedClass asEnumeratedClass()

Answer a view of this class as an enumerated class

Returns:
This class, but viewed as an EnumeratedClass facet
Throws:
ConversionException - if the class cannot be converted to an enumerated class given the lanuage profile and the current state of the underlying model.

asUnionClass

public UnionClass asUnionClass()

Answer a view of this class as a union class

Returns:
This class, but viewed as a UnionClass facet
Throws:
ConversionException - if the class cannot be converted to a union class given the lanuage profile and the current state of the underlying model.

asIntersectionClass

public IntersectionClass asIntersectionClass()

Answer a view of this class as an intersection class

Returns:
This class, but viewed as an IntersectionClass facet
Throws:
ConversionException - if the class cannot be converted to an intersection class given the lanuage profile and the current state of the underlying model.

asComplementClass

public ComplementClass asComplementClass()

Answer a view of this class as a complement class

Returns:
This class, but viewed as a ComplementClass facet
Throws:
ConversionException - if the class cannot be converted to a complement class given the lanuage profile and the current state of the underlying model.

asRestriction

public Restriction asRestriction()

Answer a view of this class as a restriction class expression

Returns:
This class, but viewed as a Restriction facet
Throws:
ConversionException - if the class cannot be converted to a restriction given the lanuage profile and the current state of the underlying model.

isEnumeratedClass

public boolean isEnumeratedClass()

Answer true if this class is an enumerated class expression

Returns:
True if this is an enumerated class expression

isUnionClass

public boolean isUnionClass()

Answer true if this class is a union class expression

Returns:
True if this is a union class expression

isIntersectionClass

public boolean isIntersectionClass()

Answer true if this class is an intersection class expression

Returns:
True if this is an intersection class expression

isComplementClass

public boolean isComplementClass()

Answer true if this class is a complement class expression

Returns:
True if this is a complement class expression

isRestriction

public boolean isRestriction()

Answer true if this class is a property restriction

Returns:
True if this is a restriction

convertToEnumeratedClass

public EnumeratedClass convertToEnumeratedClass(RDFList individuals)

Answer a view of this class as an enumeration of the given individuals.

Parameters:
individuals - A list of the individuals that will comprise the permitted values of this class converted to an enumeration
Returns:
This ontology class, converted to an enumeration of the given individuals

convertToIntersectionClass

public IntersectionClass convertToIntersectionClass(RDFList classes)

Answer a view of this class as an intersection of the given classes.

Parameters:
classes - A list of the classes that will comprise the operands of the intersection
Returns:
This ontology class, converted to an intersection of the given classes

convertToUnionClass

public UnionClass convertToUnionClass(RDFList classes)

Answer a view of this class as a union of the given classes.

Parameters:
classes - A list of the classes that will comprise the operands of the union
Returns:
This ontology class, converted to an union of the given classes

convertToComplementClass

public ComplementClass convertToComplementClass(Resource cls)

Answer a view of this class as an complement of the given class.

Parameters:
cls - An ontology classs that will be operand of the complement
Returns:
This ontology class, converted to an complement of the given class

convertToRestriction

public Restriction convertToRestriction(Property prop)

Answer a view of this class as an resriction on the given property.

Parameters:
prop - A property this is the subject of a property restriction class expression
Returns:
This ontology class, converted to a restriction on the given property


Copyright © 2001-2003 Hewlett-Packard. All Rights Reserved.