com.jivesoftware.spark.component.spelling
Class InputTextParser

java.lang.Object
  extended bycom.wintertree.ssce.StringWordParser
      extended bycom.jivesoftware.spark.component.spelling.InputTextParser
All Implemented Interfaces:
java.util.Enumeration, java.io.Serializable, com.wintertree.ssce.WordParser

public class InputTextParser
extends com.wintertree.ssce.StringWordParser

This class is based on the Swing example work that Wintertree provides with their spelling package. What they provided was insufficient in that it was written to work with an instance of JTextArea.

Author:
Derek DeMoro
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.wintertree.ssce.StringWordParser
cachedWord, cursor, is1stWord, isHyphenDelimiter, nReplacements, nWords, subWordLength, theString
 
Constructor Summary
InputTextParser(javax.swing.JTextPane textPane, boolean isHyphenDelim)
           
 
Method Summary
 void deleteText(int numChars)
          Delete characters from the text starting at the current cursor position.
 int deleteWord()
           
 void highlightWord()
          Highlight the current word in the text area.
 void insertText(int pos, java.lang.String newText)
          Calls the three argument version of this method with null.
 void insertText(int pos, java.lang.String newText, javax.swing.text.AttributeSet as)
          Insert text at a specified position.
 void replaceWord(java.lang.String newWord)
          Replace the word at the current position with a new word.
 void updateText()
          Report that the contents of the TextPane have changed.
 
Methods inherited from class com.wintertree.ssce.StringWordParser
deleteWord, findWordStart, getCursor, getNumReplacements, getNumWords, getPrevWord, getWord, hasMoreElements, includeCharInWord, includeCharInWord, is1stWordChar, isDoubledWord, isFirstWord, isWordChar, nextElement, nextWord, setCursor, setText, setWordLength, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InputTextParser

public InputTextParser(javax.swing.JTextPane textPane,
                       boolean isHyphenDelim)
Parameters:
textPane - The JTextPane component to parse.
isHyphenDelim - true if a hyphen is to be considered a word delimiter, false if it's part of a word.
Method Detail

deleteText

public void deleteText(int numChars)
                throws java.util.NoSuchElementException
Delete characters from the text starting at the current cursor position.

Parameters:
numChars - the number of characters to delete.
Throws:
java.util.NoSuchElementException - thrown in a delete beyond the end of the string.

deleteWord

public int deleteWord()

highlightWord

public void highlightWord()
Highlight the current word in the text area.


insertText

public void insertText(int pos,
                       java.lang.String newText)
Calls the three argument version of this method with null.

Parameters:
pos - The position at which new text is to be inserted.
newText - The text to insert.

insertText

public void insertText(int pos,
                       java.lang.String newText,
                       javax.swing.text.AttributeSet as)
Insert text at a specified position.

Parameters:
pos - The position at which new text is to be inserted.
newText - The text to insert.
as - the attribute set to use with the text, if null then it attempts to get the attribute set at the position of specified by the first argument

replaceWord

public void replaceWord(java.lang.String newWord)
                 throws java.util.NoSuchElementException
Replace the word at the current position with a new word.

Parameters:
newWord - The word to replace the word at the current position.
Throws:
java.util.NoSuchElementException - The cursor is positioned at the end of the string.

updateText

public void updateText()
Report that the contents of the TextPane have changed. This method must be called if the TextPane is edited by the user or updated by other software. Currently, it causes checking of the TextPane to restart.

LOKI: who know's what the hell this is doing really -- am i to believe that there's somehow listeners on the StringBuffer instance (theString) that knows when i've reset the text? maybe if they subclassed it, i guess... :-/