1 package org.apache.lucene.search; 2 3 18 19 import java.io.IOException ; 20 21 26 public abstract class Scorer { 27 private Similarity similarity; 28 29 32 protected Scorer(Similarity similarity) { 33 this.similarity = similarity; 34 } 35 36 37 public Similarity getSimilarity() { 38 return this.similarity; 39 } 40 41 46 public void score(HitCollector hc) throws IOException { 47 while (next()) { 48 hc.collect(doc(), score()); 49 } 50 } 51 52 60 protected boolean score(HitCollector hc, int max) throws IOException { 61 while (doc() < max) { 62 hc.collect(doc(), score()); 63 if (!next()) 64 return false; 65 } 66 return true; 67 } 68 69 73 public abstract boolean next() throws IOException ; 74 75 78 public abstract int doc(); 79 80 84 public abstract float score() throws IOException ; 85 86 101 public abstract boolean skipTo(int target) throws IOException ; 102 103 108 public abstract Explanation explain(int doc) throws IOException ; 109 110 } 111 | Popular Tags |