cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections/iterators IteratorChain.java
scolebourne2003/12/29 08:07:53 Modified:collections/src/test/org/apache/commons/collections/iterators TestIteratorChain.java collections/src/java/org/apache/commons/collections/iterators IteratorChain.java Log: Enable zero iterators in the chain to function Revision ChangesPath 1.7 +16 -3 jakarta-commons/collections/src/test/org/apache/commons/collections/iterators/TestIteratorChain.java Index: TestIteratorChain.java === RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/iterators/TestIteratorChain.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- TestIteratorChain.java1 Oct 2003 21:54:55 - 1.6 +++ TestIteratorChain.java29 Dec 2003 16:07:53 - 1.7 @@ -180,5 +180,18 @@ assertEquals(C,chain.next()); assertTrue(should not have next,!chain.hasNext()); } + +public void testEmptyChain() { +IteratorChain chain = new IteratorChain(); +assertEquals(false, chain.hasNext()); +try { +chain.next(); +fail(); +} catch (NoSuchElementException ex) {} +try { +chain.remove(); +fail(); +} catch (IllegalStateException ex) {} +} + } - 1.8 +70 -85 jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/IteratorChain.java Index: IteratorChain.java === RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/IteratorChain.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- IteratorChain.java3 Dec 2003 11:37:44 - 1.7 +++ IteratorChain.java29 Dec 2003 16:07:53 - 1.8 @@ -61,28 +61,28 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; -import java.util.NoSuchElementException; +import org.apache.commons.collections.IteratorUtils; import org.apache.commons.collections.list.UnmodifiableList; /** - * pAn IteratorChain is an Iterator that wraps one or - * more Iterators. When any method from the - * Iterator interface is called, the IteratorChain will - * proxy to a single underlying Iterator. The - * IteratorChain will invoke the Iterators in sequence until - * all Iterators are exhausted completely./p - * - * pUnder many circumstances, linking Iterators together - * in this manner is more efficient (and convenient) - * than reading out the contents of each Iterator into a - * List and creating a new Iterator./p - * - * pCalling a method that adds new Iteratoriafter - * a method in the Iterator interface - * has been called/i will result in an - * UnsupportedOperationException. Subclasses should itake care/i - * to not alter the underlying List of Iterators./p + * An IteratorChain is an Iterator that wraps a number of Iterators. + * p + * This class makes mutiple iterators look like one to the caller + * When any method from the Iterator interface is called, the IteratorChain + * will delegate to a single underlying Iterator. The IteratorChain will + * invoke the Iterators in sequence until all Iterators are exhausted. + * p + * Under many circumstances, linking Iterators together in this manner is + * more efficient (and convenient) than reading out the contents of each + * Iterator into a List and creating a new Iterator. + * p + * Calling a method that adds new Iteratoriafter a method in the Iterator + * interface has been called/i will result in an UnsupportedOperationException. + * Subclasses should itake care/i to not alter the underlying List of Iterators. + * p + * NOTE: As from version 3.0, the IteratorChain may contain no + * iterators. In this case the class will function as an empty iterator. * * @since Commons Collections 2.1 * @version $Revision$ $Date$ @@ -92,26 +92,30 @@ */ public class IteratorChain implements Iterator { + /** The chain of iterators */ protected final List iteratorChain = new ArrayList(); +/** The index of the current iterator */ protected int currentIteratorIndex = 0; +/** The current iterator */ protected Iterator currentIterator = null; -// the last used Iterator is the Iterator upon which -// next() or hasNext() was most recently called -// used for the remove() operation only +/** + * The last used Iterator is the Iterator upon which + * next() or hasNext() was most recently called + * used for the remove() operation only + */ protected Iterator lastUsedIterator = null; -
cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections/iterators IteratorChain.java FilterIterator.java ProxyListIterator.java CollatingIterator.java UniqueFilterIterator.java FilterListIterator.java ListIteratorWrapper.java EnumerationIterator.java SingletonIterator.java TransformIterator.java SingletonListIterator.java ProxyIterator.java IteratorEnumeration.java
scolebourne2003/09/29 15:02:34 Modified:collections/src/java/org/apache/commons/collections/iterators IteratorChain.java FilterIterator.java ProxyListIterator.java CollatingIterator.java UniqueFilterIterator.java FilterListIterator.java ListIteratorWrapper.java EnumerationIterator.java SingletonIterator.java TransformIterator.java SingletonListIterator.java ProxyIterator.java IteratorEnumeration.java Log: Javadoc format for code Revision ChangesPath 1.6 +5 -5 jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/IteratorChain.java Index: IteratorChain.java === RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/IteratorChain.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- IteratorChain.java31 Aug 2003 17:25:49 - 1.5 +++ IteratorChain.java29 Sep 2003 22:02:33 - 1.6 @@ -127,7 +127,7 @@ } /** - * Constructs a new CodeIteratorChain/Code over the two + * Constructs a new codeIteratorChain/code over the two * given iterators. * * @param a the first child iterator @@ -141,7 +141,7 @@ } /** - * Constructs a new CodeIteratorChain/Code over the array + * Constructs a new codeIteratorChain/code over the array * of iterators. * * @param iterators the array of iterators @@ -155,7 +155,7 @@ } /** - * Constructs a new CodeIteratorChain/Code over the collection + * Constructs a new codeIteratorChain/code over the collection * of iterators. * * @param iterators the collection of iterators 1.5 +5 -5 jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/FilterIterator.java Index: FilterIterator.java === RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/FilterIterator.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- FilterIterator.java 31 Aug 2003 17:25:49 - 1.4 +++ FilterIterator.java 29 Sep 2003 22:02:33 - 1.5 @@ -87,7 +87,7 @@ //- /** - * Constructs a new CodeFilterIterator/Code that will not function + * Constructs a new codeFilterIterator/code that will not function * until [EMAIL PROTECTED] #setIterator(Iterator) setIterator} is invoked. */ public FilterIterator() { @@ -95,7 +95,7 @@ } /** - * Constructs a new CodeFilterIterator/Code that will not function + * Constructs a new codeFilterIterator/code that will not function * until [EMAIL PROTECTED] #setPredicate(Predicate) setPredicate} is invoked. * * @param iterator the iterator to use @@ -105,7 +105,7 @@ } /** - * Constructs a new CodeFilterIterator/Code that will use the + * Constructs a new codeFilterIterator/code that will use the * given iterator and predicate. * * @param iterator the iterator to use 1.5 +4 -4 jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/ProxyListIterator.java Index: ProxyListIterator.java === RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/ProxyListIterator.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ProxyListIterator.java31 Aug 2003 17:25:49 - 1.4 +++ ProxyListIterator.java29 Sep 2003 22:02:33 - 1.5 @@ -78,7 +78,7 @@ //- /** - * Constructs a new CodeProxyListIterator/Code that will not + * Constructs a new codeProxyListIterator/code that will not * function until [EMAIL PROTECTED] #setListIterator(ListIterator) setListIterator} * is invoked. */ @@ -87,7 +87,7 @@ } /** - * Constructs a new CodeProxyListIterator/Code that will use the + * Constructs a new codeProxyListIterator/code that will use the * given list iterator. * * @param iterator the list iterator to use 1.8 +11 -11 jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/CollatingIterator.java Index: CollatingIterator.java
cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections/iterators IteratorChain.java ListIteratorWrapper.java IteratorEnumeration.java
scolebourne2003/01/15 13:46:55 Modified:collections/src/java/org/apache/commons/collections/iterators IteratorChain.java ListIteratorWrapper.java IteratorEnumeration.java Log: Update licence Update since and version tags Revision ChangesPath 1.4 +10 -12 jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/IteratorChain.java Index: IteratorChain.java === RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/IteratorChain.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- IteratorChain.java31 Oct 2002 21:55:23 - 1.3 +++ IteratorChain.java15 Jan 2003 21:46:55 - 1.4 @@ -1,13 +1,10 @@ /* * $Header$ - * $Revision$ - * $Date$ - * * * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2001 The Apache Software Foundation. All rights + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -23,11 +20,11 @@ *distribution. * * 3. The end-user documentation included with the redistribution, if - *any, must include the following acknowlegement: + *any, must include the following acknowledgment: * This product includes software developed by the *Apache Software Foundation (http://www.apache.org/). - *Alternately, this acknowlegement may appear in the software itself, - *if and wherever such third-party acknowlegements normally appear. + *Alternately, this acknowledgment may appear in the software itself, + *if and wherever such third-party acknowledgments normally appear. * * 4. The names The Jakarta Project, Commons, and Apache Software *Foundation must not be used to endorse or promote products derived @@ -36,7 +33,7 @@ * * 5. Products derived from this software may not be called Apache *nor may Apache appear in their names without prior written - *permission of the Apache Group. + *permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -85,10 +82,11 @@ * UnsupportedOperationException. Subclasses should itake care/i * to not alter the underlying List of Iterators./p * - * @since 2.1 + * @since Commons Collections 2.1 + * @version $Revision$ $Date$ + * * @author Morgan Delagrange - * @author a href=mailto:[EMAIL PROTECTED];Stephen Colebourne/a - * @version $Id$ + * @author Stephen Colebourne */ public class IteratorChain implements Iterator { 1.3 +12 -12 jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/ListIteratorWrapper.java Index: ListIteratorWrapper.java === RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/ListIteratorWrapper.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ListIteratorWrapper.java 17 Aug 2002 11:33:09 - 1.2 +++ ListIteratorWrapper.java 15 Jan 2003 21:46:55 - 1.3 @@ -1,13 +1,10 @@ /* * $Header$ - * $Revision$ - * $Date$ - * * * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2002 The Apache Software Foundation. All rights + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -23,11 +20,11 @@ *distribution. * * 3. The end-user documentation included with the redistribution, if - *any, must include the following acknowlegement: + *any, must include the following acknowledgment: * This product includes software developed by the *Apache Software Foundation (http://www.apache.org/). - *Alternately, this acknowlegement may appear in the software itself, - *if and wherever such third-party acknowlegements normally appear. + *Alternately, this acknowledgment may appear in the software itself, + *if and wherever such third-party acknowledgments normally appear. * * 4. The names The Jakarta Project, Commons, and Apache Software *Foundation must not be used to endorse or promote products derived @@ -36,7 +33,7 @@ * * 5. Products derived from this software may not be called Apache *nor may Apache appear