// use //* if no path has been set
PathQueryNode pathNode = root.getLocationNode();
pathNode.setAbsolute(true);
if (pathConstraints.size() == 0) {
LocationStepQueryNode step = factory.createLocationStepQueryNode(pathNode);
step.setNameTest(null);
step.setIncludeDescendants(true);
pathNode.addPathStep(step);
} else {
try {
while (pathConstraints.size() > 1) {
// merge path nodes
MergingPathQueryNode path = null;
for (Iterator it = pathConstraints.iterator(); it.hasNext();) {
path = (MergingPathQueryNode) it.next();
if (path.needsMerge()) {
break;
} else {
path = null;
}
}
if (path == null) {
throw new IllegalArgumentException("Invalid combination of jcr:path clauses");
} else {
pathConstraints.remove(path);
MergingPathQueryNode[] paths = (MergingPathQueryNode[]) pathConstraints.toArray(new MergingPathQueryNode[pathConstraints.size()]);
paths = path.doMerge(paths);
pathConstraints.clear();
pathConstraints.addAll(Arrays.asList(paths));
}
}
} catch (NoSuchElementException e) {
throw new IllegalArgumentException("Invalid combination of jcr:path clauses");
}
MergingPathQueryNode path = (MergingPathQueryNode) pathConstraints.get(0);
LocationStepQueryNode[] steps = path.getPathSteps();
for (int i = 0; i < steps.length; i++) {
LocationStepQueryNode step = factory.createLocationStepQueryNode(pathNode);
step.setNameTest(steps[i].getNameTest());
step.setIncludeDescendants(steps[i].getIncludeDescendants());
step.setIndex(steps[i].getIndex());
pathNode.addPathStep(step);
}
}
if (constraintNode.getNumOperands() == 1) {