1 16 17 package org.apache.lucene.search; 18 19 import java.util.Iterator ; 20 import java.util.NoSuchElementException ; 21 22 29 public class HitIterator implements Iterator { 30 private Hits hits; 31 private int hitNumber = 0; 32 33 36 HitIterator(Hits hits) { 37 this.hits = hits; 38 } 39 40 43 public boolean hasNext() { 44 return hitNumber < hits.length(); 45 } 46 47 52 public Object next() { 53 if (hitNumber == hits.length()) 54 throw new NoSuchElementException (); 55 56 Object next = new Hit(hits, hitNumber); 57 hitNumber++; 58 return next; 59 } 60 61 66 public void remove() { 67 throw new UnsupportedOperationException (); 68 } 69 70 73 public int length() { 74 return hits.length(); 75 } 76 } 77 78 | Popular Tags |