xalan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkess...@apache.org
Subject cvs commit: xml-xalan/java/src/org/apache/xml/dtm/ref DTMNodeList.java DTMNodeProxy.java
Date Thu, 11 Oct 2001 15:58:18 GMT
jkesselm    01/10/11 08:58:18

  Modified:    java/src/org/apache/xml/dtm/ref DTMNodeList.java
                        DTMNodeProxy.java
  Log:
  Bugzilla3722;  implementation of DTMNodeProxy.getChildren()
  
  Revision  Changes    Path
  1.4       +44 -2     xml-xalan/java/src/org/apache/xml/dtm/ref/DTMNodeList.java
  
  Index: DTMNodeList.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMNodeList.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DTMNodeList.java	2001/06/15 05:15:08	1.3
  +++ DTMNodeList.java	2001/10/11 15:58:18	1.4
  @@ -92,6 +92,8 @@
   {
     private DTMIterator dtm_iter;
     private boolean valid=true;
  +  private int m_firstChild;
  +  private DTM m_parentDTM;
   
     //================================================================
     // Methods unique to this class
  @@ -115,6 +117,24 @@
         dtm_iter.setCurrentPos(pos);
       }
   
  +  /** Public constructor: Create a NodeList to support
  +   * DTMNodeProxy.getChildren().
  +   *
  +   * Unfortunately AxisIterators and DTMIterators don't share an API,
  +   * so I can't use the existing Axis.CHILD iterator. Rather than
  +   * create Yet Another Class, let's set up a special case of this
  +   * one.
  +   *
  +   * @param parentDTM The DTM containing this node
  +   * @param parentHandle DTM node-handle integer
  +   * */
  +  public DTMNodeList(DTM parentDTM,int parentHandle)
  +  {
  +    dtm_iter=null;
  +    m_parentDTM=parentDTM;
  +    m_firstChild=parentDTM.getFirstChild(parentHandle);
  +  }
  +
     /** Access the wrapped DTMIterator. I'm not sure whether anyone will
      * need this or not, but let's write it and think about it.
      * */
  @@ -138,8 +158,18 @@
        */
       public Node item(int index)
       {
  -      int handle=dtm_iter.item(index);
  -      return dtm_iter.getDTM(handle).getNode(handle);
  +      if(dtm_iter!=null)
  +      {
  +        int handle=dtm_iter.item(index);
  +        return dtm_iter.getDTM(handle).getNode(handle);
  +      }
  +      else
  +      {
  +        int handle=m_firstChild;
  +        while(--index>0 && handle!=DTM.NULL)
  +          handle=m_parentDTM.getNextSibling(handle);
  +        return m_parentDTM.getNode(handle);
  +      }
       }
   
       /**
  @@ -148,6 +178,18 @@
        */
       public int getLength()
       {
  +      if(dtm_iter!=null)
  +      {
           return dtm_iter.getLength();
  +      }
  +      else
  +      {
  +        int count=0;
  +        for(int handle=m_firstChild;
  +            handle!=DTM.NULL;
  +            handle=m_parentDTM.getNextSibling(handle))
  +          ++count;
  +        return count;
  +      }
       }
   }
  
  
  
  1.9       +7 -8      xml-xalan/java/src/org/apache/xml/dtm/ref/DTMNodeProxy.java
  
  Index: DTMNodeProxy.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMNodeProxy.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DTMNodeProxy.java	2001/10/05 21:37:08	1.8
  +++ DTMNodeProxy.java	2001/10/11 15:58:18	1.9
  @@ -355,14 +355,13 @@
      */
     public final NodeList getChildNodes()
     {
  -    throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
  -		
  -		// Annoyingly, AxisIterators do not currently implement DTMIterator, so
  -		// the following simple solution is not avaiable.
  -		//
  -		//DTMAxisIterator it=dtm.getAxisIterator(Axis.CHILD);
  -		//it.setStartNode(node);
  -		//return new DTMNodeList(it);
  +                
  +    // Annoyingly, AxisIterators do not currently implement DTMIterator, so
  +    // we can't just wap DTMNodeList around an Axis.CHILD iterator.
  +    // Instead, we've created a special-case operating mode for that object.
  +    return new DTMNodeList(dtm,node);
  +
  +    // throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
     }
   
     /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org


Mime
View raw message