scolebourne 2003/11/14 14:58:27
Modified: collections/src/java/org/apache/commons/collections
IteratorUtils.java Flat3Map.java
AbstractDualBidiMap.java
collections/src/java/org/apache/commons/collections/iterators
EntrySetMapIterator.java LoopingIterator.java
ObjectArrayIterator.java
ObjectArrayListIterator.java SingletonIterator.java
ArrayListIterator.java SingletonListIterator.java
ArrayIterator.java
collections/src/test/org/apache/commons/collections/iterators
TestSingletonIterator.java
TestSingletonListIterator.java
collections/src/test/org/apache/commons/collections
TestIteratorUtils.java
Added: collections/src/java/org/apache/commons/collections/iterators
ResettableListIterator.java ResettableIterator.java
Removed: collections/src/java/org/apache/commons/collections/iterators
ResetableIterator.java ResetableMapIterator.java
ResetableOrderedIterator.java
ResetableListIterator.java
ResetableOrderedMapIterator.java
Log:
Rename ResetableIterator to ResettableIterator
Remove Map and Ordered variants to avoid too many classes
Revision Changes Path
1.17 +56 -45
jakarta-commons/collections/src/java/org/apache/commons/collections/IteratorUtils.java
Index: IteratorUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/IteratorUtils.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- IteratorUtils.java 8 Nov 2003 19:26:28 -0000 1.16
+++ IteratorUtils.java 14 Nov 2003 22:58:27 -0000 1.17
@@ -83,11 +83,10 @@
import org.apache.commons.collections.iterators.MapIterator;
import org.apache.commons.collections.iterators.ObjectArrayIterator;
import org.apache.commons.collections.iterators.ObjectArrayListIterator;
-import org.apache.commons.collections.iterators.ResetableIterator;
-import org.apache.commons.collections.iterators.ResetableListIterator;
-import org.apache.commons.collections.iterators.ResetableMapIterator;
-import org.apache.commons.collections.iterators.ResetableOrderedIterator;
-import org.apache.commons.collections.iterators.ResetableOrderedMapIterator;
+import org.apache.commons.collections.iterators.OrderedIterator;
+import org.apache.commons.collections.iterators.OrderedMapIterator;
+import org.apache.commons.collections.iterators.ResettableIterator;
+import org.apache.commons.collections.iterators.ResettableListIterator;
import org.apache.commons.collections.iterators.SingletonIterator;
import org.apache.commons.collections.iterators.SingletonListIterator;
import org.apache.commons.collections.iterators.TransformIterator;
@@ -113,23 +112,23 @@
/**
* An iterator over no elements
*/
- public static final ResetableIterator EMPTY_ITERATOR = new EmptyIterator();
+ public static final ResettableIterator EMPTY_ITERATOR = new EmptyIterator();
/**
* A list iterator over no elements
*/
- public static final ResetableListIterator EMPTY_LIST_ITERATOR = new
EmptyListIterator();
+ public static final ResettableListIterator EMPTY_LIST_ITERATOR = new
EmptyListIterator();
/**
* An ordered iterator over no elements
*/
- public static final ResetableOrderedIterator EMPTY_ORDERED_ITERATOR = new
EmptyOrderedIterator();
+ public static final OrderedIterator EMPTY_ORDERED_ITERATOR = new
EmptyOrderedIterator();
/**
* A map iterator over no elements
*/
- public static final ResetableMapIterator EMPTY_MAP_ITERATOR = new
EmptyMapIterator();
+ public static final MapIterator EMPTY_MAP_ITERATOR = new EmptyMapIterator();
/**
* An ordered map iterator over no elements
*/
- public static final ResetableOrderedMapIterator EMPTY_ORDERED_MAP_ITERATOR =
new EmptyOrderedMapIterator();
+ public static final OrderedMapIterator EMPTY_ORDERED_MAP_ITERATOR = new
EmptyOrderedMapIterator();
/**
* Prevents instantiation.
@@ -137,9 +136,8 @@
private IteratorUtils() {
}
- // Iterator creators
- //----------------------------------------------------------------------
-
+ // Empty
+ //-----------------------------------------------------------------------
/**
* Gets an empty iterator.
* <p>
@@ -148,7 +146,7 @@
*
* @return an iterator over nothing
*/
- public static ResetableIterator emptyIterator() {
+ public static ResettableIterator emptyIterator() {
return EMPTY_ITERATOR;
}
@@ -160,7 +158,7 @@
*
* @return a list iterator over nothing
*/
- public static ResetableListIterator emptyListIterator() {
+ public static ResettableListIterator emptyListIterator() {
return EMPTY_LIST_ITERATOR;
}
@@ -172,7 +170,7 @@
*
* @return an ordered iterator over nothing
*/
- public static ResetableOrderedIterator emptyOrderedIterator() {
+ public static OrderedIterator emptyOrderedIterator() {
return EMPTY_ORDERED_ITERATOR;
}
@@ -184,7 +182,7 @@
*
* @return a map iterator over nothing
*/
- public static ResetableMapIterator emptyMapIterator() {
+ public static MapIterator emptyMapIterator() {
return EMPTY_MAP_ITERATOR;
}
@@ -196,10 +194,12 @@
*
* @return a map iterator over nothing
*/
- public static ResetableOrderedMapIterator emptyOrderedMapIterator() {
+ public static OrderedMapIterator emptyOrderedMapIterator() {
return EMPTY_ORDERED_MAP_ITERATOR;
}
+ // Singleton
+ //-----------------------------------------------------------------------
/**
* Gets a singleton iterator.
* <p>
@@ -209,7 +209,7 @@
* @param object the single object over which to iterate
* @return a singleton iterator over the object
*/
- public static ResetableIterator singletonIterator(Object object) {
+ public static ResettableIterator singletonIterator(Object object) {
return new SingletonIterator(object);
}
@@ -222,13 +222,12 @@
* @param object the single object over which to iterate
* @return a singleton list iterator over the object
*/
- public static ResetableListIterator singletonListIterator(Object object) {
+ public static ListIterator singletonListIterator(Object object) {
return new SingletonListIterator(object);
}
// Arrays
- //----------------------------------------------------------------------
-
+ //-----------------------------------------------------------------------
/**
* Gets an iterator over an object array.
*
@@ -236,7 +235,7 @@
* @return an iterator over the array
* @throws NullPointerException if array is null
*/
- public static ResetableIterator arrayIterator(Object[] array) {
+ public static ResettableIterator arrayIterator(Object[] array) {
return new ObjectArrayIterator(array);
}
@@ -251,7 +250,7 @@
* @throws IllegalArgumentException if the array is not an array
* @throws NullPointerException if array is null
*/
- public static ResetableIterator arrayIterator(Object array) {
+ public static ResettableIterator arrayIterator(Object array) {
return new ArrayIterator(array);
}
@@ -265,7 +264,7 @@
* than the length of the array
* @throws NullPointerException if array is null
*/
- public static ResetableIterator arrayIterator(Object[] array, int start) {
+ public static ResettableIterator arrayIterator(Object[] array, int start) {
return new ObjectArrayIterator(array, start);
}
@@ -283,7 +282,7 @@
* than the length of the array
* @throws NullPointerException if array is null
*/
- public static ResetableIterator arrayIterator(Object array, int start) {
+ public static ResettableIterator arrayIterator(Object array, int start) {
return new ArrayIterator(array, start);
}
@@ -298,7 +297,7 @@
* @throws IllegalArgumentException if end is before start
* @throws NullPointerException if array is null
*/
- public static ResetableIterator arrayIterator(Object[] array, int start, int
end) {
+ public static ResettableIterator arrayIterator(Object[] array, int start, int
end) {
return new ObjectArrayIterator(array, start, end);
}
@@ -317,10 +316,11 @@
* @throws IllegalArgumentException if end is before start
* @throws NullPointerException if array is null
*/
- public static ResetableIterator arrayIterator(Object array, int start, int end)
{
+ public static ResettableIterator arrayIterator(Object array, int start, int
end) {
return new ArrayIterator(array, start, end);
}
+ //-----------------------------------------------------------------------
/**
* Gets a list iterator over an object array.
*
@@ -328,7 +328,7 @@
* @return a list iterator over the array
* @throws NullPointerException if array is null
*/
- public static ResetableListIterator arrayListIterator(Object[] array) {
+ public static ResettableListIterator arrayListIterator(Object[] array) {
return new ObjectArrayListIterator(array);
}
@@ -343,7 +343,7 @@
* @throws IllegalArgumentException if the array is not an array
* @throws NullPointerException if array is null
*/
- public static ResetableListIterator arrayListIterator(Object array) {
+ public static ResettableListIterator arrayListIterator(Object array) {
return new ArrayListIterator(array);
}
@@ -356,7 +356,7 @@
* @throws IndexOutOfBoundsException if start is less than zero
* @throws NullPointerException if array is null
*/
- public static ResetableListIterator arrayListIterator(Object[] array, int
start) {
+ public static ResettableListIterator arrayListIterator(Object[] array, int
start) {
return new ObjectArrayListIterator(array, start);
}
@@ -373,7 +373,7 @@
* @throws IndexOutOfBoundsException if start is less than zero
* @throws NullPointerException if array is null
*/
- public static ResetableListIterator arrayListIterator(Object array, int start) {
+ public static ResettableListIterator arrayListIterator(Object array, int start)
{
return new ArrayListIterator(array, start);
}
@@ -388,7 +388,7 @@
* @throws IllegalArgumentException if end is before start
* @throws NullPointerException if array is null
*/
- public static ResetableListIterator arrayListIterator(Object[] array, int
start, int end) {
+ public static ResettableListIterator arrayListIterator(Object[] array, int
start, int end) {
return new ObjectArrayListIterator(array, start, end);
}
@@ -407,13 +407,12 @@
* @throws IllegalArgumentException if end is before start
* @throws NullPointerException if array is null
*/
- public static ResetableListIterator arrayListIterator(Object array, int start,
int end) {
+ public static ResettableListIterator arrayListIterator(Object array, int start,
int end) {
return new ArrayListIterator(array, start, end);
}
- // Iterator wrappers
- //----------------------------------------------------------------------
-
+ // Unmodifiable
+ //-----------------------------------------------------------------------
/**
* Gets an immutable version of an [EMAIL PROTECTED] Iterator}. The returned
object
* will always throw an [EMAIL PROTECTED] UnsupportedOperationException} for
@@ -451,6 +450,8 @@
return UnmodifiableMapIterator.decorate(mapIterator);
}
+ // Chained
+ //-----------------------------------------------------------------------
/**
* Gets an iterator that iterates through two [EMAIL PROTECTED] Iterator}s
* one after another.
@@ -489,6 +490,8 @@
return new IteratorChain(iterators);
}
+ // Collated
+ //-----------------------------------------------------------------------
/**
* Gets an iterator that provides an ordered iteration over the elements
* contained in a collection of ordered [EMAIL PROTECTED] Iterator}s.
@@ -548,6 +551,8 @@
return new CollatingIterator(comparator, iterators);
}
+ // Transformed
+ //-----------------------------------------------------------------------
/**
* Gets an iterator that transforms the elements of another iterator.
* <p>
@@ -568,6 +573,8 @@
return new TransformIterator(iterator, transform);
}
+ // Filtered
+ //-----------------------------------------------------------------------
/**
* Gets an iterator that filters another iterator.
* <p>
@@ -608,6 +615,8 @@
return new FilterListIterator(listIterator, predicate);
}
+ // Looping
+ //-----------------------------------------------------------------------
/**
* Gets an iterator that loops continuously over the supplied collection.
* <p>
@@ -618,13 +627,15 @@
* @param coll the collection to iterate over, not null
* @throws NullPointerException if the collection is null
*/
- public static ResetableIterator loopingIterator(Collection coll) {
+ public static ResettableIterator loopingIterator(Collection coll) {
if (coll == null) {
throw new NullPointerException("Collection must not be null");
}
return new LoopingIterator(coll);
}
+ // Views
+ //-----------------------------------------------------------------------
/**
* Gets an iterator that provides an iterator view of the given enumeration.
*
@@ -825,7 +836,7 @@
/**
* EmptyIterator class
*/
- static class EmptyIterator implements ResetableIterator {
+ static class EmptyIterator implements ResettableIterator {
EmptyIterator() {
super();
@@ -852,7 +863,7 @@
/**
* EmptyListIterator class
*/
- static class EmptyListIterator extends EmptyIterator implements
ResetableListIterator {
+ static class EmptyListIterator extends EmptyIterator implements
ResettableListIterator {
EmptyListIterator() {
super();
@@ -887,7 +898,7 @@
/**
* EmptyOrderedIterator class
*/
- static class EmptyOrderedIterator extends EmptyIterator implements
ResetableOrderedIterator {
+ static class EmptyOrderedIterator extends EmptyIterator implements
OrderedIterator, ResettableIterator {
EmptyOrderedIterator() {
super();
@@ -906,7 +917,7 @@
/**
* EmptyMapIterator class
*/
- static class EmptyMapIterator extends EmptyIterator implements
ResetableMapIterator {
+ static class EmptyMapIterator extends EmptyIterator implements MapIterator,
ResettableIterator {
EmptyMapIterator() {
super();
@@ -929,7 +940,7 @@
/**
* EmptyOrderedMapIterator class
*/
- static class EmptyOrderedMapIterator extends EmptyMapIterator implements
ResetableOrderedMapIterator {
+ static class EmptyOrderedMapIterator extends EmptyMapIterator implements
OrderedMapIterator, ResettableIterator {
EmptyOrderedMapIterator() {
super();
1.3 +4 -4
jakarta-commons/collections/src/java/org/apache/commons/collections/Flat3Map.java
Index: Flat3Map.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/Flat3Map.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Flat3Map.java 8 Nov 2003 18:49:06 -0000 1.2
+++ Flat3Map.java 14 Nov 2003 22:58:27 -0000 1.3
@@ -68,7 +68,7 @@
import org.apache.commons.collections.iterators.EntrySetMapIterator;
import org.apache.commons.collections.iterators.MapIterator;
-import org.apache.commons.collections.iterators.ResetableMapIterator;
+import org.apache.commons.collections.iterators.ResettableIterator;
/**
* A <code>Map</code> implementation that stores data in simple fields until
@@ -588,7 +588,7 @@
/**
* FlatMapIterator
*/
- static class FlatMapIterator implements ResetableMapIterator {
+ static class FlatMapIterator implements MapIterator, ResettableIterator {
private final Flat3Map iFlatMap;
private int iIndex = 0;
private boolean iCanRemove = false;
1.10 +4 -4
jakarta-commons/collections/src/java/org/apache/commons/collections/AbstractDualBidiMap.java
Index: AbstractDualBidiMap.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/AbstractDualBidiMap.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- AbstractDualBidiMap.java 8 Nov 2003 18:40:17 -0000 1.9
+++ AbstractDualBidiMap.java 14 Nov 2003 22:58:27 -0000 1.10
@@ -66,7 +66,7 @@
import org.apache.commons.collections.decorators.AbstractIteratorDecorator;
import org.apache.commons.collections.decorators.AbstractMapEntryDecorator;
import org.apache.commons.collections.iterators.MapIterator;
-import org.apache.commons.collections.iterators.ResetableMapIterator;
+import org.apache.commons.collections.iterators.ResettableIterator;
/**
* Abstract <code>BidiMap</code> implemented using two maps.
@@ -548,7 +548,7 @@
/**
* Inner class MapIterator.
*/
- protected static class BidiMapIterator implements ResetableMapIterator {
+ protected static class BidiMapIterator implements MapIterator,
ResettableIterator {
protected final AbstractDualBidiMap map;
protected Iterator iterator;
1.2 +3 -3
jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/EntrySetMapIterator.java
Index: EntrySetMapIterator.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/EntrySetMapIterator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EntrySetMapIterator.java 8 Nov 2003 18:43:13 -0000 1.1
+++ EntrySetMapIterator.java 14 Nov 2003 22:58:27 -0000 1.2
@@ -77,7 +77,7 @@
*
* @author Stephen Colebourne
*/
-public class EntrySetMapIterator implements MapIterator, ResetableMapIterator {
+public class EntrySetMapIterator implements MapIterator, ResettableIterator {
private final Map map;
private Iterator iterator;
1.6 +3 -3
jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/LoopingIterator.java
Index: LoopingIterator.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/LoopingIterator.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- LoopingIterator.java 31 Aug 2003 17:25:49 -0000 1.5
+++ LoopingIterator.java 14 Nov 2003 22:58:27 -0000 1.6
@@ -77,7 +77,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Jonathan Carlson</a>
* @author Stephen Colebourne
*/
-public class LoopingIterator implements ResetableIterator {
+public class LoopingIterator implements ResettableIterator {
/** The collection to base the iterator on */
private Collection collection;
1.9 +3 -3
jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/ObjectArrayIterator.java
Index: ObjectArrayIterator.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/ObjectArrayIterator.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ObjectArrayIterator.java 10 Oct 2003 21:06:18 -0000 1.8
+++ ObjectArrayIterator.java 14 Nov 2003 22:58:27 -0000 1.9
@@ -80,7 +80,7 @@
* @author Phil Steitz
*/
public class ObjectArrayIterator
- implements Iterator, ResetableIterator {
+ implements Iterator, ResettableIterator {
/** The array */
protected Object[] array = null;
1.10 +3 -3
jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/ObjectArrayListIterator.java
Index: ObjectArrayListIterator.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/ObjectArrayListIterator.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ObjectArrayListIterator.java 8 Nov 2003 18:37:16 -0000 1.9
+++ ObjectArrayListIterator.java 14 Nov 2003 22:58:27 -0000 1.10
@@ -81,7 +81,7 @@
* @author Phil Steitz
*/
public class ObjectArrayListIterator extends ObjectArrayIterator
- implements ListIterator, ResetableListIterator {
+ implements ListIterator, ResettableListIterator {
/**
* Holds the index of the last item returned by a call to <code>next()</code>
1.9 +3 -3
jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/SingletonIterator.java
Index: SingletonIterator.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/SingletonIterator.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- SingletonIterator.java 9 Oct 2003 20:44:32 -0000 1.8
+++ SingletonIterator.java 14 Nov 2003 22:58:27 -0000 1.9
@@ -72,7 +72,7 @@
* @author Rodney Waldhoff
*/
public class SingletonIterator
- implements Iterator, ResetableIterator {
+ implements Iterator, ResettableIterator {
private boolean beforeFirst = true;
private boolean removed = false;
1.9 +3 -3
jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/ArrayListIterator.java
Index: ArrayListIterator.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/ArrayListIterator.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ArrayListIterator.java 9 Oct 2003 20:44:32 -0000 1.8
+++ ArrayListIterator.java 14 Nov 2003 22:58:27 -0000 1.9
@@ -84,7 +84,7 @@
* @author Phil Steitz
*/
public class ArrayListIterator extends ArrayIterator
- implements ListIterator, ResetableListIterator {
+ implements ListIterator, ResettableListIterator {
/**
* Holds the index of the last item returned by a call to <code>next()</code>
1.10 +3 -3
jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/SingletonListIterator.java
Index: SingletonListIterator.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/SingletonListIterator.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SingletonListIterator.java 8 Nov 2003 18:38:27 -0000 1.9
+++ SingletonListIterator.java 14 Nov 2003 22:58:27 -0000 1.10
@@ -70,7 +70,7 @@
* @author Stephen Colebourne
* @author Rodney Waldhoff
*/
-public class SingletonListIterator implements ListIterator, ResetableListIterator {
+public class SingletonListIterator implements ListIterator, ResettableListIterator {
private boolean beforeFirst = true;
private boolean nextCalled = false;
1.7 +3 -3
jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/ArrayIterator.java
Index: ArrayIterator.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/ArrayIterator.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ArrayIterator.java 29 Sep 2003 22:37:40 -0000 1.6
+++ ArrayIterator.java 14 Nov 2003 22:58:27 -0000 1.7
@@ -80,7 +80,7 @@
* @author Neil O'Toole
* @author Stephen Colebourne
*/
-public class ArrayIterator implements ResetableIterator {
+public class ArrayIterator implements ResettableIterator {
/** The array to iterate over */
protected Object array;
1.1
jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/ResettableListIterator.java
Index: ResettableListIterator.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/ResettableListIterator.java,v
1.1 2003/11/14 22:58:27 scolebourne Exp $
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 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 Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.collections.iterators;
import java.util.ListIterator;
/**
* Interface implemented by those list iterators that can be reset back
* to an initial state.
*
* @since Commons Collections 3.0
* @version $Revision: 1.1 $ $Date: 2003/11/14 22:58:27 $
*
* @author Stephen Colebourne
*/
public interface ResettableListIterator extends ListIterator, ResettableIterator {
/**
* Resets the iterator back to the position at which the iterator
* was created.
*/
public void reset();
}
1.1
jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/ResettableIterator.java
Index: ResettableIterator.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/ResettableIterator.java,v
1.1 2003/11/14 22:58:27 scolebourne Exp $
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 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 Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.collections.iterators;
import java.util.Iterator;
/**
* Interface implemented by those iterators that can be reset back to an
* initial state.
*
* @since Commons Collections 3.0
* @version $Revision: 1.1 $ $Date: 2003/11/14 22:58:27 $
*
* @author Stephen Colebourne
*/
public interface ResettableIterator extends Iterator {
/**
* Resets the iterator back to the position at which the iterator
* was created.
*/
public void reset();
}
1.8 +4 -4
jakarta-commons/collections/src/test/org/apache/commons/collections/iterators/TestSingletonIterator.java
Index: TestSingletonIterator.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/iterators/TestSingletonIterator.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- TestSingletonIterator.java 9 Oct 2003 11:05:27 -0000 1.7
+++ TestSingletonIterator.java 14 Nov 2003 22:58:27 -0000 1.8
@@ -126,7 +126,7 @@
}
public void testSingletonIteratorRemove() {
- ResetableIterator iter = new SingletonIterator("xyzzy");
+ ResettableIterator iter = new SingletonIterator("xyzzy");
assertTrue(iter.hasNext());
assertEquals("xyzzy",iter.next());
iter.remove();
@@ -135,7 +135,7 @@
}
public void testReset() {
- ResetableIterator it = (ResetableIterator) makeObject();
+ ResettableIterator it = (ResettableIterator) makeObject();
assertEquals(true, it.hasNext());
assertEquals(testValue, it.next());
1.8 +3 -3
jakarta-commons/collections/src/test/org/apache/commons/collections/iterators/TestSingletonListIterator.java
Index: TestSingletonListIterator.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/iterators/TestSingletonListIterator.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- TestSingletonListIterator.java 9 Oct 2003 11:05:27 -0000 1.7
+++ TestSingletonListIterator.java 14 Nov 2003 22:58:27 -0000 1.8
@@ -157,7 +157,7 @@
}
public void testReset() {
- ResetableListIterator it = (ResetableListIterator) makeObject();
+ ResettableListIterator it = (ResettableListIterator) makeObject();
assertEquals(true, it.hasNext());
assertEquals(false, it.hasPrevious());
1.11 +15 -23
jakarta-commons/collections/src/test/org/apache/commons/collections/TestIteratorUtils.java
Index: TestIteratorUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestIteratorUtils.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- TestIteratorUtils.java 8 Nov 2003 19:26:29 -0000 1.10
+++ TestIteratorUtils.java 14 Nov 2003 22:58:27 -0000 1.11
@@ -69,11 +69,8 @@
import org.apache.commons.collections.iterators.MapIterator;
import org.apache.commons.collections.iterators.OrderedIterator;
import org.apache.commons.collections.iterators.OrderedMapIterator;
-import org.apache.commons.collections.iterators.ResetableIterator;
-import org.apache.commons.collections.iterators.ResetableListIterator;
-import org.apache.commons.collections.iterators.ResetableMapIterator;
-import org.apache.commons.collections.iterators.ResetableOrderedIterator;
-import org.apache.commons.collections.iterators.ResetableOrderedMapIterator;
+import org.apache.commons.collections.iterators.ResettableIterator;
+import org.apache.commons.collections.iterators.ResettableListIterator;
/**
* Tests for IteratorUtils.
@@ -125,7 +122,7 @@
public void testArrayIterator() {
Object[] objArray = {"a", "b", "c"};
- ResetableIterator iterator = IteratorUtils.arrayIterator(objArray);
+ ResettableIterator iterator = IteratorUtils.arrayIterator(objArray);
assertTrue(iterator.next().equals("a"));
assertTrue(iterator.next().equals("b"));
iterator.reset();
@@ -245,7 +242,7 @@
public void testArrayListIterator() {
Object[] objArray = {"a", "b", "c", "d"};
- ResetableListIterator iterator = IteratorUtils.arrayListIterator(objArray);
+ ResettableListIterator iterator = IteratorUtils.arrayListIterator(objArray);
assertTrue(!iterator.hasPrevious());
assertTrue(iterator.previousIndex() == -1);
assertTrue(iterator.nextIndex() == 0);
@@ -436,7 +433,7 @@
*/
public void testEmptyIterator() {
assertTrue(IteratorUtils.EMPTY_ITERATOR instanceof Iterator);
- assertTrue(IteratorUtils.EMPTY_ITERATOR instanceof ResetableIterator);
+ assertTrue(IteratorUtils.EMPTY_ITERATOR instanceof ResettableIterator);
assertEquals(false, IteratorUtils.EMPTY_ITERATOR.hasNext());
IteratorUtils.EMPTY_ITERATOR.reset();
assertSame(IteratorUtils.EMPTY_ITERATOR, IteratorUtils.EMPTY_ITERATOR);
@@ -458,8 +455,8 @@
public void testEmptyListIterator() {
assertTrue(IteratorUtils.EMPTY_LIST_ITERATOR instanceof Iterator);
assertTrue(IteratorUtils.EMPTY_LIST_ITERATOR instanceof ListIterator);
- assertTrue(IteratorUtils.EMPTY_LIST_ITERATOR instanceof ResetableIterator);
- assertTrue(IteratorUtils.EMPTY_LIST_ITERATOR instanceof
ResetableListIterator);
+ assertTrue(IteratorUtils.EMPTY_LIST_ITERATOR instanceof ResettableIterator);
+ assertTrue(IteratorUtils.EMPTY_LIST_ITERATOR instanceof
ResettableListIterator);
assertEquals(false, IteratorUtils.EMPTY_LIST_ITERATOR.hasNext());
assertEquals(0, IteratorUtils.EMPTY_LIST_ITERATOR.nextIndex());
assertEquals(-1, IteratorUtils.EMPTY_LIST_ITERATOR.previousIndex());
@@ -495,10 +492,9 @@
public void testEmptyMapIterator() {
assertTrue(IteratorUtils.EMPTY_MAP_ITERATOR instanceof Iterator);
assertTrue(IteratorUtils.EMPTY_MAP_ITERATOR instanceof MapIterator);
- assertTrue(IteratorUtils.EMPTY_MAP_ITERATOR instanceof ResetableIterator);
- assertTrue(IteratorUtils.EMPTY_MAP_ITERATOR instanceof
ResetableMapIterator);
+ assertTrue(IteratorUtils.EMPTY_MAP_ITERATOR instanceof ResettableIterator);
assertEquals(false, IteratorUtils.EMPTY_MAP_ITERATOR.hasNext());
- IteratorUtils.EMPTY_MAP_ITERATOR.reset();
+ ((ResettableIterator) IteratorUtils.EMPTY_MAP_ITERATOR).reset();
assertSame(IteratorUtils.EMPTY_MAP_ITERATOR,
IteratorUtils.EMPTY_MAP_ITERATOR);
assertSame(IteratorUtils.EMPTY_MAP_ITERATOR,
IteratorUtils.emptyMapIterator());
try {
@@ -530,11 +526,10 @@
public void testEmptyOrderedIterator() {
assertTrue(IteratorUtils.EMPTY_ORDERED_ITERATOR instanceof Iterator);
assertTrue(IteratorUtils.EMPTY_ORDERED_ITERATOR instanceof OrderedIterator);
- assertTrue(IteratorUtils.EMPTY_ORDERED_ITERATOR instanceof
ResetableIterator);
- assertTrue(IteratorUtils.EMPTY_ORDERED_ITERATOR instanceof
ResetableOrderedIterator);
+ assertTrue(IteratorUtils.EMPTY_ORDERED_ITERATOR instanceof
ResettableIterator);
assertEquals(false, IteratorUtils.EMPTY_ORDERED_ITERATOR.hasNext());
assertEquals(false, IteratorUtils.EMPTY_ORDERED_ITERATOR.hasPrevious());
- IteratorUtils.EMPTY_ORDERED_ITERATOR.reset();
+ ((ResettableIterator) IteratorUtils.EMPTY_ORDERED_ITERATOR).reset();
assertSame(IteratorUtils.EMPTY_ORDERED_ITERATOR,
IteratorUtils.EMPTY_ORDERED_ITERATOR);
assertSame(IteratorUtils.EMPTY_ORDERED_ITERATOR,
IteratorUtils.emptyOrderedIterator());
try {
@@ -559,13 +554,10 @@
assertTrue(IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR instanceof Iterator);
assertTrue(IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR instanceof MapIterator);
assertTrue(IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR instanceof
OrderedMapIterator);
- assertTrue(IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR instanceof
ResetableIterator);
- assertTrue(IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR instanceof
ResetableMapIterator);
- assertTrue(IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR instanceof
ResetableOrderedIterator);
- assertTrue(IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR instanceof
ResetableOrderedMapIterator);
+ assertTrue(IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR instanceof
ResettableIterator);
assertEquals(false, IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR.hasNext());
assertEquals(false, IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR.hasPrevious());
- IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR.reset();
+ ((ResettableIterator) IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR).reset();
assertSame(IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR,
IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR);
assertSame(IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR,
IteratorUtils.emptyOrderedMapIterator());
try {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]