/** * Returns {@link TupleExpr} children of the given node. * * @param t * a tuple expression. * @return a list of TupleExpr children. */ public static List<TupleExpr> getChildren(TupleExpr t) { final List<TupleExpr> children = new ArrayList<>(4); t.visitChildren(new AbstractQueryModelVisitor<RuntimeException>() { public void meetNode(QueryModelNode node) { if (node instanceof TupleExpr) { children.add((TupleExpr)node); } } }); return children; }
/** * Returns {@link TupleExpr} children of the given node. * * @param t * a tuple expression. * @return a list of TupleExpr children. */ public static List<TupleExpr> getChildren(TupleExpr t) { final List<TupleExpr> children = new ArrayList<>(4); t.visitChildren(new AbstractQueryModelVisitor<RuntimeException>() { @Override public void meetNode(QueryModelNode node) { if (node instanceof TupleExpr) { children.add((TupleExpr)node); } } }); return children; }
throw new IOException(e); parsedQuery.getTupleExpr().visitChildren(new AbstractQueryModelVisitor<IOException>() { @Override public void meet(StatementPattern node) throws IOException {
/** * Fetch the {@link StatementPattern} from a SPARQL string. * * @param sparql - A SPARQL query that contains only a single Statement Pattern. (not null) * @return The {@link StatementPattern} that was in the query, if it could be found. Otherwise {@code null} * @throws Exception The statement pattern could not be found in the parsed SPARQL query. */ public static @Nullable StatementPattern getSp(final String sparql) throws Exception { requireNonNull(sparql); final AtomicReference<StatementPattern> statementPattern = new AtomicReference<>(); final ParsedQuery parsed = new SPARQLParser().parseQuery(sparql, null); parsed.getTupleExpr().visitChildren(new AbstractQueryModelVisitor<Exception>() { @Override public void meet(final StatementPattern node) throws Exception { statementPattern.set(node); } }); return statementPattern.get(); }