tmiller     02/03/04 06:41:00

  Modified:    java/src/org/apache/xalan/xsltc/dom SortingIterator.java
  Log:
  bug 6693- fix by Santiago Pericas, implement a
  iterator clone method.
  
  Revision  Changes    Path
  1.2       +27 -3     
xml-xalan/java/src/org/apache/xalan/xsltc/dom/SortingIterator.java
  
  Index: SortingIterator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/SortingIterator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SortingIterator.java      17 Apr 2001 18:52:36 -0000      1.1
  +++ SortingIterator.java      4 Mar 2002 14:41:00 -0000       1.2
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: SortingIterator.java,v 1.1 2001/04/17 18:52:36 sboag Exp $
  + * @(#)$Id: SortingIterator.java,v 1.2 2002/03/04 14:41:00 tmiller Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -66,11 +66,12 @@
   
   import org.apache.xalan.xsltc.NodeIterator;
   import org.apache.xalan.xsltc.TransletException;
  +import org.apache.xalan.xsltc.runtime.BasisLibrary;
   
   public final class SortingIterator extends NodeIteratorBase {
       private final static int INIT_DATA_SIZE = 16;
  -    private final NodeIterator _source;
  -    private final NodeSortRecordFactory _factory;
  +    private NodeIterator _source;
  +    private NodeSortRecordFactory _factory;
       private NodeSortRecord[] _data;
       private int _free = 0;
       private int _current;    // index in _nodes of the next node to try
  @@ -124,6 +125,29 @@
        _current = _markedNode;
       }
       
  +    /**
  +     * Clone a <code>SortingIterator</code> by cloning its source
  +     * iterator and then sharing the factory and the array of
  +     * <code>NodeSortRecords</code>.
  +     */
  +    public NodeIterator cloneIterator() {
  +     try {
  +         final SortingIterator clone = (SortingIterator) super.clone();
  +         clone._source = _source.cloneIterator();  
  +         clone._factory = _factory;          // shared between clones
  +         clone._data = _data;                // shared between clones
  +         clone._free = _free;
  +         clone._current = _current;
  +         clone.setRestartable(false);
  +         return clone.reset();
  +     }
  +     catch (CloneNotSupportedException e) {
  +         BasisLibrary.runTimeError(BasisLibrary.ITERATOR_CLONE_ERR,
  +                                   e.toString());
  +         return null;
  +     }
  +    }
  +
       private void addRecord(NodeSortRecord record) {
        if (_free == _data.length) {
            NodeSortRecord[] newArray = new NodeSortRecord[_data.length * 2];
  
  
  

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

Reply via email to