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.java new file mode 100644 index 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 Kelvin Tan + * @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; + } +}