1 package org.apache.lucene.search; 2 3 18 19 import java.io.IOException ; 20 import org.apache.lucene.index.*; 21 22 final class PhrasePositions { 23 int doc; int position; int count; int offset; TermPositions tp; PhrasePositions next; 30 PhrasePositions(TermPositions t, int o) { 31 tp = t; 32 offset = o; 33 } 34 35 final boolean next() throws IOException { if (!tp.next()) { 37 tp.close(); doc = Integer.MAX_VALUE; return false; 40 } 41 doc = tp.doc(); 42 position = 0; 43 return true; 44 } 45 46 final boolean skipTo(int target) throws IOException { 47 if (!tp.skipTo(target)) { 48 tp.close(); doc = Integer.MAX_VALUE; return false; 51 } 52 doc = tp.doc(); 53 position = 0; 54 return true; 55 } 56 57 58 final void firstPosition() throws IOException { 59 count = tp.freq(); nextPosition(); 61 } 62 63 final boolean nextPosition() throws IOException { 64 if (count-- > 0) { position = tp.nextPosition() - offset; 66 return true; 67 } else 68 return false; 69 } 70 } 71 | Popular Tags |