FileDocCategorySizeDatePackage
PhrasePositions.javaAPI DocApache Lucene 2.2.02609Sat Jun 16 22:20:34 BST 2007org.apache.lucene.search

PhrasePositions

public final class PhrasePositions extends Object
Position of a term in a document that takes into account the term offset within the phrase.

Fields Summary
int
doc
int
position
int
count
int
offset
TermPositions
tp
PhrasePositions
next
boolean
repeats
Constructors Summary
PhrasePositions(TermPositions t, int o)

    tp = t;
    offset = o;
  
Methods Summary
final voidfirstPosition()

    count = tp.freq();				  // read first pos
    nextPosition();
  
final booleannext()

	  // increments to next doc
    if (!tp.next()) {
      tp.close();				  // close stream
      doc = Integer.MAX_VALUE;			  // sentinel value
      return false;
    }
    doc = tp.doc();
    position = 0;
    return true;
  
final booleannextPosition()
Go to next location of this term current document, and set position as location - offset, so that a matching exact phrase is easily identified when all PhrasePositions have exactly the same position.

    if (count-- > 0) {				  // read subsequent pos's
      position = tp.nextPosition() - offset;
      return true;
    } else
      return false;
  
final booleanskipTo(int target)

    if (!tp.skipTo(target)) {
      tp.close();				  // close stream
      doc = Integer.MAX_VALUE;			  // sentinel value
      return false;
    }
    doc = tp.doc();
    position = 0;
    return true;