xalan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mor...@apache.org
Subject cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/dom DOMImpl.java FilteredStepIterator.java StepIterator.java UnionIterator.java
Date Tue, 27 Nov 2001 08:40:28 GMT
morten      01/11/27 00:40:28

  Modified:    java/src/org/apache/xalan/xsltc/dom DOMImpl.java
                        FilteredStepIterator.java StepIterator.java
                        UnionIterator.java
  Log:
  Updated the StepIterator and FilteredStepIterator's cloneIterator() and
  reset() methods so that the _isRestartable flag is set correctly.
  PR:		bugzilla 4905
  Obtained from:	n/a
  Submitted by:	morten@xml.apache.org
  Reviewed by:	morten@xml.apache.org
  
  Revision  Changes    Path
  1.62      +2 -2      xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java
  
  Index: DOMImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- DOMImpl.java	2001/11/26 14:03:09	1.61
  +++ DOMImpl.java	2001/11/27 08:40:28	1.62
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: DOMImpl.java,v 1.61 2001/11/26 14:03:09 morten Exp $
  + * @(#)$Id: DOMImpl.java,v 1.62 2001/11/27 08:40:28 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -743,7 +743,7 @@
   		_currentChild = _offsetOrChild[_startNode];
   	    else
   		_currentChild = END;
  -	    return this;
  +	    return resetPosition();
   	}
   
   	public int next() {
  
  
  
  1.3       +15 -47    xml-xalan/java/src/org/apache/xalan/xsltc/dom/FilteredStepIterator.java
  
  Index: FilteredStepIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/FilteredStepIterator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FilteredStepIterator.java	2001/10/30 15:49:32	1.2
  +++ FilteredStepIterator.java	2001/11/27 08:40:28	1.3
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: FilteredStepIterator.java,v 1.2 2001/10/30 15:49:32 morten Exp $
  + * @(#)$Id: FilteredStepIterator.java,v 1.3 2001/11/27 08:40:28 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -58,6 +58,7 @@
    *
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
  + * @author Morten Jorgensen
    *
    */
   
  @@ -66,28 +67,26 @@
   import org.apache.xalan.xsltc.NodeIterator;
   import org.apache.xalan.xsltc.runtime.BasisLibrary;
   
  -public final class FilteredStepIterator extends NodeIteratorBase {
  -    private NodeIterator _source;
  -    private NodeIterator _iterator;
  -    private final Filter _filter;
  +public final class FilteredStepIterator extends StepIterator {
  +
  +    private Filter _filter;
   	
       public FilteredStepIterator(NodeIterator source,
   				NodeIterator iterator,
   				Filter filter) {
  -	_source = source;
  -	_iterator = iterator;
  +	super(source, iterator);
   	_filter = filter;
       }
   
       public NodeIterator cloneIterator() {
  +	setNotRestartable();
   	try {
   	    final FilteredStepIterator clone =
   		(FilteredStepIterator)super.clone();
  -	    clone._isRestartable = false;
   	    clone._source = _source.cloneIterator();
  -	    clone._iterator = _iterator.cloneIterator()
  -		.setStartNode(_source.next());
  -	    return clone.resetPosition();
  +	    clone._iterator = _iterator.cloneIterator();
  +	    clone._filter = _filter;
  +	    return clone.reset();
   	}
   	catch (CloneNotSupportedException e) {
   	    BasisLibrary.runTimeError(BasisLibrary.ITERATOR_CLONE_ERR,
  @@ -95,45 +94,14 @@
   	    return null;
   	}
       }
  -    
  -    public NodeIterator setStartNode(int node) {
  -	if (_isRestartable) {
  -	    // iterator is not a clone
  -	    _source.setStartNode(_startNode = node);
  -	    _iterator.setStartNode(_source.next());
  -	    return resetPosition();
  -	}
  -	return this;
  -    }
   
  -    public NodeIterator reset() {
  -	_source.reset();
  -	_iterator.setStartNode(_source.next());
  -	return resetPosition();
  -    }
  -    
       public int next() {
  -	for (int node;;) {
  -	    while ((node = _iterator.next()) != END)
  -		if (_filter.test(node)) {
  -		    return returnNode(node);
  -		}
  -	    // local iterator ran out of nodes
  -	    // try to get new start node from source
  -	    if ((node = _source.next()) == END)
  -		return END;
  -	    else
  -		_iterator.setStartNode(node);
  +	int node;
  +	while ((node = super.next()) != END) {
  +	    if (_filter.test(node))
  +		return returnNode(node);
   	}
  -    }
  -		
  -    public void setMark() {
  -	_source.setMark();
  -	_iterator.setMark();
  +	return(node);
       }
   
  -    public void gotoMark() {
  -	_source.gotoMark();
  -	_iterator.gotoMark();
  -    }
   }
  
  
  
  1.8       +23 -9     xml-xalan/java/src/org/apache/xalan/xsltc/dom/StepIterator.java
  
  Index: StepIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/StepIterator.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- StepIterator.java	2001/10/30 15:49:32	1.7
  +++ StepIterator.java	2001/11/27 08:40:28	1.8
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: StepIterator.java,v 1.7 2001/10/30 15:49:32 morten Exp $
  + * @(#)$Id: StepIterator.java,v 1.8 2001/11/27 08:40:28 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -59,6 +59,7 @@
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
    * @author Erwin Bolwidt <ejb@klomp.org>
  + * @author Morten Jorgensen
    *
    */
   
  @@ -67,25 +68,38 @@
   import org.apache.xalan.xsltc.NodeIterator;
   import org.apache.xalan.xsltc.runtime.BasisLibrary;
   
  -public final class StepIterator extends NodeIteratorBase {
  -    private NodeIterator _source;
  -    private NodeIterator _iterator;
  +public class StepIterator extends NodeIteratorBase {
   
  +    protected NodeIterator _source;
  +    protected NodeIterator _iterator;
  +
       public StepIterator(NodeIterator source, NodeIterator iterator) {
   	_source = source;
   	_iterator = iterator;
       }
   
  +    protected void setNotRestartable() {
  +	if (_source instanceof StepIterator) {
  +	    _isRestartable = true;
  +	    if (_iterator instanceof NodeIteratorBase)
  +		((NodeIteratorBase)_iterator)._isRestartable = true;
  +	    ((StepIterator)_source).setNotRestartable();
  +	}
  +	else {
  +	    _isRestartable = false;
  +	    if (_source instanceof NodeIteratorBase)
  +		((NodeIteratorBase)_source)._isRestartable = false;
  +	    if (_iterator instanceof NodeIteratorBase)
  +		((NodeIteratorBase)_iterator)._isRestartable = true;
  +	}
  +    }
  +
       public NodeIterator cloneIterator() {
  -	_isRestartable = false;
  +	setNotRestartable();
   	try {
   	    final StepIterator clone = (StepIterator)super.clone();
   	    clone._source = _source.cloneIterator();
   	    clone._iterator = _iterator.cloneIterator();
  -	    // Special case -> _iterator must be restartable
  -	    if (clone._iterator instanceof NodeIteratorBase) {
  -		((NodeIteratorBase)(clone._iterator))._isRestartable = true;
  -	    }
   	    return clone.reset();
   	}
   	catch (CloneNotSupportedException e) {
  
  
  
  1.8       +2 -2      xml-xalan/java/src/org/apache/xalan/xsltc/dom/UnionIterator.java
  
  Index: UnionIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/UnionIterator.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- UnionIterator.java	2001/10/30 15:49:32	1.7
  +++ UnionIterator.java	2001/11/27 08:40:28	1.8
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: UnionIterator.java,v 1.7 2001/10/30 15:49:32 morten Exp $
  + * @(#)$Id: UnionIterator.java,v 1.8 2001/11/27 08:40:28 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -227,7 +227,7 @@
   	for (int i = 0; i < _free; i++) {
   	    _heap[i].iterator.reset();
   	}
  -	return(this);
  +	return resetPosition();
       }
   
   }
  
  
  

---------------------------------------------------------------------
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