diff --git a/src/java/org/apache/commons/collections/iterators/CollatingIterator.java b/src/java/org/apache/commons/collections/iterators/CollatingIterator.java index 44513194a..2aa905781 100644 --- a/src/java/org/apache/commons/collections/iterators/CollatingIterator.java +++ b/src/java/org/apache/commons/collections/iterators/CollatingIterator.java @@ -253,6 +253,20 @@ public class CollatingIterator implements Iterator { it.remove(); } + /** + * Returns the index of the iterator that returned the last element. + * + * @return the index of the iterator that returned the last element + * @throws IllegalStateException if there is no last returned element + */ + public int getIteratorIndex() { + if (lastReturned == -1) { + throw new IllegalStateException("No value has been returned yet"); + } + + return lastReturned; + } + // Private Methods // ------------------------------------------------------------------- /** diff --git a/src/test/org/apache/commons/collections/iterators/TestCollatingIterator.java b/src/test/org/apache/commons/collections/iterators/TestCollatingIterator.java index b844a7d15..2453edfb5 100644 --- a/src/test/org/apache/commons/collections/iterators/TestCollatingIterator.java +++ b/src/test/org/apache/commons/collections/iterators/TestCollatingIterator.java @@ -104,6 +104,7 @@ public class TestCollatingIterator extends AbstractTestIterator { for(int i=0;i