use of org.javarosa.xpath.expr.XPathBinaryOpExpr in project javarosa by opendatakit.
the class XPathConditional method getTriggers.
private static void getTriggers(XPathExpression x, Set<TreeReference> v, TreeReference contextRef) {
if (x instanceof XPathPathExpr) {
TreeReference ref = ((XPathPathExpr) x).getReference();
TreeReference contextualized = ref;
if (contextRef != null) {
contextualized = ref.contextualize(contextRef);
}
// TODO: It's possible we should just handle this the same way as "genericize". Not entirely clear.
if (contextualized.hasPredicates()) {
contextualized = contextualized.removePredicates();
}
v.add(contextualized);
for (int i = 0; i < ref.size(); i++) {
List<XPathExpression> predicates = ref.getPredicate(i);
if (predicates == null) {
continue;
}
// we can't generate this properly without an absolute reference
if (!ref.isAbsolute()) {
throw new IllegalArgumentException("can't get triggers for relative references");
}
TreeReference predicateContext = ref.getSubReference(i);
for (XPathExpression predicate : predicates) {
getTriggers(predicate, v, predicateContext);
}
}
} else if (x instanceof XPathBinaryOpExpr) {
getTriggers(((XPathBinaryOpExpr) x).a, v, contextRef);
getTriggers(((XPathBinaryOpExpr) x).b, v, contextRef);
} else if (x instanceof XPathUnaryOpExpr) {
getTriggers(((XPathUnaryOpExpr) x).a, v, contextRef);
} else if (x instanceof XPathFuncExpr) {
XPathFuncExpr fx = (XPathFuncExpr) x;
for (int i = 0; i < fx.args.length; i++) getTriggers(fx.args[i], v, contextRef);
}
}
Aggregations