garyp       00/10/17 08:41:57

  Modified:    java/src/org/apache/xpath/objects XRTreeFrag.java
  Log:
  Fix NodeIteratorWrapper to properly return NodeIterator with just
  a single root node.
  
  Revision  Changes    Path
  1.6       +9 -36     
xml-xalan/java/src/org/apache/xpath/objects/XRTreeFrag.java
  
  Index: XRTreeFrag.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xpath/objects/XRTreeFrag.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XRTreeFrag.java   2000/10/16 23:34:46     1.5
  +++ XRTreeFrag.java   2000/10/17 15:41:54     1.6
  @@ -213,42 +213,17 @@
       }
     }
     
  -  class NodeIteratorWrapper implements NodeIterator, NodeList
  +  class NodeIteratorWrapper implements NodeIterator
     {
  -    int m_pos = -1;
  -    DocumentFragment m_docFrag;
  -    NodeList m_nl;
  +    private int m_pos = -1;
  +    private DocumentFragment m_docFrag;
       
       NodeIteratorWrapper(DocumentFragment df)
       {
         m_docFrag = df;
  -      m_nl = df.getChildNodes();
       }
       
       /**
  -     *  Returns the <code>index</code> th item in the collection. If 
  -     * <code>index</code> is greater than or equal to the number of nodes in 
  -     * the list, this returns <code>null</code> .
  -     * @param index  Index into the collection.
  -     * @return  The node at the <code>index</code> th position in the 
  -     *   <code>NodeList</code> , or <code>null</code> if that is not a valid 
  -     *   index.
  -     */
  -    public Node item(int index)
  -    {
  -      return m_nl.item(index);
  -    }
  -
  -    /**
  -     *  The number of nodes in the list. The range of valid child node 
indices 
  -     * is 0 to <code>length-1</code> inclusive. 
  -     */
  -    public int getLength()
  -    {
  -      return m_nl.getLength();
  -    }
  -    
  -    /**
        *  The root node of the Iterator, as specified when it was created.
        */
       public Node getRoot()
  @@ -304,11 +279,10 @@
       public Node nextNode()
                            throws DOMException
       {
  -      int next = m_pos+1;
  -      if((next >= 0) && (next < m_nl.getLength()))  
  +      if (-1 == m_pos)
         {
  -        m_pos++;
  -        return m_nl.item(next);
  +        m_pos = 0;
  +        return m_docFrag;
         }
         else
           return null;
  @@ -326,11 +300,10 @@
       public Node previousNode()
                                throws DOMException
       {
  -      int prev = m_pos-1;
  -      if((prev >= 0) && (prev < m_nl.getLength()))  
  +      if (0 == m_pos)
         {
  -        m_pos--;
  -        return m_nl.item(prev);
  +        m_pos = -1;
  +        return m_docFrag;
         }
         else
           return null;
  
  
  

Reply via email to