You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mm...@locus.apache.org on 2000/08/17 22:58:43 UTC

cvs commit: xml-xalan/java/src/org/apache/xpath/axes UnionPathIterator.java

mmidy       00/08/17 13:58:43

  Modified:    java/src/org/apache/xpath/axes UnionPathIterator.java
  Log:
  I am actually checking in code to check for a null array of iterators. But found some other code that Scott must have written on my machine, I don't remember what it was for, but I'll check it in as well.
  
  Revision  Changes    Path
  1.3       +42 -36    xml-xalan/java/src/org/apache/xpath/axes/UnionPathIterator.java
  
  Index: UnionPathIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/UnionPathIterator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UnionPathIterator.java	2000/07/30 22:41:48	1.2
  +++ UnionPathIterator.java	2000/08/17 20:58:42	1.3
  @@ -102,12 +102,15 @@
       this.m_execContext = execContext;
       this.m_currentContextNode = execContext.getCurrentExpressionNode();
       this.m_context = execContext.getCurrentNode();
  -
  -    int n = m_iterators.length;
  -    for(int i = 0; i < n; i++)
  -    {
  -      m_iterators[i].initContext(execContext);
  -      m_iterators[i].nextNode();
  +    
  +    if (null != m_iterators)
  +    {  
  +      int n = m_iterators.length;
  +      for(int i = 0; i < n; i++)
  +      {
  +        m_iterators[i].initContext(execContext);
  +        m_iterators[i].nextNode();
  +      }
       }
       
     }
  @@ -407,46 +410,49 @@
       // Loop through the iterators getting the current fetched 
       // node, and get the earliest occuring in document order
       Node earliestNode = null;
  -    int n = m_iterators.length;
  -    int iteratorUsed = -1;
  -    for(int i = 0; i < n; i++)
  -    {
  -      Node node = m_iterators[i].getCurrentNode();
  -      if(null == node)
  -        continue;
  -      else if(null == earliestNode)
  -      {
  -        iteratorUsed = i;
  -        earliestNode = node;
  -      }
  -      else
  +    if (null != m_iterators)
  +    {  
  +      int n = m_iterators.length;
  +      int iteratorUsed = -1;
  +      for(int i = 0; i < n; i++)
         {
  -        if(node.equals(earliestNode))
  +        Node node = m_iterators[i].getCurrentNode();
  +        if(null == node)
  +          continue;
  +        else if(null == earliestNode)
           {
  -          // Found a duplicate, so skip past it.
  -          m_iterators[i].nextNode();
  +          iteratorUsed = i;
  +          earliestNode = node;
           }
           else
           {
  -          DOMHelper dh = m_execContext.getDOMHelper();
  -          if(dh.isNodeAfter(node, earliestNode))
  +          if(node.equals(earliestNode))
  +          {
  +            // Found a duplicate, so skip past it.
  +            m_iterators[i].nextNode();
  +          }
  +          else
             {
  -            iteratorUsed = i;
  -            earliestNode = node;
  +            DOMHelper dh = m_execContext.getDOMHelper();
  +            if(dh.isNodeAfter(node, earliestNode))
  +            {
  +              iteratorUsed = i;
  +              earliestNode = node;
  +            }
             }
           }
  +      }    
  +      
  +      if(null != earliestNode)
  +      {
  +        m_iterators[iteratorUsed].nextNode();
  +        if(null != m_cachedNodes)
  +          m_cachedNodes.addElement(earliestNode);
  +        m_next++;
         }
  +      else
  +        m_foundLast = true;
       }
  -    
  -    if(null != earliestNode)
  -    {
  -      m_iterators[iteratorUsed].nextNode();
  -      if(null != m_cachedNodes)
  -        m_cachedNodes.addElement(earliestNode);
  -      m_next++;
  -    }
  -    else
  -      m_foundLast = true;
       
       m_lastFetched = earliestNode;
       return earliestNode;