1 package org.apache.lucene.search; 2 3 import org.apache.lucene.index.IndexReader; 4 5 import java.io.IOException ; 6 7 25 public abstract class SortComparator 26 implements SortComparatorSource { 27 28 public ScoreDocComparator newComparator (final IndexReader reader, final String fieldname) 30 throws IOException { 31 final String field = fieldname.intern(); 32 final Comparable [] cachedValues = FieldCache.DEFAULT.getCustom (reader, field, SortComparator.this); 33 34 return new ScoreDocComparator() { 35 36 public int compare (ScoreDoc i, ScoreDoc j) { 37 return cachedValues[i.doc].compareTo (cachedValues[j.doc]); 38 } 39 40 public Comparable sortValue (ScoreDoc i) { 41 return cachedValues[i.doc]; 42 } 43 44 public int sortType(){ 45 return SortField.CUSTOM; 46 } 47 }; 48 } 49 50 63 protected abstract Comparable getComparable (String termtext); 64 65 } | Popular Tags |