|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectBasicWordIter
public class BasicWordIter
Utility class used to iterate either forward or backward through the tokens in a single string of text.
Created: Dec 13, 2004
Field Summary | |
---|---|
protected int |
maxWordPos
Word position of the last token |
protected String |
text
The original text to which the tokens refer |
protected Token[] |
tokens
Array of tokens, holding words from the current chunk |
protected int |
tokNum
Current token this iterator is pointed at |
protected int |
wordPos
Word position of the curren token |
Fields inherited from interface WordIter |
---|
FIELD_END, FIELD_START, TERM_END, TERM_END_PLUS, TERM_START |
Constructor Summary | |
---|---|
protected |
BasicWordIter()
Do-nothing constructor - should only be used by derived classes that perform their own initialization. |
|
BasicWordIter(String text,
TokenStream stream)
Construct the iterator and read in tokens from the given stream. |
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 WordIter.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 targetPos,
boolean force)
Reposition the iterator at the first word whose position is greater than or equal to 'wordPos'. |
void |
seekLast(int targetPos,
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 |
Methods inherited from class Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected String text
protected Token[] tokens
protected int tokNum
protected int wordPos
protected int maxWordPos
Constructor Detail |
---|
public BasicWordIter(String text, TokenStream stream) throws IOException
text
- text represented by the tokensstream
- stream of tokens from the text
IOException
- If something goes wrong reading from 'stream'protected BasicWordIter()
Method Detail |
---|
public Object clone()
WordIter
clone
in interface WordIter
clone
in class Object
public boolean next(boolean force)
WordIter
next
in interface WordIter
force
- true to ignore section boundaries
public boolean prev(boolean force)
WordIter
prev
in interface WordIter
force
- true to ignore section boundaries
public void seekFirst(int targetPos, boolean force)
WordIter
seekFirst
in interface WordIter
targetPos
- Position to seek toforce
- true to ignore section boundariespublic void seekLast(int targetPos, boolean force)
WordIter
seekLast
in interface WordIter
targetPos
- Position to seek toforce
- true to ignore section boundariespublic MarkPos getPos(int startOrEnd)
WordIter
getPos
in interface WordIter
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.public void getPos(MarkPos pos, int startOrEnd)
WordIter
WordIter.getPos(int)
using the iterator's current position.
getPos
in interface WordIter
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.public final String term()
WordIter
term
in interface WordIter
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |