Ejemplo n.º 1
0
  /**
   * Compute the variable names occurring in the service expression using tree traversal, since
   * these are necessary for building the SPARQL query.
   *
   * @return the set of variable names in the given service expression
   */
  private Set<String> computeServiceVars(TupleExpr serviceExpression) {
    final Set<String> res = new HashSet<String>();
    serviceExpression.visit(
        new AbstractQueryModelVisitor<RuntimeException>() {

          @Override
          public void meet(Var node) throws RuntimeException {
            // take only real vars, i.e. ignore blank nodes
            if (!node.hasValue() && !node.isAnonymous()) res.add(node.getName());
          }
          // TODO maybe stop tree traversal in nested SERVICE?
          // TODO special case handling for BIND
        });
    return res;
  }