Пример #1
0
 private Set<String> extractVars(String query) {
   log.debug(" {}", query);
   Query q = QueryFactory.create(query);
   Element element = q.getQueryPattern();
   ElementWalker.walk(element, collector);
   Set<String> vars = collector.getVariables();
   log.debug(" > {}", vars);
   return vars;
 }
Пример #2
0
 /**
  * This method constructs {@link VariablePair} list with old and numeric ones
  *
  * @param query
  * @param finalIndex
  */
 private static List<VariablePair> constructVariablePairs(Query query, final int finalIndex) {
   final List<VariablePair> variablePairs = new ArrayList<VariablePair>();
   ElementVisitorBase visitor =
       new ElementVisitorBase() {
         @Override
         public void visit(ElementFilter el) {
           Set<Var> varsMentioned = el.getExpr().getVarsMentioned();
           for (Var var : varsMentioned) {
             Node numericVariable = Var.createVariable(var.getName() + "_" + finalIndex);
             variablePairs.add(new VariablePair(var.getName(), numericVariable.getName()));
           }
           super.visit(el);
         }
       };
   ElementWalker.walk(query.getQueryPattern(), visitor);
   return variablePairs;
 }