Class IndividualImpl
- All Implemented Interfaces:
FrontsNode
,Individual
,OntResource
,RDFNode
,Resource
Implementation for the ontology abstraction representing ontology class descriptions.
-
Field Summary
Modifier and TypeFieldDescriptionstatic Implementation
A factory for generating Individual facets from nodes in enhanced graphs.Fields inherited from class org.apache.jena.ontology.impl.OntResourceImpl
KNOWN_LANGUAGES
Fields inherited from class org.apache.jena.rdf.model.impl.ResourceImpl
rdfNodeFactory
-
Constructor Summary
ConstructorDescriptionIndividualImpl
(Node n, EnhGraph g) Construct an individual represented by the given node in the given graph. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addOntClass
(Resource cls) Add the given ontology class as one of the classes to which this individual belongs.Answer an ontology class to which this individual belongs.getOntClass
(boolean direct) Answer an ontology class to which this individual belongs.boolean
hasOntClass
(String uri) Answer true if this individual is a member of the class denoted by the given URI.boolean
hasOntClass
(Resource ontClass) Answer true if this individual is a member of the class denoted by the given ontology class resource.boolean
hasOntClass
(Resource ontClass, boolean direct) Answer true if this individual is a member of the class denoted by the given class resource.<T extends OntClass>
ExtendedIterator<T>listOntClasses
(boolean direct) Answer an iterator over the ontology classes to which this individual belongs.void
removeOntClass
(Resource ontClass) Attempt to remove thisindividual
as a member of the given ontology class.void
setOntClass
(Resource cls) Set the ontology class for this individual, replacing any existing class membership.Methods inherited from class org.apache.jena.ontology.impl.OntResourceImpl
addComment, addComment, addDifferentFrom, addIsDefinedBy, addLabel, addLabel, addRDFType, addSameAs, addSeeAlso, addVersionInfo, asAllDifferent, asAnnotationProperty, asClass, asDataRange, asDatatypeProperty, asIndividual, asObjectProperty, asOntology, asProperty, getCardinality, getComment, getDifferentFrom, getIsDefinedBy, getLabel, getOntModel, getProfile, getPropertyValue, getRDFType, getRDFType, getSameAs, getSeeAlso, getVersionInfo, hasComment, hasComment, hasLabel, hasLabel, hasRDFType, hasRDFType, hasRDFType, hasSeeAlso, hasVersionInfo, isAllDifferent, isAnnotationProperty, isClass, isDataRange, isDatatypeProperty, isDefinedBy, isDifferentFrom, isIndividual, isObjectProperty, isOntLanguageTerm, isOntology, isProperty, 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 class org.apache.jena.rdf.model.impl.ResourceImpl
abort, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addProperty, addProperty, addProperty, addProperty, addProperty, addProperty, addProperty, asLiteral, asResource, begin, commit, getId, getLocalName, getModel, getNameSpace, getProperty, getProperty, getPropertyResourceValue, getRequiredProperty, getRequiredProperty, getStmtTerm, getURI, hasLiteral, hasLiteral, hasLiteral, hasLiteral, hasLiteral, hasLiteral, hasProperty, hasProperty, hasProperty, hasProperty, hasURI, inModel, listProperties, listProperties, listProperties, removeAll, removeProperties, toString, visitWith
Methods inherited from class org.apache.jena.enhanced.EnhNode
as, asNode, canAs, equals, getGraph, hashCode, isAnon, isLiteral, isResource, isStmtResource, isURIResource, isValid, viewAs
Methods inherited from class org.apache.jena.enhanced.Polymorphic
addView, supports
Methods inherited from interface org.apache.jena.graph.FrontsNode
asNode
Methods inherited from interface org.apache.jena.ontology.OntResource
addComment, addComment, addDifferentFrom, addIsDefinedBy, addLabel, addLabel, addRDFType, addSameAs, addSeeAlso, addVersionInfo, asAllDifferent, asAnnotationProperty, asClass, asDataRange, asDatatypeProperty, asIndividual, asObjectProperty, asOntology, asProperty, getCardinality, getComment, getDifferentFrom, getIsDefinedBy, getLabel, getOntModel, getProfile, getPropertyValue, getRDFType, getRDFType, getSameAs, getSeeAlso, getVersionInfo, hasComment, hasComment, hasLabel, hasLabel, hasRDFType, hasRDFType, hasRDFType, hasSeeAlso, hasVersionInfo, isAllDifferent, isAnnotationProperty, isClass, isDataRange, isDatatypeProperty, isDefinedBy, isDifferentFrom, isIndividual, isObjectProperty, isOntLanguageTerm, isOntology, isProperty, 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 org.apache.jena.rdf.model.RDFNode
as, asLiteral, asResource, canAs, getModel, isAnon, isLiteral, isResource, isStmtResource, isURIResource, visitWith
Methods inherited from interface org.apache.jena.rdf.model.Resource
abort, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addProperty, addProperty, addProperty, addProperty, begin, commit, equals, getId, getLocalName, getNameSpace, getProperty, getProperty, getPropertyResourceValue, getRequiredProperty, getRequiredProperty, getStmtTerm, getURI, hasLiteral, hasLiteral, hasLiteral, hasLiteral, hasLiteral, hasLiteral, hasProperty, hasProperty, hasProperty, hasProperty, hasURI, inModel, listProperties, listProperties, listProperties, removeAll, removeProperties, toString
-
Field Details
-
factory
A factory for generating Individual facets from nodes in enhanced graphs. Note: should not be invoked directly by user code: useas()
instead.
-
-
Constructor Details
-
IndividualImpl
Construct an individual represented by the given node in the given graph.
- Parameters:
n
- The node that represents the resourceg
- The enh graph that contains n
-
-
Method Details
-
setOntClass
Set the ontology class for this individual, replacing any existing class membership. Class membership is encoded using the
rdf:type
property. Any existing statements for the RDF type will first be removed.- Specified by:
setOntClass
in interfaceIndividual
- Parameters:
cls
- The RDF resource denoting the new class to which this individual belongs, which will replace any existingrdf:type
property.
-
addOntClass
Add the given ontology class as one of the classes to which this individual belongs. Class membership is encoded using the
rdf:type
property.- Specified by:
addOntClass
in interfaceIndividual
- Parameters:
cls
- An RDF resource denoting an additional class to which this individual belongs.
-
getOntClass
Answer an ontology class to which this individual belongs. If the individual belongs to more than one class, which is common in ontology models using a reasoner, then the return value will be one of the possible values but it is not specified which one. In the case of multiple classes, callers should not rely on the return value being consistent, e.g. across runs, since it may depend on the underlying hash indexes in the model.
This method considers any ontology class for the individual, not just direct classes. It is equivalent to
getOntClass(false)
.- Specified by:
getOntClass
in interfaceIndividual
- Returns:
- A resource denoting the ontology class for this individual, or one of them if more than one is defined.
- Throws:
ConversionException
- if the return value is known to be an ontology class, assuming strict type checking is turned on for the underlyingOntModel
. SeeOntModel.setStrictMode(boolean)
-
getOntClass
Answer an ontology class to which this individual belongs. If the resource belongs to more than one class, which is common in ontology models using a reasoner, then the return value will be one of the possible values but it is not specified which one. In the case of multiple classes, callers should not rely on the return value being consistent, e.g. across runs, since it may depend on the underlying hash indexes in the model.
- Specified by:
getOntClass
in interfaceIndividual
- Parameters:
direct
- Iftrue
, only direct classes are considered. A class is a direct class of thisIndividual
if and only if there is no other resource is both anrdf:type
of this individual and a sub-class of the candidate class.- Returns:
- A resource denoting the ontology class for this individual, or one of them if more than one is defined.
- Throws:
ConversionException
- if the return value is known to be an ontology class, assuming strict type checking is turned on for the underlyingOntModel
. SeeOntModel.setStrictMode(boolean)
-
listOntClasses
Answer an iterator over the ontology classes to which this individual belongs. The members of the iterator will be
OntClass
objects.- Specified by:
listOntClasses
in interfaceIndividual
- Parameters:
direct
- If true, only answer those resources that are direct types of this individual, not the super-classes of the class etc.- Returns:
- An iterator over the set of this individual's classes. Each member
of the iteration will be an
OntClass
.
-
hasOntClass
Answer true if this individual is a member of the class denoted by the given class resource.
- Specified by:
hasOntClass
in interfaceIndividual
- Parameters:
ontClass
- Denotes an ontology class to which this individual may belongdirect
- If true, only consider the direct types of this individual, ignoring the super-classes of the stated types.- Returns:
- True if this individual is a member of the given class, possibly taking the directness constraint into account.
-
hasOntClass
Answer true if this individual is a member of the class denoted by the given ontology class resource. Not limited to only direct class relationships, so this is equivalent to:
hasOntClass( ontClass, false );
- Specified by:
hasOntClass
in interfaceIndividual
- Parameters:
ontClass
- Denotes a class to which this individual may belong- Returns:
- True if this individual has the given class as one of its
rdf:type
's.
-
hasOntClass
Answer true if this individual is a member of the class denoted by the given URI.
- Specified by:
hasOntClass
in interfaceIndividual
- Parameters:
uri
- Denotes the URI of a class to which this value may belong- Returns:
- True if this individual has the given class as one of its
rdf:type
's.
-
removeOntClass
Attempt to remove this
individual
as a member of the given ontology class. This relationship is represented by ardf:type
statement in the underlying model. If this relationship was originally asserted, then removal will always succeed. However, if therdf:type
relationship is entailed by the action of an attached reasoner, it may not be possible to directly remove it. Callers should instead update the assertions and axioms that entail the class membership relationship, and ensure the reasoner gets chance to update the entailments.If this individual is not a member of the given class, the operation has no effect.
- Specified by:
removeOntClass
in interfaceIndividual
- Parameters:
ontClass
- A resource denoting a class that that is to be removed from the set of classes to which this individual belongs
-