1 12 13 package com.openedit.modules.search; 14 15 import java.io.IOException ; 16 import java.util.Iterator ; 17 18 import org.apache.lucene.search.Hits; 19 20 import com.openedit.OpenEditRuntimeException; 21 22 23 28 public class HitIterator implements Iterator 29 { 30 protected Hits fieldHits; 31 protected int hitCount = 0; 32 protected int startOffset = 0; 33 34 public HitIterator(Hits inHits) 35 { 36 setHits(inHits); 37 } 38 39 public HitIterator() 40 { 41 } 42 public void setStartOffset( int inStart) 43 { 44 startOffset = inStart; 45 } 46 51 public void setHits(Hits inHits) 52 { 53 fieldHits = inHits; 54 } 55 56 61 public Hits getHits() 62 { 63 return fieldHits; 64 } 65 66 69 public boolean hasNext() 70 { 71 if (hitCount < getHits().length()) 72 { 73 return true; 74 } 75 else 76 { 77 return false; 78 } 79 } 80 81 84 public Object next() 85 { 86 try 87 { 88 return getHits().doc(startOffset + hitCount++); 89 } 90 catch (IOException ex) 91 { 92 throw new OpenEditRuntimeException(ex); 93 } 94 } 95 96 99 public void remove() 100 { 101 } 102 } 103 | Popular Tags |