@Test public void testBNodeQuery() throws Exception { String text = "PREFIX foaf: <" + FOAF.NAMESPACE + ">\n" + "SELECT * WHERE {\n" + " ?x a [ rdfs:subClassOf foaf:Person ] .\n" + " ?x foaf:knows ?y .\n" + "}"; ParsedQuery query = new SPARQLParser().parseQuery(text, null); AntecedentVisitor visitor = new AntecedentVisitor(); query.getTupleExpr().visit(visitor); Set<StatementPattern> actual = visitor.getAntecedents(); Assert.assertEquals(3, actual.size()); StatementPattern knows = new StatementPattern(new Var("x"), c(FOAF.KNOWS), new Var("y")); Assert.assertTrue(actual.remove(knows)); Assert.assertTrue(actual.removeIf(sp -> { return sp.getSubjectVar().equals(new Var("x")) && RDF.TYPE.equals(sp.getPredicateVar().getValue()) && sp.getObjectVar().getValue() == null; })); Assert.assertTrue(actual.removeIf(sp -> { return sp.getSubjectVar().getValue() == null && RDFS.SUBCLASSOF.equals(sp.getPredicateVar().getValue()) && FOAF.PERSON.equals(sp.getObjectVar().getValue()); })); }
public Set<StatementPattern> getAntecedents() { return antecedentStatementPatterns; }
AntecedentVisitor extends AbstractQueryModelVisitor<RuntimeException> { public Set<StatementPattern> getAntecedents() { return antecedentStatementPatterns; } }
AntecedentVisitor extends AbstractQueryModelVisitor<RuntimeException> { public Set<StatementPattern> getAntecedents() { return antecedentStatementPatterns; }  }
AntecedentVisitor extends AbstractQueryModelVisitor<RuntimeException> { public Set<StatementPattern> getAntecedents() { return antecedentStatementPatterns; }  Set<StatementPattern> getAntecedents(); @Override void meet(StatementPattern sp); }
AntecedentVisitor extends AbstractQueryModelVisitor<RuntimeException> { public Set<StatementPattern> getAntecedents() { return antecedentStatementPatterns; }  Set<StatementPattern> getAntecedents(); @Override void meet(StatementPattern sp);  }