/** * <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 */ @Override public Individual createIndividual( String uri ) { return ((OntModel) getModel()).createIndividual( uri, this ); }
/** * <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 */ @Override public Individual createIndividual( String uri ) { return ((OntModel) getModel()).createIndividual( uri, this ); }
/** * <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 ); }
/** * <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 */ @Override public void dropIndividual( Resource individual ) { getModel().remove( individual, RDF.type, this ); }
/** * <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 */ @Override public void dropIndividual( Resource individual ) { getModel().remove( individual, RDF.type, this ); }
/** * <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 ); }
/** * <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. */ @Override public boolean hasSubClass( Resource cls, boolean direct ) { if (getModel() instanceof OntModel && (cls.getModel() == null || !(cls.getModel() instanceof OntModel))) { // could be outside an ontmodel if a constant cls = cls.inModel( getModel() ); } return cls.as( OntClass.class ).hasSuperClass( this, direct ); }
OntModel om = (OntModel) getModel(); if (om.getReasoner() != null) { if (om.getReasoner()
OntModel om = (OntModel) getModel(); if (om.getReasoner() != null) { if (om.getReasoner()
/** * <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. */ @Override public boolean hasSubClass( Resource cls, boolean direct ) { if (getModel() instanceof OntModel && (cls.getModel() == null || !(cls.getModel() instanceof OntModel))) { // could be outside an ontmodel if a constant cls = cls.inModel( getModel() ); } return cls.as( OntClass.class ).hasSuperClass( this, direct ); }
/** * <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 */ @Override public ExtendedIterator<Individual> listInstances( final boolean direct ) { return getModel() .listStatements( null, RDF.type, this ) .mapWith( s -> s.getSubject().as( Individual.class ) ) .filterKeep( o -> o.hasRDFType( OntClassImpl.this, direct )) .filterKeep( new UniqueFilter<Individual>()); }
/** * <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 */ @Override public ExtendedIterator<Individual> listInstances( final boolean direct ) { return getModel() .listStatements( null, RDF.type, this ) .mapWith( s -> s.getSubject().as( Individual.class ) ) .filterKeep( o -> o.hasRDFType( OntClassImpl.this, direct )) .filterKeep( new UniqueFilter<Individual>()); }
/** * <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 ); }
/** * <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 ); }
/** * <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. */ @Override public OntClass getSubClass() { checkProfile( getProfile().SUB_CLASS_OF(), "SUB_CLASS_OF" ); StmtIterator i = getModel().listStatements( null, getProfile().SUB_CLASS_OF(), this ); try { if (i.hasNext()) { return i.nextStatement() .getSubject() .as( OntClass.class ); } else { return null; } } finally { i.close(); } }
for (StmtIterator i = getModel().listStatements( p, getProfile().DOMAIN(), (RDFNode) null ); i.hasNext(); ) { Resource domain = i.nextStatement().getResource();
/** * <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. */ @Override public OntClass getSubClass() { checkProfile( getProfile().SUB_CLASS_OF(), "SUB_CLASS_OF" ); StmtIterator i = getModel().listStatements( null, getProfile().SUB_CLASS_OF(), this ); try { if (i.hasNext()) { return i.nextStatement() .getSubject() .as( OntClass.class ); } else { return null; } } finally { i.close(); } }
for (StmtIterator i = getModel().listStatements( p, getProfile().DOMAIN(), (RDFNode) null ); i.hasNext(); ) { Resource domain = i.nextStatement().getResource();
OntModel mOnt = (OntModel) getModel(); Profile prof = mOnt.getProfile();
OntModel mOnt = (OntModel) getModel(); Profile prof = mOnt.getProfile();