StmtIterator nameIterator = r.listProperties(VCARD4.hasName); while (nameIterator.hasNext()) { Statement nameStatement = nameIterator.nextStatement(); Resource structuredNameResource = nameStatement.getResource(); StructuredName structuredName = new StructuredName(); structuredName.setGiven(structuredNameResource.getProperty(VCARD4.given_name).getString()); structuredNameResource.listProperties(VCARD4.hasHonorificPrefix).forEachRemaining( prefix -> structuredName.getPrefixes().add(prefix.getString()) ); structuredNameResource.listProperties(VCARD4.hasHonorificSuffix).forEachRemaining( suffix -> structuredName.getSuffixes().add(suffix.getString()) ); if (emailResource.isResource()) { Statement valueStatement = getValueStatement(emailResource); String mailTo = valueStatement.getObject().toString(); Matcher matcher = MAIL_TO_PATTERN.matcher(mailTo); checkState(matcher.matches(), "%s mail to address doesn't match", mailTo); if (telephoneResource.isResource()) { Statement valueStatement = getValueStatement(telephoneResource); String telephoneNumber = valueStatement.getObject().toString(); Telephone telephoneObject = new Telephone(telephoneNumber); if (telephoneResource.hasProperty(RDF.type)) {
protected int countProperties(Resource r) { int numProp = 0 ; StmtIterator sIter = r.listProperties() ; for ( ; sIter.hasNext() ; ) { sIter.nextStatement() ; numProp++ ; } sIter.close() ; return numProp ; }
protected int countArcsTo(Property prop, Resource resource) { int numArcs = 0 ; StmtIterator sIter = resource.getModel().listStatements(null, prop, resource) ; for ( ; sIter.hasNext() ; ) { sIter.nextStatement() ; numArcs++ ; } sIter.close() ; return numArcs ; }
/** Load all the classes which are objects of any (t, ja:assembler, S) statements in <code>m</code>. <code>group.implementWIth(t,c)</code> is called for each statement, where <code>c</code> is an instance of the class named by <code>S</code>. The order in which the classes are loaded is not specified, and loading stops immediately if any class cannot be loaded. */ public static void loadAssemblerClasses( AssemblerGroup group, Model m ) { StmtIterator it = m.listStatements( ANY, JA.assembler, ANY ); while (it.hasNext()) loadAssemblerClass( group, it.nextStatement() ); }
private static void closureNoTest(Resource r, Model closureBlob, Collection<Resource> visited, ClosureTest test) { visited.add(r) ; StmtIterator sIter = r.listProperties() ; for ( ; sIter.hasNext() ; ) { Statement stmt = sIter.nextStatement() ; closure(stmt, closureBlob, visited, test) ; } }
public static Resource getResourcePropertyWithType(Resource subject, Property predicate, Resource type) { StmtIterator it = subject.listProperties(predicate); while(it.hasNext()) { Statement s = it.next(); if(s.getObject().isResource() && JenaUtil.hasIndirectType(s.getResource(), type)) { it.close(); return s.getResource(); } } return null; }
@Override public Statement getProperty( Resource s, Property p, String lang) { StmtIterator iter = listStatements( s, p, null, lang ); try { return iter.hasNext() ? iter.nextStatement() : null; } finally { iter.close(); } }
public static void addValueNodes(RDFNode focusNode, Property predicate, Collection<RDFNode> results) { if(focusNode instanceof Resource) { StmtIterator it = ((Resource)focusNode).listProperties(predicate); while(it.hasNext()) { results.add(it.next().getObject()); } } }
private long countOfStatements( List<Model> models){ long count =0; for( Model m : models){ StmtIterator it = m.listStatements(); while( it.hasNext()){ it.next(); count++; } it.close(); } return count; }
public static boolean exactlyOneProperty(Resource r, Property p) { StmtIterator sIter = r.listProperties(p) ; try { if ( !sIter.hasNext() ) throw new PropertyRequiredException(r, p) ; sIter.next() ; if ( sIter.hasNext() ) throw new NotUniqueException(r, p) ; } finally { sIter.close() ; } return true ; }
public void testRemoveProperties() { r.removeProperties(); Assert.assertEquals(false, model .listStatements(r, null, (RDFNode) null).hasNext()); }
public static URI findFirstObjectUri(Model model, Property property, RDFNode object, boolean allowMultiple, boolean allowNone) { URI retVal = null; StmtIterator it = model.listStatements(null, property, object); if (!it.hasNext() && !allowNone) throw new IllegalArgumentException("expecting at least one triple"); if (it.hasNext()) { retVal = URI.create(it.nextStatement().getObject().asResource().toString()); } if (!allowMultiple && it.hasNext()) throw new IllegalArgumentException("not expecting more than one triple"); return retVal; }
public static List<RDFNode> multiValue(Resource r, Property p) { List<RDFNode> values = new ArrayList<>() ; StmtIterator sIter = r.listProperties(p) ; while (sIter.hasNext()) { Statement s = sIter.nextStatement() ; values.add(s.getObject()) ; } return values ; }
/** Load all the classes which are objects of any (t, ja:assembler, S) statements in <code>m</code>. <code>group.implementWIth(t,c)</code> is called for each statement, where <code>c</code> is an instance of the class named by <code>S</code>. The order in which the classes are loaded is not specified, and loading stops immediately if any class cannot be loaded. */ public static void loadAssemblerClasses( AssemblerGroup group, Model m ) { StmtIterator it = m.listStatements( ANY, JA.assembler, ANY ); while (it.hasNext()) loadAssemblerClass( group, it.nextStatement() ); }
protected void addExternalContents( List<Content> contents, FileManager fm, Resource root ) { StmtIterator it = root.listProperties( JA.externalContent ); while (it.hasNext()) contents.add( objectAsContent( fm, it.nextStatement() ) ); }
protected int countProperties(Resource r, Property p) { int numProp = 0 ; StmtIterator sIter = r.listProperties(p) ; for ( ; sIter.hasNext() ; ) { sIter.nextStatement() ; numProp++ ; } sIter.close() ; return numProp ; }
public static Resource getResourcePropertyWithType(Resource subject, Property predicate, Resource type) { StmtIterator it = subject.listProperties(predicate); while(it.hasNext()) { Statement s = it.next(); if(s.getObject().isResource() && JenaUtil.hasIndirectType(s.getResource(), type)) { it.close(); return s.getResource(); } } return null; }
@Override public Statement getProperty( Resource s, Property p, String lang) { StmtIterator iter = listStatements( s, p, null, lang ); try { return iter.hasNext() ? iter.nextStatement() : null; } finally { iter.close(); } }