org.apache.lucene.mark
Interface WordIter

All Superinterfaces:
Cloneable
All Known Implementing Classes:
BasicWordIter, BoundedWordIter, ChunkedWordIter, XtfChunkedWordIter

public interface WordIter
extends Cloneable

Interface for iterating over the contents of a field or document on a word-oriented basis. Instances of this class are used for context and hit marking operations by ContextMarker. Optionally, derived classes can support semi-rigid section boundaries within the text; the context for a given hit will never cross one of these boundaries.

Created: Dec 17, 2004

Author:
Martin Haye

Field Summary
static int FIELD_END
          See getPos(int) or getPos(MarkPos,int)
static int FIELD_START
          See getPos(int) or getPos(MarkPos,int)
static int TERM_END
          See getPos(int) or getPos(MarkPos,int)
static int TERM_END_PLUS
          See getPos(int) or getPos(MarkPos,int)
static int TERM_START
          See getPos(int) or getPos(MarkPos,int)
 
Method Summary
 Object clone()
          Make an exact, independent, copy of this iterator
 MarkPos getPos(int startOrEnd)
          Retrieve the start or end of the current position.
 void getPos(MarkPos pos, int startOrEnd)
          Replace the position within a MarkPos created by getPos(int) using the iterator's current position.
 boolean next(boolean force)
          Advance to the next word.
 boolean prev(boolean force)
          Back up to the previous word.
 void seekFirst(int wordPos, boolean force)
          Reposition the iterator at the first word whose position is greater than or equal to 'wordPos'.
 void seekLast(int wordPos, boolean force)
          Reposition the iterator at the last word whose position is less than or equal to 'wordPos'.
 String term()
          Retrieve the text of the term at the current position
 

Field Detail

FIELD_START

static final int FIELD_START
See getPos(int) or getPos(MarkPos,int)

See Also:
Constant Field Values

TERM_START

static final int TERM_START
See getPos(int) or getPos(MarkPos,int)

See Also:
Constant Field Values

TERM_END

static final int TERM_END
See getPos(int) or getPos(MarkPos,int)

See Also:
Constant Field Values

TERM_END_PLUS

static final int TERM_END_PLUS
See getPos(int) or getPos(MarkPos,int)

See Also:
Constant Field Values

FIELD_END

static final int FIELD_END
See getPos(int) or getPos(MarkPos,int)

See Also:
Constant Field Values
Method Detail

clone

Object clone()
Make an exact, independent, copy of this iterator


next

boolean next(boolean force)
Advance to the next word. If 'force' is set, ignore any section boundary between this word and the next.

Parameters:
force - true to ignore section boundaries
Returns:
true if there was another word to advance to, false if we've reached then end (or, if 'force' is false, a section boundary).

prev

boolean prev(boolean force)
Back up to the previous word. If 'force' is set, ignore any section boundary between this word and the previous.

Parameters:
force - true to ignore section boundaries
Returns:
true if there was room to back up, false if we've reached the start (or, if 'force' is false, a section boundary).

seekFirst

void seekFirst(int wordPos,
               boolean force)
Reposition the iterator at the first word whose position is greater than or equal to 'wordPos'.

Parameters:
wordPos - Position to seek to
force - true to ignore section boundaries

seekLast

void seekLast(int wordPos,
              boolean force)
Reposition the iterator at the last word whose position is less than or equal to 'wordPos'.

Parameters:
wordPos - Position to seek to
force - true to ignore section boundaries

term

String term()
Retrieve the text of the term at the current position


getPos

MarkPos getPos(int startOrEnd)
Retrieve the start or end of the current position.

Parameters:
startOrEnd - FIELD_START for the very start of the field; TERM_START for the first character of the word; TERM_END for the last character of the word; TERM_END_PLUS for the last character plus any trailing punctuation and/or spaces; FIELD_END for the very last end of the field.

getPos

void getPos(MarkPos pos,
            int startOrEnd)
Replace the position within a MarkPos created by getPos(int) using the iterator's current position.

Parameters:
startOrEnd - FIELD_START for the very start of the field; TERM_START for the first character of the word; TERM_END for the last character of the word; TERM_END_PLUS for the last character plus any trailing punctuation and/or spaces; FIELD_END for the very last end of the field.