Search in sources :

Example 1 with OpVisitorByTypeBase

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]);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) OpProject(org.apache.jena.sparql.algebra.op.OpProject) OpVisitorByTypeBase(org.apache.jena.sparql.algebra.OpVisitorByTypeBase)

Aggregations

Op (org.apache.jena.sparql.algebra.Op)1 OpVisitorByTypeBase (org.apache.jena.sparql.algebra.OpVisitorByTypeBase)1 OpProject (org.apache.jena.sparql.algebra.op.OpProject)1