use of org.apache.jena.sparql.algebra.OpVisitorByTypeBase in project webofneeds by researchstudio-sat.
the class SparqlMatcherUtils method findToplevelOpProject.
/**
* Finds the top-level projection of the query.
*/
public static Optional<Op> findToplevelOpProject(Op op) {
// use a final array to obtain the result of the visit
final Op[] toplevelOpProject = new Op[] { null };
Walker.walk(op, new OpVisitorByTypeBase() {
@Override
public void visit(OpProject opProject) {
// the visitor is called after returning from the recursion, so
// we have to replace any project op we found deeper in the tree
// to end up with the toplevel one in the end
toplevelOpProject[0] = opProject;
}
});
return Optional.ofNullable(toplevelOpProject[0]);
}
Aggregations