public abstract class AbstractWordFinder extends java.lang.Object implements WordFinder
| Modifier and Type | Field and Description |
|---|---|
protected Word |
currentWord
The word being analyzed
|
protected Word |
nextWord
The word following the current one
|
protected java.text.BreakIterator |
sentenceIterator
An iterator to work through the sentence
|
protected boolean |
startsSentence
Indicate if the current word starts a new sentence
|
protected java.lang.String |
text
Holds the text to analyze
|
| Constructor and Description |
|---|
AbstractWordFinder()
Creates a new default AbstractWordFinder object.
|
AbstractWordFinder(java.lang.String inText)
Creates a new AbstractWordFinder object.
|
| Modifier and Type | Method and Description |
|---|---|
Word |
current()
Returns the current word in the iteration .
|
java.lang.String |
getText()
Return the text being searched.
|
boolean |
hasNext()
Indicates if there is some more word to analyze
|
protected int |
ignore(int index,
char startIgnore)
Ignores or skip over text starting from the index position specified
if it contains the
startIgnore, and until the
first non letter or digit character is encountered or end of text is
detected. |
protected int |
ignore(int index,
java.lang.Character startIgnore,
java.lang.Character endIgnore)
Ignores or skip over text starting from the index position specified
if it contains the
startIgnore, and until the
endIgnore character is encountered or end of text is
detected. |
protected int |
ignore(int index,
char startIgnore,
char endIgnore)
Ignores or skip over text starting from the index position specified
if it contains the
startIgnore, and until the
endIgnore character is encountered or end of text is
detected. |
protected int |
ignore(int index,
java.lang.String startIgnore,
java.lang.String endIgnore)
Ignores or skip over text starting from the index position specified
if it contains the
startIgnore string, and until the
endIgnore string is encountered or end of text is
detected. |
protected void |
init()
Initializes the sentenseIterator
|
protected boolean |
isWordChar(char c)
Indicates if the character at the specified character is acceptable as
part of a word.
|
protected boolean |
isWordChar(int posn)
Indicates if the character at the specified position is acceptable as
part of a word.
|
abstract Word |
next()
This method scans the text from the end of the last word, and returns
a new Word object corresponding to the next word.
|
void |
replace(java.lang.String newWord)
Replace the current word in the search with a replacement string.
|
protected void |
setSentenceIterator(Word wd)
Adjusts the sentence iterator and the startSentence flag according to the
currentWord.
|
void |
setText(java.lang.String newText)
Defines the text to search.
|
boolean |
startsSentence()
Indicates if the current word starts a new sentence.
|
java.lang.String |
toString()
Return the text being searched.
|
protected Word currentWord
protected Word nextWord
protected boolean startsSentence
protected java.lang.String text
protected java.text.BreakIterator sentenceIterator
public AbstractWordFinder(java.lang.String inText)
inText - the String to iterate through.public AbstractWordFinder()
public abstract Word next()
next in interface WordFinderpublic java.lang.String getText()
getText in interface WordFinderpublic void setText(java.lang.String newText)
setText in interface WordFindernewText - The text to be analyzedpublic Word current()
current in interface WordFinderWordNotFoundException - current word has not yet been set.public boolean hasNext()
hasNext in interface WordFinderpublic void replace(java.lang.String newWord)
replace in interface WordFindernewWord - the replacement string.WordNotFoundException - current word has not yet been set.public boolean startsSentence()
WordFinderstartsSentence in interface WordFinderWordNotFoundException - current word has not yet been set.public java.lang.String toString()
toString in class java.lang.Objectprotected void setSentenceIterator(Word wd)
wd - the wd parameter is not presently used.protected boolean isWordChar(int posn)
posn - The character position to analyze.protected boolean isWordChar(char c)
c - The character to evaluates if it can be part of a wordprotected int ignore(int index,
char startIgnore)
startIgnore, and until the
first non letter or digit character is encountered or end of text is
detected.index - The start position in text.startIgnore - The character that should be at index
position to start skipping through.protected int ignore(int index,
char startIgnore,
char endIgnore)
startIgnore, and until the
endIgnore character is encountered or end of text is
detected.index - The start position in text.startIgnore - The character that should be at index
position to start skipping through.endIgnore - The character which mark the end of skipping through. If
the value of endIgnore is null, skipping characters stop
at first non letter or digit character.protected int ignore(int index,
java.lang.Character startIgnore,
java.lang.Character endIgnore)
startIgnore, and until the
endIgnore character is encountered or end of text is
detected.index - The start position in text.startIgnore - The character that should be at index
position to start skipping through.endIgnore - The character which mark the end of skipping through. If
the value of endIgnore is null, skipping characters stop
at first non letter or digit character.protected int ignore(int index,
java.lang.String startIgnore,
java.lang.String endIgnore)
startIgnore string, and until the
endIgnore string is encountered or end of text is
detected.index - The start position in text.startIgnore - The string that should be at index
position to start skipping through.endIgnore - The string which mark the end of skipping through.protected void init()