zongaro     2002/11/05 02:32:26

  Modified:    java/src/org/apache/xml/dtm/ref Tag: XSLTC_DTM
                        DTMNodeList.java
  Added:       java/src/org/apache/xml/dtm/ref Tag: XSLTC_DTM
                        DTMAxisIterNodeList.java DTMChildIterNodeList.java
                        DTMNodeListBase.java
  Log:
  Splitting DTMNodeList into classes based on the iterator contained.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.5.12.2  +46 -84    
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.5.12.1
  retrieving revision 1.5.12.2
  diff -u -r1.5.12.1 -r1.5.12.2
  --- DTMNodeList.java  17 Apr 2002 18:13:48 -0000      1.5.12.1
  +++ DTMNodeList.java  5 Nov 2002 10:32:26 -0000       1.5.12.2
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999,2002 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -88,67 +88,48 @@
    *
    * <p>State: In progress!!</p>
    * */
  -public class DTMNodeList implements org.w3c.dom.NodeList
  -{
  -  private DTMIterator dtm_iter;
  -  private boolean valid=true;
  -  private int m_firstChild;
  -  private DTM m_parentDTM;
  -
  -  //================================================================
  -  // Methods unique to this class
  -
  -  /** Public constructor: Wrap a DTMNodeList around an existing
  -   * and preconfigured DTMIterator
  -   *
  -   * WARNING: THIS HAS THE SIDE EFFECT OF ISSUING setShouldCacheNodes(true)
  -   * AGAINST THE DTMIterator.
  -   * */
  -  public DTMNodeList(DTMIterator dtmIterator)
  -  {
  -    if (dtmIterator != null)
  -    {
  -      int pos = dtmIterator.getCurrentPos();
  -      try
  -      {
  -        dtm_iter=(DTMIterator)dtmIterator.cloneWithReset();
  -      }
  -      catch(CloneNotSupportedException cnse) {}
  -      dtm_iter.setShouldCacheNodes(true);
  -      dtm_iter.runTo(-1);
  -      dtm_iter.setCurrentPos(pos);
  +public class DTMNodeList extends DTMNodeListBase {
  +    private DTMIterator m_iter;
  +
  +    //================================================================
  +    // Methods unique to this class
  +    private DTMNodeList() {
       }
  -  }
   
  -  /** 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.
  -   * */
  -  DTMIterator getDTMIterator()
  -    {
  -      return dtm_iter;
  +    /**
  +     * Public constructor: Wrap a DTMNodeList around an existing
  +     * and preconfigured DTMIterator
  +     *
  +     * WARNING: THIS HAS THE SIDE EFFECT OF ISSUING setShouldCacheNodes(true)
  +     * AGAINST THE DTMIterator.
  +     *
  +     */
  +    public DTMNodeList(DTMIterator dtmIterator) {
  +        if (dtmIterator != null) {
  +            int pos = dtmIterator.getCurrentPos();
  +            try {
  +                m_iter=(DTMIterator)dtmIterator.cloneWithReset();
  +            } catch(CloneNotSupportedException cnse) {
  +                m_iter = dtmIterator;
  +            }
  +            m_iter.setShouldCacheNodes(true);
  +            m_iter.runTo(-1);
  +            m_iter.setCurrentPos(pos);
  +        }
  +    }
  +
  +    /**
  +     * Access the wrapped DTMIterator. I'm not sure whether anyone will
  +     * need this or not, but let's write it and think about it.
  +     *
  +     */
  +    DTMIterator getDTMIterator() {
  +        return m_iter;
       }
     
   
  -  //================================================================
  -  // org.w3c.dom.NodeList API follows
  +    //================================================================
  +    // org.w3c.dom.NodeList API follows
   
       /**
        * Returns the <code>index</code>th item in the collection. If 
  @@ -161,38 +142,19 @@
        */
       public Node item(int index)
       {
  -      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);
  -      }
  +        if (m_iter != null) {
  +            int handle=m_iter.item(index);
  +            return m_iter.getDTM(handle).getNode(handle);
  +        } else {
  +            return null;
  +        }
       }
   
       /**
        * 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()
  -    {
  -      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;
  -      }
  +    public int getLength() {
  +        return (m_iter != null) ? m_iter.getLength() : 0;
       }
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +180 -0    
xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMAxisIterNodeList.java
  
  
  
  
  1.1.2.1   +152 -0    
xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMChildIterNodeList.java
  
  
  
  
  1.1.2.1   +119 -0    
xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMNodeListBase.java
  
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to