@Test public void testComplexQuery() throws Exception { String text = "PREFIX foaf: <" + FOAF.NAMESPACE + ">\n" + "PREFIX ex: <" + EX + ">\n" + "SELECT * WHERE {\n" + " { ?x a foaf:Person } UNION {\n" + " GRAPH ex:Graph1 { ?y a foaf:Person }\n" + " } .\n" + " GRAPH ex:Graph2 {\n" + " ?x foaf:knows ?y .\n" + " }\n ." + " OPTIONAL { ?x foaf:mbox ?m } .\n" + " FILTER (?x != ?y) .\n" + "}"; ParsedQuery query = new SPARQLParser().parseQuery(text, null); AntecedentVisitor visitor = new AntecedentVisitor(); query.getTupleExpr().visit(visitor); Set<StatementPattern> expected = Sets.newHashSet( new StatementPattern(Scope.NAMED_CONTEXTS, new Var("y"), c(RDF.TYPE), c(FOAF.PERSON), c(G1)), new StatementPattern(new Var("x"), c(RDF.TYPE), c(FOAF.PERSON)), new StatementPattern(Scope.NAMED_CONTEXTS, new Var("x"), c(FOAF.KNOWS), new Var("y"), c(G2)), new StatementPattern(new Var("x"), c(FOAF.MBOX), new Var("m"))); Assert.assertEquals(expected, visitor.getAntecedents()); }
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);  }