lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kelv...@apache.org
Subject cvs commit: jakarta-lucene-sandbox/contributions/searchbean/src/java/org/apache/lucene/beans IteratorAdapter.java
Date Sat, 31 Aug 2002 01:19:43 GMT
kelvint     2002/08/30 18:19:43

  Added:       contributions/searchbean/src/java/org/apache/lucene/beans
                        IteratorAdapter.java
  Log:
  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.
  
  Useful when you want to pass the HitsIterator object into Velocity as a collection
  and you want to be able to do something like
  #foreach($hit in $hitIterator)
    ##display stuff
  #end
  
  Revision  Changes    Path
  1.1                  jakarta-lucene-sandbox/contributions/searchbean/src/java/org/apache/lucene/beans/IteratorAdapter.java
  
  Index: IteratorAdapter.java
  ===================================================================
  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:kelvint@apache.org">Kelvin Tan</a>
   * @version $Id: IteratorAdapter.java,v 1.1 2002/08/31 01:19:42 kelvint Exp $
   */
  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;
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>


Mime
View raw message