1 package com.openedit.archive.update; 2 3 import java.io.IOException ; 4 import java.util.Iterator ; 5 6 import org.apache.lucene.document.Document; 7 import org.apache.lucene.search.Hits; 8 9 import sun.reflect.generics.reflectiveObjects.NotImplementedException; 10 11 import com.openedit.OpenEditRuntimeException; 12 13 public class IdIterator implements Iterator { 14 Hits hits; 15 16 int index; 17 18 public IdIterator(Hits hits) { 19 this.hits = hits; 20 index = 0; 21 } 22 23 public boolean hasNext() { 24 return index < hits.length(); 25 } 26 27 public Object next() { 28 Document doc; 29 try { 30 doc = hits.doc(index); 31 } catch (IOException e) { 32 throw new OpenEditRuntimeException("IdIterator failed: ", e); 33 } 34 String id = doc.get("id"); 35 index++; 36 return id; 37 } 38 39 public void remove() { 40 throw new NotImplementedException(); 41 } 42 43 } 44 | Popular Tags |