com.swabunga.spell.event
Class DocumentWordTokenizer

java.lang.Object
  extended bycom.swabunga.spell.event.DocumentWordTokenizer
All Implemented Interfaces:
WordTokenizer

public class DocumentWordTokenizer
extends java.lang.Object
implements WordTokenizer

This class tokenizes a swing document model. It also allows for the document model to be changed when corrections occur.

Author:
Jason Height ([email protected])

Constructor Summary
DocumentWordTokenizer(javax.swing.text.Document document)
           
 
Method Summary
 java.lang.String getContext()
          Returns the current text that is being tokenized (includes any changes that have been made)
 int getCurrentWordCount()
          Returns the current number of words that have been processed
 int getCurrentWordEnd()
          Returns the current end word position in the text
 int getCurrentWordPosition()
          Returns the current character position in the text
 boolean hasMoreWords()
          Returns true if there are more words that can be processed in the string
 boolean isNewSentence()
          Returns true if the current word is at the start of a sentence
 java.lang.String nextWord()
          Returns the next word in the text
 void replaceWord(java.lang.String newWord)
          Replaces the current word token
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentWordTokenizer

public DocumentWordTokenizer(javax.swing.text.Document document)
Method Detail

hasMoreWords

public boolean hasMoreWords()
Returns true if there are more words that can be processed in the string

Specified by:
hasMoreWords in interface WordTokenizer
Returns:
true if more words can be found in the text.

getCurrentWordPosition

public int getCurrentWordPosition()
Returns the current character position in the text

Specified by:
getCurrentWordPosition in interface WordTokenizer
Returns:
index of the start of the current word in the text.

getCurrentWordEnd

public int getCurrentWordEnd()
Returns the current end word position in the text

Specified by:
getCurrentWordEnd in interface WordTokenizer
Returns:
index of the end of the current word in the text.

nextWord

public java.lang.String nextWord()
Returns the next word in the text

Specified by:
nextWord in interface WordTokenizer
Returns:
the next word in the iteration.

getCurrentWordCount

public int getCurrentWordCount()
Returns the current number of words that have been processed

Specified by:
getCurrentWordCount in interface WordTokenizer
Returns:
the number of words found so far.

replaceWord

public void replaceWord(java.lang.String newWord)
Replaces the current word token

Specified by:
replaceWord in interface WordTokenizer
Parameters:
newWord - the string which should replace the current word.

getContext

public java.lang.String getContext()
Returns the current text that is being tokenized (includes any changes that have been made)

Specified by:
getContext in interface WordTokenizer
Returns:
the text being searched.

isNewSentence

public boolean isNewSentence()
Returns true if the current word is at the start of a sentence

Specified by:
isNewSentence in interface WordTokenizer
Returns:
true if the current word starts a sentence.