org.apache.lucene.search.spans
Class NearSpans.SpansCell

Object
  extended by NearSpans.SpansCell
All Implemented Interfaces:
Spans
Enclosing class:
NearSpans

private class NearSpans.SpansCell
extends Object
implements Spans

Wraps a Spans, and can be used to form a linked list.


Field Summary
private  int index
           
private  int length
           
private  NearSpans.SpansCell nextCell
           
private  NearSpans.SpansCell prevCell
           
private  float score
           
private  Spans spans
           
 
Constructor Summary
NearSpans.SpansCell(Spans spans, int index)
           
 
Method Summary
 void adjustPosition()
           
private  void checkList()
          Debugging only: check that the links are all correct
 void collectTerms(Set terms)
           
 int doc()
          Returns the document number of the current match.
 int end()
          Returns the end position of the current match.
 Explanation explain()
          Returns an explanation of how the score was arrived at.
private  void fixLinks()
          Helper function for linkAfter and linkBefore
private  boolean lessThan(NearSpans.SpansCell otherCell)
          Ordering function for cells in the list
private  void linkAfter(NearSpans.SpansCell other)
          Link the cell into the list just after 'other', or at the head if null
private  void linkBefore(NearSpans.SpansCell other)
          Link the cell into the list just before 'other', or at the tail if null
 boolean next()
          Move to the next match, returning true iff any such exists.
private  void postChange()
          Called just after advancing the cell
private  void preChange()
          Called just before advancing the cell
 float score()
          Returns the score of the current match.
 boolean skipTo(int target)
          Skips to the first match beyond the current, whose document number is greater than or equal to target.
 int start()
          Returns the start position of the current match.
 String toString()
           
private  void unlink()
          Remove the current cell from the linked list
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

spans

private Spans spans

prevCell

private NearSpans.SpansCell prevCell

nextCell

private NearSpans.SpansCell nextCell

length

private int length

score

private float score

index

private int index
Constructor Detail

NearSpans.SpansCell

public NearSpans.SpansCell(Spans spans,
                           int index)
Method Detail

next

public boolean next()
             throws IOException
Description copied from interface: Spans
Move to the next match, returning true iff any such exists.

Specified by:
next in interface Spans
Throws:
IOException

skipTo

public boolean skipTo(int target)
               throws IOException
Description copied from interface: Spans
Skips to the first match beyond the current, whose document number is greater than or equal to target.

Returns true iff there is such a match.

Behaves as if written:

   boolean skipTo(int target) {
     do {
       if (!next())
              return false;
     } while (target > doc());
     return true;
   }
 
Most implementations are considerably more efficient than that.

Specified by:
skipTo in interface Spans
Throws:
IOException

preChange

private void preChange()
Called just before advancing the cell


postChange

private void postChange()
Called just after advancing the cell


adjustPosition

public void adjustPosition()

unlink

private void unlink()
Remove the current cell from the linked list


linkBefore

private void linkBefore(NearSpans.SpansCell other)
Link the cell into the list just before 'other', or at the tail if null


linkAfter

private void linkAfter(NearSpans.SpansCell other)
Link the cell into the list just after 'other', or at the head if null


fixLinks

private void fixLinks()
Helper function for linkAfter and linkBefore


checkList

private void checkList()
Debugging only: check that the links are all correct


lessThan

private final boolean lessThan(NearSpans.SpansCell otherCell)
Ordering function for cells in the list


doc

public int doc()
Description copied from interface: Spans
Returns the document number of the current match. Initially invalid.

Specified by:
doc in interface Spans

start

public int start()
Description copied from interface: Spans
Returns the start position of the current match. Initially invalid.

Specified by:
start in interface Spans

end

public int end()
Description copied from interface: Spans
Returns the end position of the current match. Initially invalid.

Specified by:
end in interface Spans

score

public float score()
Description copied from interface: Spans
Returns the score of the current match. Initially invalid.

Specified by:
score in interface Spans

explain

public Explanation explain()
                    throws IOException
Description copied from interface: Spans
Returns an explanation of how the score was arrived at. Initially invalid.

Specified by:
explain in interface Spans
Throws:
IOException

collectTerms

public void collectTerms(Set terms)

toString

public String toString()
Overrides:
toString in class Object