/** * <p>Answer a resource presenting the {@link OntResource} facet, which * corresponds to the given resource but attached to this model.</p> * @param res An existing resource * @return An {@link OntResource} attached to this model that has the same URI * or anonID as the given resource */ @Override public OntResource getOntResource( Resource res ) { return res.inModel( this ).as( OntResource.class ); }
/** * <p>Add a sub-class of this class.</p> * @param cls A 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 addSubClass( Resource cls ) { cls.as( OntClass.class ).addSuperClass( this ); }
/** * <p>Answer a resource presenting the {@link OntResource} facet, which * corresponds to the given resource but attached to this model.</p> * @param res An existing resource * @return An {@link OntResource} attached to this model that has the same URI * or anonID as the given resource */ @Override public OntResource getOntResource( Resource res ) { return res.inModel( this ).as( OntResource.class ); }
/** * <p>Remove the given class from the sub-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 sub-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 removeSubClass( Resource cls ) { (cls.as( OntClass.class)).removeSuperClass( this ); }
/** Answer a (the) new empty list Until this is made the object or subject in the model, it will not appear in a written form. @return An RDF-encoded list of no elements (ie nil) */ @Override public RDFList createList() { return getResource( RDF.nil.getURI() ).as( RDFList.class ); }
/** * <p>Answer an iterator over all of the individuals that are declared to be distinct by * this AllDifferent declaration. Each element of the iterator will be an {@link OntResource}.</p> * @return An iterator over distinct individuals. * @exception ProfileException If the {@link Profile#DISTINCT_MEMBERS()} property is not supported in the current language profile. */ @Override public ExtendedIterator<? extends OntResource> listDistinctMembers() { return getDistinctMembers().mapWith( o -> ((Resource) o).as( OntResource.class )); }
public void testDoesNotReify( final String title, final Resource r ) { try { r.as(ReifiedStatement.class); Assert.fail(title + " (" + r + ")"); } catch (final DoesNotReifyException e) { /* that's what we expect */ } }
/** * Test that a non-literal node can be as'ed into a resource */ public void testCannotAsNonLiteral() { ModelHelper.resource(model, "plumPie").as(Resource.class); }
/** * Test that a non-literal node can be as'ed into a resource */ public void testCannotAsNonLiteral() { ModelHelper.resource(model, "plumPie").as(Resource.class); }
private void incrementCurrent() { if (!endOfList()) { current = current.getRequiredProperty(RDF.rest).getResource() .as(RDFList.class); } }
/** * <p>Answer a new empty list. This method overrides the list create method in ModelCom, * to allow both DAML and RDFS lists to be created.</p> * @return An RDF-encoded list of no elements, using the current language profile */ @Override public RDFList createList() { Resource list = getResource( getProfile().NIL().getURI() ); return list.as( RDFList.class ); }
private void testNotReifying( final Model m, final String uri ) { try { m.createResource(uri).as(ReifiedStatement.class); Assert.fail("there should be no reifiedStatement for " + uri); } catch (final DoesNotReifyException e) { /* that's what we require */ } }
/** * <p>Answer an iterator over the properties that are defined to be inverses of this property.</p> * @return An iterator over the properties that declare themselves the <code>inverseOf</code> this property. */ @Override public ExtendedIterator<OntProperty> listInverse() { return getModel().listStatements( null, getProfile().INVERSE_OF(), this ).mapWith( s -> s.getSubject().as( OntProperty.class ) ); }
/** * <p>Answer an iterator over the properties that are defined to be inverses of this property.</p> * @return An iterator over the properties that declare themselves the <code>inverseOf</code> this property. */ @Override public ExtendedIterator<OntProperty> listInverse() { return getModel().listStatements( null, getProfile().INVERSE_OF(), this ).mapWith( s -> s.getSubject().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 ); OntClass A = m.getResource( NS + "ClassA").as( OntClass.class); assertTrue( "p should have domain A", p.hasDomain( A ) ); } },
public void testAsToOwnClassWithNoModel() { Resource r = ResourceFactory.createResource(); assertEquals( null, r.getModel() ); assertTrue( r.canAs( Resource.class ) ); assertSame( r, r.as( Resource.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 ); OntClass B = m.getResource( NS + "ClassB").as( OntClass.class); assertTrue( "p should have domain B", p.hasRange( B ) ); } },
protected RDFList getListRoot( final Model m ) { final Resource root = m.getResource(TestList.NS + "root"); Assert.assertNotNull("Root resource should not be null", root); final Resource listHead = root.getRequiredProperty( m.getProperty(TestList.NS + "p")).getResource(); final RDFList l = listHead.as(RDFList.class); Assert.assertNotNull("as(RDFList) should not return null for root", l); return l; }
@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 ) { // class is defined (differently) in every profile OntResource or = m.getProfile().CLASS().inModel(m).as( OntResource.class ); assertTrue( "should be a lang term", or.isOntLanguageTerm() ); or = m.createOntResource( "http://foo/bar" ); assertFalse( "should not be a lang term", or.isOntLanguageTerm() ); } },