Examples of LocationStepQueryNode


Examples of org.apache.jackrabbit.spi.commons.query.LocationStepQueryNode

            } else if (JCR_DEREF.equals(funName)) {
                // check number of arguments
                if (node.jjtGetNumChildren() == 3) {
                    boolean descendant = false;
                    if (queryNode.getType() == QueryNode.TYPE_LOCATION) {
                        LocationStepQueryNode loc = (LocationStepQueryNode) queryNode;
                        // remember if descendant axis
                        descendant = loc.getIncludeDescendants();
                        queryNode = loc.getParent();
                        ((NAryQueryNode) queryNode).removeOperand(loc);
                    }
                    if (queryNode.getType() == QueryNode.TYPE_PATH) {
                        PathQueryNode pathNode = (PathQueryNode) queryNode;
View Full Code Here

Examples of org.apache.jackrabbit.spi.commons.query.LocationStepQueryNode

            // check if this node is valid as an operand
            if (operands.size() < 3) {
                throw new NoSuchElementException("Merging not possible");
            }
            int size = operands.size();
            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");
            }
            // find a node to merge with
            MergingPathQueryNode matchedNode = null;
            for (int i = 0; i < nodes.length; i++) {
                if (nodes[i].operands.size() == operands.size() - 1) {
                    boolean match = true;
                    for (int j = 0; j < operands.size() - 1 && match; j++) {
                        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());
                    }
                    if (match) {
                        matchedNode = nodes[i];
                        break;
                    }
View Full Code Here

Examples of org.apache.jackrabbit.spi.commons.query.LocationStepQueryNode

        private MergingPathQueryNode[] doOrMerge(MergingPathQueryNode[] nodes) {
            // compact this
            MergingPathQueryNode compacted = new MergingPathQueryNode(
                    QueryNode.TYPE_OR, getValidJcrSystemNodeTypeNames());
            for (Iterator it = operands.iterator(); it.hasNext();) {
                LocationStepQueryNode step = (LocationStepQueryNode) it.next();
                if (step.getIncludeDescendants() && step.getNameTest() == null) {
                    // check if has next
                    if (it.hasNext()) {
                        LocationStepQueryNode next = (LocationStepQueryNode) it.next();
                        next.setIncludeDescendants(true);
                        compacted.addPathStep(next);
                    } else {
                        compacted.addPathStep(step);
                    }
                } else {
                    compacted.addPathStep(step);
                }
            }

            MergingPathQueryNode matchedNode = null;
            for (int i = 0; i < nodes.length; i++) {
                // loop over the steps and compare the names
                if (nodes[i].operands.size() == compacted.operands.size()) {
                    boolean match = true;
                    Iterator compactedSteps = compacted.operands.iterator();
                    Iterator otherSteps = nodes[i].operands.iterator();
                    while (match && compactedSteps.hasNext()) {
                        LocationStepQueryNode n1 = (LocationStepQueryNode) compactedSteps.next();
                        LocationStepQueryNode n2 = (LocationStepQueryNode) otherSteps.next();
                        match &= (n1.getNameTest() == null) ? n2.getNameTest() == null : n1.getNameTest().equals(n2.getNameTest());
                    }
                    if (match) {
                        matchedNode = nodes[i];
                        break;
                    }
View Full Code Here

Examples of org.exoplatform.services.jcr.impl.core.query.LocationStepQueryNode

      // 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)
View Full Code Here

Examples of org.exoplatform.services.jcr.impl.core.query.LocationStepQueryNode

               }

            }
            // if name test is % this means also search descendants
            boolean descendant = name == null;
            LocationStepQueryNode step = factory.createLocationStepQueryNode(pathNode);
            step.setNameTest(qName);
            step.setIncludeDescendants(descendant);
            if (index > 0)
            {
               step.setIndex(index);
            }
            pathNode.addPathStep(step);
         }
      }
      pathConstraints.add(pathNode);
View Full Code Here

Examples of org.exoplatform.services.jcr.impl.core.query.LocationStepQueryNode

         if (operands.size() < 3)
         {
            throw new NoSuchElementException("Merging not possible");
         }
         int size = operands.size();
         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");
         }
         // find a node to merge with
         MergingPathQueryNode matchedNode = null;
         for (int i = 0; i < nodes.length; i++)
         {
            if (nodes[i].operands.size() == operands.size() - 1)
            {
               boolean match = true;
               for (int j = 0; j < operands.size() - 1 && match; j++)
               {
                  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());
               }
               if (match)
               {
                  matchedNode = nodes[i];
                  break;
View Full Code Here

Examples of org.exoplatform.services.jcr.impl.core.query.LocationStepQueryNode

      {
         // compact this
         MergingPathQueryNode compacted = new MergingPathQueryNode(QueryNode.TYPE_OR, getValidJcrSystemNodeTypeNames());
         for (Iterator it = operands.iterator(); it.hasNext();)
         {
            LocationStepQueryNode step = (LocationStepQueryNode)it.next();
            if (step.getIncludeDescendants() && step.getNameTest() == null)
            {
               // check if has next
               if (it.hasNext())
               {
                  LocationStepQueryNode next = (LocationStepQueryNode)it.next();
                  next.setIncludeDescendants(true);
                  compacted.addPathStep(next);
               }
               else
               {
                  compacted.addPathStep(step);
               }
            }
            else
            {
               compacted.addPathStep(step);
            }
         }

         MergingPathQueryNode matchedNode = null;
         for (int i = 0; i < nodes.length; i++)
         {
            // loop over the steps and compare the names
            if (nodes[i].operands.size() == compacted.operands.size())
            {
               boolean match = true;
               Iterator compactedSteps = compacted.operands.iterator();
               Iterator otherSteps = nodes[i].operands.iterator();
               while (match && compactedSteps.hasNext())
               {
                  LocationStepQueryNode n1 = (LocationStepQueryNode)compactedSteps.next();
                  LocationStepQueryNode n2 = (LocationStepQueryNode)otherSteps.next();
                  match &=
                     (n1.getNameTest() == null) ? n2.getNameTest() == null : n1.getNameTest().equals(n2.getNameTest());
               }
               if (match)
               {
                  matchedNode = nodes[i];
                  break;
View Full Code Here

Examples of org.exoplatform.services.jcr.impl.core.query.LocationStepQueryNode

       */
      boolean needsMerge()
      {
         for (Iterator it = operands.iterator(); it.hasNext();)
         {
            LocationStepQueryNode step = (LocationStepQueryNode)it.next();
            if (step.getIncludeDescendants() && step.getNameTest() == null)
            {
               return true;
            }
         }
         return false;
View Full Code Here

Examples of org.exoplatform.services.jcr.impl.core.query.LocationStepQueryNode

                    }
                }
                break;
            case JJTTEXTTEST:
                if (queryNode.getType() == QueryNode.TYPE_LOCATION) {
                    LocationStepQueryNode loc = (LocationStepQueryNode) queryNode;
                    loc.setNameTest(JCR_XMLTEXT);
                }
                break;
            case JJTTYPENAME:
                if (queryNode.getType() == QueryNode.TYPE_LOCATION) {
                    LocationStepQueryNode loc = (LocationStepQueryNode) queryNode;
                    String ntName = ((SimpleNode) node.jjtGetChild(0)).getValue();
                    try {
                        InternalQName nt = resolver.parseJCRName(ntName).getInternalName();
                        NodeTypeQueryNode nodeType = factory.createNodeTypeQueryNode(loc, nt);
                        loc.addPredicate(nodeType);
                    } catch (NamespaceException e) {
                        exceptions.add(new InvalidQueryException("Not a valid name: " + ntName));
                    } catch (RepositoryException e) {
                        exceptions.add(new InvalidQueryException("Not a valid name: " + ntName));
                    }
View Full Code Here

Examples of org.exoplatform.services.jcr.impl.core.query.LocationStepQueryNode

     * @param node   the current node in the xpath syntax tree.
     * @param parent the parent <code>PathQueryNode</code>.
     * @return the created <code>LocationStepQueryNode</code>.
     */
    private LocationStepQueryNode createLocationStep(SimpleNode node, NAryQueryNode parent) {
        LocationStepQueryNode queryNode = null;
        boolean descendant = false;
        Node p = node.jjtGetParent();
        for (int i = 0; i < p.jjtGetNumChildren(); i++) {
            SimpleNode c = (SimpleNode) p.jjtGetChild(i);
            if (c == node) { // NOSONAR
                queryNode = factory.createLocationStepQueryNode(parent);
                queryNode.setNameTest(null);
                queryNode.setIncludeDescendants(descendant);
                parent.addOperand(queryNode);
                break;
            }
            descendant = (c.getId() == JJTSLASHSLASH
                    || c.getId() == JJTROOTDESCENDANTS);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.