use of org.javarosa.xpath.expr.XPathStep in project javarosa by opendatakit.
the class ASTNodeLocPath method build.
public XPathExpression build() throws XPathSyntaxException {
Vector<XPathStep> steps = new Vector<XPathStep>();
XPathExpression filtExpr = null;
int offset = isAbsolute() ? 1 : 0;
for (int i = 0; i < clauses.size() + offset; i++) {
if (offset == 0 || i > 0) {
if (clauses.elementAt(i - offset) instanceof ASTNodePathStep) {
steps.addElement(((ASTNodePathStep) clauses.elementAt(i - offset)).getStep());
} else {
filtExpr = clauses.elementAt(i - offset).build();
}
}
if (i < separators.size()) {
if (Parser.vectInt(separators, i) == Token.DBL_SLASH) {
steps.addElement(XPathStep.ABBR_DESCENDANTS());
}
}
}
XPathStep[] stepArr = new XPathStep[steps.size()];
for (int i = 0; i < stepArr.length; i++) stepArr[i] = steps.elementAt(i);
if (filtExpr == null) {
return new XPathPathExpr(isAbsolute() ? XPathPathExpr.INIT_CONTEXT_ROOT : XPathPathExpr.INIT_CONTEXT_RELATIVE, stepArr);
} else {
if (filtExpr instanceof XPathFilterExpr) {
return new XPathPathExpr((XPathFilterExpr) filtExpr, stepArr);
} else {
return new XPathPathExpr(new XPathFilterExpr(filtExpr, new XPathExpression[0]), stepArr);
}
}
}
Aggregations