FileDocCategorySizeDatePackage
TermSpans.javaAPI DocApache Lucene 2.2.02273Sat Jun 16 22:20:32 BST 2007org.apache.lucene.search.spans

TermSpans

public class TermSpans extends Object implements Spans
Expert: Public for extension only

Fields Summary
protected TermPositions
positions
protected Term
term
protected int
doc
protected int
freq
protected int
count
protected int
position
Constructors Summary
public TermSpans(TermPositions positions, Term term)


    this.positions = positions;
    this.term = term;
    doc = -1;
  
Methods Summary
public intdoc()

    return doc;
  
public intend()

    return position + 1;
  
public org.apache.lucene.index.TermPositionsgetPositions()

    return positions;
  
public booleannext()

    if (count == freq) {
      if (!positions.next()) {
        doc = Integer.MAX_VALUE;
        return false;
      }
      doc = positions.doc();
      freq = positions.freq();
      count = 0;
    }
    position = positions.nextPosition();
    count++;
    return true;
  
public booleanskipTo(int target)

    // are we already at the correct position?
    if (doc >= target) {
      return true;
    }

    if (!positions.skipTo(target)) {
      doc = Integer.MAX_VALUE;
      return false;
    }

    doc = positions.doc();
    freq = positions.freq();
    count = 0;

    position = positions.nextPosition();
    count++;

    return true;
  
public intstart()

    return position;
  
public java.lang.StringtoString()

    return "spans(" + term.toString() + ")@" +
            (doc == -1 ? "START" : (doc == Integer.MAX_VALUE) ? "END" : doc + "-" + position);