Property p = myModel.getProperty( "http://example.com/foo#p" ); OntProperty op = p.as( OntProperty.class );
/** * <p>Answer true if the given property is a sub-property of this property.</p> * @param prop A property to test. * @param direct If true, only consider the direcly adjacent properties in the * property hierarchy * @return True if the given property is a sub-property of this property. */ @Override public boolean hasSubProperty( Property prop, boolean direct ) { return prop.as( OntProperty.class ).hasSuperProperty( this, direct ); }
/** * <p>Remove the given property from the sub-properties of this property. If this statement * is not true of the current model, nothing happens.</p> * @param prop A property to be removed from the sub-properties of this property * @exception ProfileException If the {@link Profile#SUB_PROPERTY_OF()} property is not supported in the current language profile. */ @Override public void removeSubProperty( Property prop ) { prop.as( OntProperty.class ).removeSuperProperty( this ); }
/** * <p>Answer true if the given property is a sub-property of this property.</p> * @param prop A property to test. * @param direct If true, only consider the direcly adjacent properties in the * property hierarchy * @return True if the given property is a sub-property of this property. */ @Override public boolean hasSubProperty( Property prop, boolean direct ) { return prop.as( OntProperty.class ).hasSuperProperty( this, direct ); }
/** * <p>Add a sub-property of this property.</p> * @param prop A property that is a sub-property of this property. * @exception ProfileException If the {@link Profile#SUB_PROPERTY_OF()} property is not supported in the current language profile. */ @Override public void addSubProperty( Property prop ) { prop.as( OntProperty.class ).addSuperProperty( this ); }
/** * <p>Add a sub-property of this property.</p> * @param prop A property that is a sub-property of this property. * @exception ProfileException If the {@link Profile#SUB_PROPERTY_OF()} property is not supported in the current language profile. */ @Override public void addSubProperty( Property prop ) { prop.as( OntProperty.class ).addSuperProperty( this ); }
/** * <p>Remove the given property from the sub-properties of this property. If this statement * is not true of the current model, nothing happens.</p> * @param prop A property to be removed from the sub-properties of this property * @exception ProfileException If the {@link Profile#SUB_PROPERTY_OF()} property is not supported in the current language profile. */ @Override public void removeSubProperty( Property prop ) { prop.as( OntProperty.class ).removeSuperProperty( this ); }
/** * <p> * Answer a resource representing an generic property in this model. Effectively * this method is an alias for {@link #createProperty( String )}, except that * the return type is {@link OntProperty}, which allow more convenient access to * a property's position in the property hierarchy, domain, range, etc. * </p> * * @param uri The uri for the property. May not be null. * @return An OntProperty resource. */ @Override public OntProperty createOntProperty( String uri ) { Property p = createProperty( uri ); p.addProperty( RDF.type, getProfile().PROPERTY() ); return p.as( OntProperty.class ); }
@Override public void ontTest( OntModel m ) { String lang = m_owlLang ? "owl" : "rdfs" ; String fileName = "file:testing/ontology/" + lang + "/Property/test.rdf"; m.read( fileName ); OntProperty p = m.getProperty( NS, "p" ).as( OntProperty.class ); OntProperty s = m.getProperty( NS, "s" ).as( OntProperty.class ); assertTrue( "p should have inv prop s", p.isInverseOf( s ) ); } },
@Override public void ontTest( OntModel m ) { String lang = m_owlLang ? "owl" : "rdfs" ; String fileName = "file:testing/ontology/" + lang + "/Property/test.rdf"; m.read( fileName ); OntProperty p = m.getProperty( NS, "p" ).as( OntProperty.class ); OntProperty r = m.getProperty( NS, "r" ).as( OntProperty.class ); assertTrue( "p should have equiv prop r", p.hasEquivalentProperty( r ) ); } },
@Override public void ontTest( OntModel m ) { String lang = m_owlLang ? "owl" : "rdfs" ; String fileName = "file:testing/ontology/" + lang + "/Property/test.rdf"; m.read( fileName ); OntProperty p = m.getProperty( NS, "p" ).as( OntProperty.class ); OntProperty r = m.getProperty( NS, "r" ).as( OntProperty.class ); assertTrue( "p should have equiv prop r", p.hasEquivalentProperty( r ) ); } },
@Override public void ontTest( OntModel m ) { String lang = m_owlLang ? "owl" : "rdfs" ; String fileName = "file:testing/ontology/" + lang + "/Property/test.rdf"; m.read( fileName ); OntProperty p = m.getProperty( NS, "p" ).as( OntProperty.class ); OntProperty s = m.getProperty( NS, "s" ).as( OntProperty.class ); assertTrue( "p should have inv prop s", p.isInverseOf( s ) ); } },
@Override public void ontTest( OntModel m ) { String lang = m_owlLang ? "owl" : "rdfs" ; String fileName = "file:testing/ontology/" + lang + "/Property/test.rdf"; m.read( fileName ); OntProperty p = m.getProperty( NS, "p" ).as( OntProperty.class ); OntProperty q = m.getProperty( NS, "q" ).as( OntProperty.class ); iteratorTest( p.listSuperProperties(), new Object[] {q} ); iteratorTest( q.listSubProperties(), new Object[] {p} ); } },
@Override public void ontTest( OntModel m ) { String lang = m_owlLang ? "owl" : "rdfs" ; String fileName = "file:testing/ontology/" + lang + "/Property/test.rdf"; m.read( fileName ); OntProperty p = m.getProperty( NS, "p" ).as( OntProperty.class ); OntProperty q = m.getProperty( NS, "q" ).as( OntProperty.class ); iteratorTest( p.listSuperProperties(), new Object[] {q} ); iteratorTest( q.listSubProperties(), new Object[] {p} ); } },
/** * <p>Assert that this property is super-property of the given property. Any existing * statements for <code>subPropertyOf</code> on <code>prop</code> will be removed.</p> * @param prop The property that is a sub-property of this property * @exception ProfileException If the {@link Profile#SUB_PROPERTY_OF()} property is not supported in the current language profile. */ @Override public void setSubProperty( Property prop ) { // first we have to remove all of the inverse sub-prop links checkProfile( getProfile().SUB_PROPERTY_OF(), "SUB_PROPERTY_OF" ); for (StmtIterator i = getModel().listStatements( null, getProfile().SUB_PROPERTY_OF(), this ); i.hasNext(); ) { i.removeNext(); } prop.as( OntProperty.class ).addSuperProperty( this ); }
/** * <p>Assert that this property is super-property of the given property. Any existing * statements for <code>subPropertyOf</code> on <code>prop</code> will be removed.</p> * @param prop The property that is a sub-property of this property * @exception ProfileException If the {@link Profile#SUB_PROPERTY_OF()} property is not supported in the current language profile. */ @Override public void setSubProperty( Property prop ) { // first we have to remove all of the inverse sub-prop links checkProfile( getProfile().SUB_PROPERTY_OF(), "SUB_PROPERTY_OF" ); for (StmtIterator i = getModel().listStatements( null, getProfile().SUB_PROPERTY_OF(), this ); i.hasNext(); ) { i.removeNext(); } prop.as( OntProperty.class ).addSuperProperty( this ); }
@Override public void ontTest( OntModel m ) { String lang = m_owlLang ? "owl" : "rdfs" ; String fileName = "file:testing/ontology/" + lang + "/Property/test.rdf"; m.read( fileName ); OntProperty p = m.getProperty( NS, "p" ).as( OntProperty.class ); OntClass B = m.getResource( NS + "ClassB").as( OntClass.class); assertTrue( "p should have domain B", p.hasRange( B ) ); } },
@Override public void ontTest( OntModel m ) { String lang = m_owlLang ? "owl" : "rdfs" ; String fileName = "file:testing/ontology/" + lang + "/Property/test.rdf"; m.read( fileName ); OntProperty p = m.getProperty( NS, "p" ).as( OntProperty.class ); OntClass B = m.getResource( NS + "ClassB").as( OntClass.class); assertTrue( "p should have domain B", p.hasRange( B ) ); } },
@Override public void ontTest( OntModel m ) { String lang = m_owlLang ? "owl" : "rdfs" ; String fileName = "file:testing/ontology/" + lang + "/Property/test.rdf"; m.read( fileName ); OntProperty p = m.getProperty( NS, "p" ).as( OntProperty.class ); OntClass A = m.getResource( NS + "ClassA").as( OntClass.class); assertTrue( "p should have domain A", p.hasDomain( A ) ); } },
@Override public void ontTest( OntModel m ) { String lang = m_owlLang ? "owl" : "rdfs" ; String fileName = "file:testing/ontology/" + lang + "/Property/test.rdf"; m.read( fileName ); OntProperty p = m.getProperty( NS, "p" ).as( OntProperty.class ); OntClass A = m.getResource( NS + "ClassA").as( OntClass.class); assertTrue( "p should have domain A", p.hasDomain( A ) ); } },