Author: andy Date: Tue Nov 5 18:28:53 2013 New Revision: 1539095 URL: http://svn.apache.org/r1539095 Log: Add listResources convenience operation.
Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/util/junit/TestUtils.java Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/util/junit/TestUtils.java URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/util/junit/TestUtils.java?rev=1539095&r1=1539094&r2=1539095&view=diff ============================================================================== --- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/util/junit/TestUtils.java (original) +++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/util/junit/TestUtils.java Tue Nov 5 18:28:53 2013 @@ -18,10 +18,11 @@ package com.hp.hpl.jena.util.junit; -import com.hp.hpl.jena.rdf.model.Literal; -import com.hp.hpl.jena.rdf.model.Property; -import com.hp.hpl.jena.rdf.model.RDFNode; -import com.hp.hpl.jena.rdf.model.Resource; +import java.util.ArrayList ; +import java.util.Collection ; +import java.util.List ; + +import com.hp.hpl.jena.rdf.model.* ; public class TestUtils { @@ -39,6 +40,21 @@ public class TestUtils throw new TestException("Manifest problem (not a Resource): "+n+" => "+p) ; } + public static Collection<Resource> listResources(Resource r, Property p) + { + if ( r == null ) + return null ; + List<Resource> x = new ArrayList<Resource>() ; + StmtIterator sIter = r.listProperties(p) ; + for ( ; sIter.hasNext() ; ) { + RDFNode n = sIter.next().getObject() ; + if ( ! ( n instanceof Resource ) ) + throw new TestException("Manifest problem (not a Resource): "+n+" => "+p) ; + x.add((Resource)n) ; + } + return x ; + } + public static String getLiteral(Resource r, Property p) { if ( r == null )