/** * Returns <code>true</code> if this node needs merging; <code>false</code> * otherwise. * * @return <code>true</code> if this node needs merging; <code>false</code> * otherwise. */ boolean needsMerge() { for (Iterator it = operands.iterator(); it.hasNext();) { LocationStepQueryNode step = (LocationStepQueryNode) it.next(); if (step.getIncludeDescendants() && step.getNameTest() == null) { return true; } } return false; } }
/** * Returns <code>true</code> if this node needs merging; <code>false</code> * otherwise. * * @return <code>true</code> if this node needs merging; <code>false</code> * otherwise. */ boolean needsMerge() { for (Iterator it = operands.iterator(); it.hasNext();) { LocationStepQueryNode step = (LocationStepQueryNode) it.next(); if (step.getIncludeDescendants() && step.getNameTest() == null) { return true; } } return false; } }
/** * Returns <code>true</code> if <code>path</code> contains exactly one * step with a descendant-or-self axis and an explicit name test; returns * <code>false</code> otherwise. * * @param path the path node. * @return <code>true</code> if <code>path</code> contains exactly one * step with a descendant-or-self axis. */ private static boolean containsDescendantOrSelf(PathQueryNode path) { LocationStepQueryNode[] steps = path.getPathSteps(); int count = 0; for (int i = 0; i < steps.length; i++) { if (steps[i].getNameTest() != null && steps[i].getIncludeDescendants()) { count++; } } return count == 1; }
/** * Returns <code>true</code> if <code>path</code> contains exactly one * step with a descendant-or-self axis and an explicit name test; returns * <code>false</code> otherwise. * * @param path the path node. * @return <code>true</code> if <code>path</code> contains exactly one * step with a descendant-or-self axis. */ private static boolean containsDescendantOrSelf(PathQueryNode path) { LocationStepQueryNode[] steps = path.getPathSteps(); int count = 0; for (int i = 0; i < steps.length; i++) { if (steps[i].getNameTest() != null && steps[i].getIncludeDescendants()) { count++; } } return count == 1; }
public Object visit(LocationStepQueryNode node, Object data) throws RepositoryException { StringBuffer buffer = (StringBuffer) data; buffer.append(PADDING, 0, indent); buffer.append("+ LocationStepQueryNode: "); buffer.append(" NodeTest="); if (node.getNameTest() == null) { buffer.append("*"); } else { buffer.append(node.getNameTest()); } buffer.append(" Descendants=").append(node.getIncludeDescendants()); buffer.append(" Index="); if (node.getIndex() == LocationStepQueryNode.NONE) { buffer.append("NONE"); } else if (node.getIndex() == LocationStepQueryNode.LAST) { buffer.append("last()"); } else { buffer.append(node.getIndex()); } buffer.append("\n"); traverse(node.getOperands(), buffer); return buffer; }
public Object visit(LocationStepQueryNode node, Object data) throws RepositoryException { StringBuffer buffer = (StringBuffer) data; buffer.append(PADDING, 0, indent); buffer.append("+ LocationStepQueryNode: "); buffer.append(" NodeTest="); if (node.getNameTest() == null) { buffer.append("*"); } else { buffer.append(node.getNameTest()); } buffer.append(" Descendants=").append(node.getIncludeDescendants()); buffer.append(" Index="); if (node.getIndex() == LocationStepQueryNode.NONE) { buffer.append("NONE"); } else if (node.getIndex() == LocationStepQueryNode.LAST) { buffer.append("last()"); } else { buffer.append(node.getIndex()); } buffer.append("\n"); traverse(node.getOperands(), buffer); return buffer; }
/** * Returns <code>true</code> if <code>path</code> contains exactly one * location step which matches all node names. That is, matches any children * of a given node. That location step must be the last one in the sequence * of location steps. * * @param path the path node. * @return <code>true</code> if the last step matches any node name. */ private static boolean containsAllChildrenMatch(PathQueryNode path) { LocationStepQueryNode[] steps = path.getPathSteps(); int count = 0; for (int i = 0; i < steps.length; i++) { if (steps[i].getNameTest() == null && !steps[i].getIncludeDescendants()) { if (i == steps.length - 1 && count == 0) { return true; } count++; } } return false; } }
/** * Returns <code>true</code> if <code>path</code> contains exactly one * location step which matches all node names. That is, matches any children * of a given node. That location step must be the last one in the sequence * of location steps. * * @param path the path node. * @return <code>true</code> if the last step matches any node name. */ private static boolean containsAllChildrenMatch(PathQueryNode path) { LocationStepQueryNode[] steps = path.getPathSteps(); int count = 0; for (int i = 0; i < steps.length; i++) { if (steps[i].getNameTest() == null && !steps[i].getIncludeDescendants()) { if (i == steps.length - 1 && count == 0) { return true; } count++; } } return false; } }
LocationStepQueryNode n2 = (LocationStepQueryNode) operands.get(size - 2); if (n1.getNameTest() != null || n2.getNameTest() != null || !n1.getIncludeDescendants() || !n2.getIncludeDescendants()) { throw new NoSuchElementException("Merging not possible");
for (Iterator it = operands.iterator(); it.hasNext();) { LocationStepQueryNode step = (LocationStepQueryNode) it.next(); if (step.getIncludeDescendants() && step.getNameTest() == null) {
public Object visit(LocationStepQueryNode node, Object data) throws RepositoryException { StringBuffer sb = (StringBuffer) data; if (node.getIncludeDescendants()) { sb.append('/');
&& steps[1].getIncludeDescendants() && steps[1].getNameTest() == null) { && steps[0].getIncludeDescendants() && steps[0].getNameTest() == null) {
public Object visit(LocationStepQueryNode node, Object data) throws RepositoryException { StringBuffer sb = (StringBuffer) data; if (node.getIncludeDescendants()) { sb.append('/');
sb.append('/'); if (steps[i].getIncludeDescendants()) { sb.append("%/");
if (firstWorkspaceRelativeStep.getIncludeDescendants()) { return true;
if (firstWorkspaceRelativeStep.getIncludeDescendants()) { return true;
LocationStepQueryNode[] steps = node.getPathSteps(); if (steps.length > 0) { if (node.isAbsolute() && !steps[0].getIncludeDescendants()) {
LocationStepQueryNode[] steps = node.getPathSteps(); if (steps.length > 0) { if (node.isAbsolute() && !steps[0].getIncludeDescendants()) {
LocationStepQueryNode step = factory.createLocationStepQueryNode(pathNode); step.setNameTest(steps[i].getNameTest()); step.setIncludeDescendants(steps[i].getIncludeDescendants()); step.setIndex(steps[i].getIndex()); pathNode.addPathStep(step);
LocationStepQueryNode step = factory.createLocationStepQueryNode(pathNode); step.setNameTest(steps[i].getNameTest()); step.setIncludeDescendants(steps[i].getIncludeDescendants()); step.setIndex(steps[i].getIndex()); pathNode.addPathStep(step);