/** * Add all statements from Iterator into collection that match the given subj,prop,obj pattern * @param matches Collection of statements to which matches are added * @param statements Iterator of statements to determine matches * @param s Subject of statements to match, or null for any * @param p Predicate of statements to match, or null for any * @param o Object of statements to match, or null for any */ public static void addAllMatches(Collection<Statement> matches,Iterator<Statement> statements,Resource s,URI p,Value o) { while(statements.hasNext()) { Statement stmt=statements.next(); if(match(stmt,s,p,o,null)) { matches.add(stmt); } } Iterators.closeCloseable(statements); }