Apache Lucene open-source search software
Although HitsIterator doesn't implement Iterator, it follows the Iterator idiom so this is just a simple adapter (really more of a wrapper) which does implement Iterator.
Kelvin Tan0a7e5168e5d1
diff --git a/sandbox/contributions/searchbean/src/java/org/apache/lucene/beans/IteratorAdapter.java b/sandbox/contributions/searchbean/src/java/org/apache/lucene/beans/IteratorAdapter.javanew file mode 100644index 00000000000..49f18c31edc--- /dev/null+++ b/sandbox/contributions/searchbean/src/java/org/apache/lucene/beans/IteratorAdapter.java@@ -0,0 +1,42 @@+package org.apache.lucene.beans;++import java.util.Iterator;++/**+ * Acts as an adapter for HitsIterator to comply with the Collections+ * API.+ *+ * @author <a href="mailto:[email protected]">Kelvin Tan</a>+ * @version $Id$+ */+public final class IteratorAdapter implements Iterator+{+ private HitsIterator hitsIterator;++ public IteratorAdapter(HitsIterator it)+ {+ this.hitsIterator = it;+ }++ public boolean hasNext()+ {+ return hitsIterator.hasNext();+ }++ public Object next()+ {+ return hitsIterator.next();+ }++ public void remove()+ {+ throw new UnsupportedOperationException(+ "HitsIterator does not " ++ "support modification of the hits!");+ }++ public HitsIterator getHitsIterator()+ {+ return hitsIterator;+ }+}