/** * <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. */ @Override public void addEquivalentClass( Resource cls ) { addPropertyValue( getProfile().EQUIVALENT_CLASS(), "EQUIVALENT_CLASS", cls ); }
/** * <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 */ @Override public IntersectionClass convertToIntersectionClass( RDFList classes ) { setPropertyValue( getProfile().INTERSECTION_OF(), "INTERSECTION_OF", classes ); return as( IntersectionClass.class ); }
/** * <p>Answer true if this class is a property restriction</p> * @return True if this is a restriction */ @Override public boolean isRestriction() { checkProfile( getProfile().RESTRICTION(), "RESTRICTION" ); return hasProperty( getProfile().ON_PROPERTY() ) || hasProperty( RDF.type, getProfile().RESTRICTION() ); }
/** * <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 */ @Override public Restriction convertToRestriction( Property prop ) { if (!hasRDFType( getProfile().RESTRICTION(), "RESTRICTION", false )) { setRDFType( getProfile().RESTRICTION() ); } setPropertyValue( getProfile().ON_PROPERTY(), "ON_PROPERTY", prop ); return as( Restriction.class ); }
/** * <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. */ @Override public void setSubClass( Resource cls ) { // first we have to remove all of the inverse sub-class links checkProfile( getProfile().SUB_CLASS_OF(), "SUB_CLASS_OF" ); for (StmtIterator i = getModel().listStatements( null, getProfile().SUB_CLASS_OF(), this ); i.hasNext(); ) { i.removeNext(); } cls.as( OntClass.class ).addSuperClass( this ); }
if (!direct) { return hasPropertyValue( getProfile().SUB_CLASS_OF(), "SUB_CLASS_OF", cls ); if (getGraph() instanceof InfGraph) { ig = (InfGraph) getGraph(); else if (getGraph() instanceof OntModel) { OntModel m = (OntModel) getGraph(); if (m.getGraph() instanceof InfGraph) { ig = (InfGraph) m.getGraph(); return hasPropertyValue( ReasonerVocabulary.directSubClassOf, "direct sub-class", cls ); return hasSuperClassDirect(cls);
for (StmtIterator i = getModel().listStatements( p, getProfile().DOMAIN(), (RDFNode) null ); i.hasNext(); ) { Resource domain = i.nextStatement().getResource(); if (!(domain.equals( getProfile().THING() ) || domain.equals( RDFS.Resource ))) { else if (!canProveSuperClass( domain )) { return seenDirect || (isGlobal && isHierarchyRoot());
/** * <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. */ @Override public void removeSuperClass( Resource cls ) { removePropertyValue( getProfile().SUB_CLASS_OF(), "SUB_CLASS_OF", 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.</p> * @return A super-class of this class * @exception ProfileException If the {@link Profile#SUB_CLASS_OF()} property is not supported in the current language profile. */ @Override public OntClass getSuperClass() { return objectAs( getProfile().SUB_CLASS_OF(), "SUB_CLASS_OF", OntClass.class ); }
/** * <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. */ @Override public void setSuperClass( Resource cls ) { setPropertyValue( getProfile().SUB_CLASS_OF(), "SUB_CLASS_OF", cls ); }
/** * <p>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 {@link OntClass}. * See {@link #listSubClasses( boolean )} for a full explanation of the <em>direct</em> * parameter. * </p> * * @param 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. * @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. */ @Override public ExtendedIterator<OntClass> listSuperClasses( boolean direct ) { // Eclispe Oxygen (July 2017) generates a warning on use of "this::equals" in filterDrop. OntClass ontClass = this; return listDirectPropertyValues( getProfile().SUB_CLASS_OF(), "SUB_CLASS_OF", OntClass.class, getProfile().SUB_CLASS_OF(), direct, false ) .filterDrop( ontClass::equals ).filterKeep( new UniqueFilter<>()); }
public boolean isHierarchyRoot() { if (equals( getProfile().NOTHING() )) { return false; ExtendedIterator<OntClass> i = listSuperClasses( true ); try { if (!(sup.equals( getProfile().THING() ) || sup.equals( RDFS.Resource ) || sup.equals( this )))
/** * <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. */ @Override public ExtendedIterator<OntClass> listDisjointWith() { return listAs( getProfile().DISJOINT_WITH(), "DISJOINT_WITH", OntClass.class ).filterKeep( new UniqueFilter<OntClass>() ) ; }
/** * <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. */ @Override public boolean hasEquivalentClass( Resource cls ) { return hasPropertyValue( getProfile().EQUIVALENT_CLASS(), "EQUIVALENT_CLASS", cls ); }
/** * <p>Answer a view of this class as an intersection class</p> * @return This class, but viewed as an IntersectionClass node * @exception ConversionException if the class cannot be converted to an intersection class * given the lanuage profile and the current state of the underlying model. */ @Override public IntersectionClass asIntersectionClass() { return as( IntersectionClass.class ); }
/** * <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 */ @Override public Individual createIndividual() { return ((OntModel) getModel()).createIndividual( this ); }
OntModel mOnt = (OntModel) getModel(); Profile prof = mOnt.getProfile(); ExtendedIterator<Statement> pi = mOnt.listStatements( null, RDF.type, getProfile().PROPERTY() );
OntModel om = (OntModel) getModel(); if (om.getReasoner() != null) { if (om.getReasoner() return hasSuperClass( sup );
/** * <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. */ @Override public boolean hasSubClass() { return getSubClass() != null; }
@Override public EnhNode wrap( Node n, EnhGraph eg ) { if (canWrap( n, eg )) { return new OntClassImpl( n, eg ); } else { throw new ConversionException( "Cannot convert node " + n.toString() + " to OntClass: it does not have rdf:type owl:Class or equivalent"); } }