Package org.apache.xpath.axes

Examples of org.apache.xpath.axes.WalkingIterator


  {   
    if(null == testee.m_exprOwner)
      return head;
     
    // Start with the longest possible match, and move down.
    WalkingIterator iter1 = (WalkingIterator) testee.m_exprOwner.getExpression();
    if(partialIsVariable(testee, lengthToTest))
      return head;
    MultistepExprHolder matchedPaths = null;
    MultistepExprHolder matchedPathsTail = null;
    MultistepExprHolder meh = head;
    while( null != meh)
    {
      if ((meh != testee) && (null != meh.m_exprOwner))
      {
        WalkingIterator iter2 = (WalkingIterator) meh.m_exprOwner.getExpression();
        if (stepsEqual(iter1, iter2, lengthToTest))
        {
          if (null == matchedPaths)
          {
            try
            {
              matchedPaths = (MultistepExprHolder)testee.clone();
              testee.m_exprOwner = null; // So it won't be processed again.
            }
            catch(CloneNotSupportedException cnse){}
            matchedPathsTail = matchedPaths;
            matchedPathsTail.m_next = null;
          }
        
          try
          {
            matchedPathsTail.m_next = (MultistepExprHolder)meh.clone();
            meh.m_exprOwner = null; // So it won't be processed again.
          }
          catch(CloneNotSupportedException cnse){}
          matchedPathsTail = matchedPathsTail.m_next;
          matchedPathsTail.m_next = null;
        }
      }
      meh = meh.m_next;
    }
     
  int matchCount = 0;
  if(null != matchedPaths)
  {
    ElemTemplateElement root = isGlobal ? varScope : findCommonAncestor(matchedPaths);
    WalkingIterator sharedIter = (WalkingIterator)matchedPaths.m_exprOwner.getExpression();
    WalkingIterator newIter = createIteratorFromSteps(sharedIter, lengthToTest);
    ElemVariable var = createPseudoVarDecl(root, newIter, isGlobal);
    if(DIAGNOSE_MULTISTEPLIST)
      System.err.println("Created var: "+var.getName()+(isGlobal ? "(Global)" : ""));
    while(null != matchedPaths)
    {
      ExpressionOwner owner = matchedPaths.m_exprOwner;
      WalkingIterator iter = (WalkingIterator)owner.getExpression();
     
      if(DIAGNOSE_MULTISTEPLIST)
        diagnoseLineNumber(iter);
     
      LocPathIterator newIter2 =
View Full Code Here


   */
  boolean partialIsVariable(MultistepExprHolder testee, int lengthToTest)
  {
    if(1 == lengthToTest)
    {
      WalkingIterator wi = (WalkingIterator)testee.m_exprOwner.getExpression();
      if(wi.getFirstWalker() instanceof FilterExprWalker)
        return true;
    }
    return false;
  }
View Full Code Here

   *                 iterator.
   * @return The new iterator.
   */
  protected WalkingIterator createIteratorFromSteps(final WalkingIterator wi, int numSteps)
  {
    WalkingIterator newIter = new WalkingIterator(wi.getPrefixResolver());
    try
    {
      AxesWalker walker = (AxesWalker)wi.getFirstWalker().clone();
      newIter.setFirstWalker(walker);
      walker.setLocPathIterator(newIter);
      for(int i = 1; i < numSteps; i++)
      {
        AxesWalker next = (AxesWalker)walker.getNextWalker().clone();
        walker.setNextWalker(next);
View Full Code Here

   */
  protected int countSteps(LocPathIterator lpi)
  {
    if(lpi instanceof WalkingIterator)
    {
      WalkingIterator wi = (WalkingIterator)lpi;
      AxesWalker aw = wi.getFirstWalker();
      int count = 0;
      while(null != aw)
      {
        count++;
        aw = aw.getNextWalker();
View Full Code Here

    {
      return true;
    }
    else if(path instanceof WalkingIterator)
    {
      WalkingIterator wi = (WalkingIterator)path;
      AxesWalker aw = wi.getFirstWalker();
      if((aw instanceof FilterExprWalker) && (null == aw.getNextWalker()))
      {
        FilterExprWalker few = (FilterExprWalker)aw;
        Expression exp = few.getInnerExpression();
        if(exp instanceof Variable)
View Full Code Here

  {   
    if(null == testee.m_exprOwner)
      return head;
     
    // Start with the longest possible match, and move down.
    WalkingIterator iter1 = (WalkingIterator) testee.m_exprOwner.getExpression();
    if(partialIsVariable(testee, lengthToTest))
      return head;
    MultistepExprHolder matchedPaths = null;
    MultistepExprHolder matchedPathsTail = null;
    MultistepExprHolder meh = head;
    while( null != meh)
    {
      if ((meh != testee) && (null != meh.m_exprOwner))
      {
        WalkingIterator iter2 = (WalkingIterator) meh.m_exprOwner.getExpression();
        if (stepsEqual(iter1, iter2, lengthToTest))
        {
          if (null == matchedPaths)
          {
            try
            {
              matchedPaths = (MultistepExprHolder)testee.clone();
              testee.m_exprOwner = null; // So it won't be processed again.
            }
            catch(CloneNotSupportedException cnse){}
            matchedPathsTail = matchedPaths;
            matchedPathsTail.m_next = null;
          }
        
          try
          {
            matchedPathsTail.m_next = (MultistepExprHolder)meh.clone();
            meh.m_exprOwner = null; // So it won't be processed again.
          }
          catch(CloneNotSupportedException cnse){}
          matchedPathsTail = matchedPathsTail.m_next;
          matchedPathsTail.m_next = null;
        }
      }
      meh = meh.m_next;
    }
     
  int matchCount = 0;
  if(null != matchedPaths)
  {
    ElemTemplateElement root = isGlobal ? varScope : findCommonAncestor(matchedPaths);
    WalkingIterator sharedIter = (WalkingIterator)matchedPaths.m_exprOwner.getExpression();
    WalkingIterator newIter = createIteratorFromSteps(sharedIter, lengthToTest);
    ElemVariable var = createPseudoVarDecl(root, newIter, isGlobal);
    if(DIAGNOSE_MULTISTEPLIST)
      System.err.println("Created var: "+var.getName()+(isGlobal ? "(Global)" : ""));
    while(null != matchedPaths)
    {
      ExpressionOwner owner = matchedPaths.m_exprOwner;
      WalkingIterator iter = (WalkingIterator)owner.getExpression();
     
      if(DIAGNOSE_MULTISTEPLIST)
        diagnoseLineNumber(iter);
     
      LocPathIterator newIter2 =
View Full Code Here

   */
  boolean partialIsVariable(MultistepExprHolder testee, int lengthToTest)
  {
    if(1 == lengthToTest)
    {
      WalkingIterator wi = (WalkingIterator)testee.m_exprOwner.getExpression();
      if(wi.getFirstWalker() instanceof FilterExprWalker)
        return true;
    }
    return false;
  }
View Full Code Here

   *                 iterator.
   * @return The new iterator.
   */
  protected WalkingIterator createIteratorFromSteps(final WalkingIterator wi, int numSteps)
  {
    WalkingIterator newIter = new WalkingIterator(wi.getPrefixResolver());
    try
    {
      AxesWalker walker = (AxesWalker)wi.getFirstWalker().clone();
      newIter.setFirstWalker(walker);
      walker.setLocPathIterator(newIter);
      for(int i = 1; i < numSteps; i++)
      {
        AxesWalker next = (AxesWalker)walker.getNextWalker().clone();
        walker.setNextWalker(next);
View Full Code Here

   */
  protected int countSteps(LocPathIterator lpi)
  {
    if(lpi instanceof WalkingIterator)
    {
      WalkingIterator wi = (WalkingIterator)lpi;
      AxesWalker aw = wi.getFirstWalker();
      int count = 0;
      while(null != aw)
      {
        count++;
        aw = aw.getNextWalker();
View Full Code Here

    {
      return true;
    }
    else if(path instanceof WalkingIterator)
    {
      WalkingIterator wi = (WalkingIterator)path;
      AxesWalker aw = wi.getFirstWalker();
      if((aw instanceof FilterExprWalker) && (null == aw.getNextWalker()))
      {
        FilterExprWalker few = (FilterExprWalker)aw;
        Expression exp = few.getInnerExpression();
        if(exp instanceof Variable)
View Full Code Here

TOP

Related Classes of org.apache.xpath.axes.WalkingIterator

Copyright © 2018 www.massapicom. 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.