/** * 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; } }
public Object visit(LocationStepQueryNode node, Object data) { StringBuffer sb = (StringBuffer) data; if (node.getNameTest() == null) { sb.append("%"); } else { if (node.getNameTest().getLocalName().length() > 0) { try { sb.append(resolver.getJCRName(node.getNameTest())); } catch (NamespaceException e) { exceptions.add(e); } if (node.getIndex() == LocationStepQueryNode.NONE) { sb.append("[%]"); } else if (node.getIndex() == 1) { // do nothing } else { sb.append('[').append(node.getIndex()).append(']'); } } else { // empty name test indicates root node } } return sb; }
public Object visit(LocationStepQueryNode node, Object data) { StringBuffer sb = (StringBuffer) data; if (node.getNameTest() == null) { sb.append("%"); } else { if (node.getNameTest().getLocalName().length() > 0) { try { sb.append(resolver.getJCRName(node.getNameTest())); } catch (NamespaceException e) { exceptions.add(e); } if (node.getIndex() == LocationStepQueryNode.NONE) { sb.append("[%]"); } else if (node.getIndex() == 1) { // do nothing } else { sb.append('[').append(node.getIndex()).append(']'); } } else { // empty name test indicates root node } } return sb; }
LocationStepQueryNode n1 = (LocationStepQueryNode) operands.get(size - 1); LocationStepQueryNode n2 = (LocationStepQueryNode) operands.get(size - 2); if (n1.getNameTest() != null || n2.getNameTest() != null || !n1.getIncludeDescendants() || !n2.getIncludeDescendants()) { throw new NoSuchElementException("Merging not possible"); LocationStepQueryNode step = (LocationStepQueryNode) operands.get(j); LocationStepQueryNode other = (LocationStepQueryNode) nodes[i].operands.get(j); match &= (step.getNameTest() == null) ? other.getNameTest() == null : step.getNameTest().equals(other.getNameTest());
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 * 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; }
/** * 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[] steps = node.getPathSteps(); for (int i = 0; i < steps.length; i++) { if (steps[i].getNameTest() == null || steps[i].getNameTest().getLocalName().length() > 0) { sb.append('/'); sb.append(" LIKE '"); for (int i = 0; i < steps.length; i++) { if (steps[i].getNameTest() == null || steps[i].getNameTest().getLocalName().length() > 0) { sb.append('/'); if (steps[i].getNameTest() != null) { steps[i].accept(this, sb); LocationStepQueryNode[] steps = node.getPathSteps(); for (int i = 0; i < steps.length; i++) { if (steps[i].getNameTest() == null || steps[i].getNameTest().getLocalName().length() > 0) { path.append('/'); LocationStepQueryNode[] steps = node.getPathSteps(); for (int i = 0; i < steps.length; i++) { if (steps[i].getNameTest() == null || steps[i].getNameTest().getLocalName().length() > 0) { sb.append('/');
Name firstPathStepName = pathSteps[0].getNameTest(); if (firstPathStepName == null) { Name firstWorkspaceRelativeName = firstWorkspaceRelativeStep.getNameTest(); if (firstWorkspaceRelativeName == null || firstWorkspaceRelativeName.equals(NameConstants.JCR_SYSTEM)) {
if (node.getNameTest() == null) { sb.append("*"); } else { try { if (node.getNameTest().getLocalName().length() == 0) { sb.append(resolver.getJCRName(XPathQueryBuilder.JCR_ROOT)); } else { sb.append(resolver.getJCRName(encode(node.getNameTest())));
Name firstPathStepName = pathSteps[0].getNameTest(); if (firstPathStepName == null) { Name firstWorkspaceRelativeName = firstWorkspaceRelativeStep.getNameTest(); if (firstWorkspaceRelativeName == null || firstWorkspaceRelativeName.equals(NameConstants.JCR_SYSTEM)) {
if (node.getNameTest() == null) { sb.append("*"); } else { try { if (node.getNameTest().getLocalName().length() == 0) { sb.append(resolver.getJCRName(XPathQueryBuilder.JCR_ROOT)); } else { sb.append(resolver.getJCRName(encode(node.getNameTest())));
if (node.isAbsolute() && !steps[0].getIncludeDescendants()) { Name nameTest = steps[0].getNameTest(); if (nameTest == null) {
if (node.isAbsolute() && !steps[0].getIncludeDescendants()) { Name nameTest = steps[0].getNameTest(); if (nameTest == null) {
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());
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());