WhereHandler implements Handler { public Node list(Object... objs) { Node retval = NodeFactory.createBlankNode(); Node lastObject = retval; for (int i = 0; i < objs.length; i++) { Node n = Converters.makeNode(objs[i], query.getPrefixMapping()); addWhere(new TriplePath(new Triple(lastObject, RDF.first.asNode(), n))); if (i + 1 < objs.length) { Node nextObject = NodeFactory.createBlankNode(); addWhere(new TriplePath(new Triple(lastObject, RDF.rest.asNode(), nextObject))); lastObject = nextObject; } else { addWhere(new TriplePath(new Triple(lastObject, RDF.rest.asNode(), RDF.nil.asNode()))); } } return retval; } WhereHandler(Query query);  WhereHandler(); Element getQueryPattern(); Query getQuery(); void addAll(WhereHandler whereHandler); Element getElement(); ElementGroup getClause(); void addWhere(TriplePath t); void addWhere(ValuesHandler values); void addOptional(TriplePath t); void addOptional(WhereHandler whereHandler); void addFilter(String expression); void addFilter(Expr expr); void addSubQuery(AbstractQueryBuilder<?> subQuery); ElementSubQuery makeSubQuery(AbstractQueryBuilder<?> subQuery); void addUnion(AbstractQueryBuilder<?> subQuery); void addGraph(Node graph, WhereHandler subQuery); void addGraph(Node graph, TriplePath subQuery); void addBind(Expr expr, Var var); void addBind(String expression, Var var); @Override void setVars(Map<Var, Node> values); @Override void build(); Node list(Object... objs); void addMinus( AbstractQueryBuilder<?> qb ); void addValueVar(PrefixMapping prefixMapping, Object var); void addValueVar(PrefixMapping prefixMapping, Object var, Object... objects); void addValueVars(PrefixMapping prefixMapping, Map<?,K> dataTable); void addValueRow(PrefixMapping prefixMapping, Object... values); void addValueRow(PrefixMapping prefixMapping, Collection<?> values); List<Var> getValuesVars(); Map<Var,List<Node>> getValuesMap(); void clearValues();  }
@Test public void testList() { Node n = handler.list("<one>", "?var", "'three'"); Node one = NodeFactory.createURI("one"); Node two = Var.alloc("var").asNode(); Node three = NodeFactory.createLiteral( "three"); ElementPathBlock epb = new ElementPathBlock(); Node firstObject = NodeFactory.createBlankNode(); Node secondObject = NodeFactory.createBlankNode(); Node thirdObject = NodeFactory.createBlankNode(); epb.addTriplePath( new TriplePath( new Triple( firstObject, RDF.first.asNode(), one))); epb.addTriplePath( new TriplePath( new Triple( firstObject, RDF.rest.asNode(), secondObject))); epb.addTriplePath( new TriplePath( new Triple( secondObject, RDF.first.asNode(), two))); epb.addTriplePath( new TriplePath( new Triple( secondObject, RDF.rest.asNode(), thirdObject))); epb.addTriplePath( new TriplePath( new Triple( thirdObject, RDF.first.asNode(), three))); epb.addTriplePath( new TriplePath( new Triple( thirdObject, RDF.rest.asNode(), RDF.nil.asNode()))); WhereValidator visitor = new WhereValidator( epb ); query.getQueryPattern().visit( visitor ); assertTrue( visitor.matching ); assertTrue(n.isBlank()); }