scolebourne 2003/01/15 13:51:05
Modified: collections/src/java/org/apache/commons/collections/iterators
SingletonIterator.java SingletonListIterator.java
Log:
Implement new Resetable Iterator interfaces
Update licence
Update since and version tags
Revision Changes Path
1.3 +19 -14
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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SingletonIterator.java 17 Aug 2002 11:29:38 -0000 1.2
+++ SingletonIterator.java 15 Jan 2003 21:51:05 -0000 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 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
@@ -62,16 +59,18 @@
import java.util.Iterator;
import java.util.NoSuchElementException;
+
/**
* <p><code>SingletonIterator</code> is an {@link Iterator} over a single
* object instance.</p>
*
- * @since 2.0
+ * @since Commons Collections 2.0
+ * @version $Revision$ $Date$
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
- * @author <a href="mailto:[EMAIL PROTECTED]">Stephen Colebourne</a>
- * @version $Revision$
+ * @author Stephen Colebourne
*/
-public class SingletonIterator implements Iterator {
+public class SingletonIterator implements ResetableIterator {
private boolean first = true;
private Object object;
@@ -111,7 +110,6 @@
throw new NoSuchElementException();
}
Object answer = object;
- object = null;
first = false;
return answer;
}
@@ -123,6 +121,13 @@
*/
public void remove() {
throw new UnsupportedOperationException("remove() is not supported by this
iterator");
+ }
+
+ /**
+ * Reset the iterator to the start.
+ */
+ public void reset() {
+ first = true;
}
}
1.3 +19 -13
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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SingletonListIterator.java 19 Aug 2002 21:56:18 -0000 1.2
+++ SingletonListIterator.java 15 Jan 2003 21:51:05 -0000 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 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
@@ -66,11 +63,12 @@
* <p><code>SingletonIterator</code> is an {@link ListIterator} over a single
* object instance.</p>
*
- * @since 2.1
- * @author <a href="mailto:[EMAIL PROTECTED]">Stephen Colebourne</a>
- * @version $Id$
+ * @since Commons Collections 2.1
+ * @version $Revision$ $Date$
+ *
+ * @author Stephen Colebourne
*/
-public class SingletonListIterator implements ListIterator {
+public class SingletonListIterator implements ResetableListIterator {
private boolean first = true;
private boolean nextCalled = false;
@@ -193,6 +191,14 @@
throw new IllegalStateException();
}
this.object = obj;
+ }
+
+ /**
+ * Reset the iterator back to the start.
+ */
+ public void reset() {
+ first = true;
+ nextCalled = false;
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>