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) ; } }
@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(); } }
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 ; }
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 ; }
@Override public Statement getProperty( Resource s, Property p ) { StmtIterator iter = listStatements( s, p, (RDFNode) null ); try { return iter.hasNext() ? iter.nextStatement() : null; } finally { iter.close(); } }
private static List<Statement> getRemovedStmts(Model assertions, Model retractions) { List<Statement> toRemove = new LinkedList<Statement>(); StmtIterator iter = retractions.listStatements(); while(iter.hasNext()){ Statement stmt = iter.nextStatement(); if( stmt.getObject() != null && ! stmt.getObject().isLiteral() && ! assertions.contains(stmt)) toRemove.add( stmt ); } iter.close(); return toRemove; }
/** * Helper method - extracts the truth of a boolean configuration * predicate. * @param predicate the predicate to be tested * @param configuration the configuration node * @return null if there is no setting otherwise a Boolean giving the setting value */ public static Boolean checkBinaryPredicate(Property predicate, Resource configuration) { StmtIterator i = configuration.listProperties(predicate); if (i.hasNext()) { return i.nextStatement().getObject().toString().equalsIgnoreCase( "true" ); } else { return null; } }
private static void addIntersections( Model result, Model schema ) { StmtIterator it = schema.listStatements( ANY, OWL.intersectionOf, ANY ); while (it.hasNext()) addIntersections( result, schema, it.nextStatement() ); }
private List<Model> getSubModels( Assembler a, Resource root, Mode mode ) { List<Model> result = new ArrayList<>(); for (StmtIterator it = root.listProperties( JA.subModel ); it.hasNext();) result.add( a.openModel( it.nextStatement().getResource(), mode ) ); return result; }
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 ; }
@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 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; }
/** * Helper method - extracts the truth of a boolean configuration * predicate. * @param predicate the predicate to be tested * @param configuration the configuration node * @return null if there is no setting otherwise a Boolean giving the setting value */ public static Boolean checkBinaryPredicate(Property predicate, Resource configuration) { StmtIterator i = configuration.listProperties(predicate); if (i.hasNext()) { return i.nextStatement().getObject().toString().equalsIgnoreCase( "true" ); } else { return null; } }