Package com.inet.jortho
Class Tokenizer
- java.lang.Object
-
- com.inet.jortho.Tokenizer
-
class Tokenizer extends java.lang.Object
Break the text and words and search for misspelling.
-
-
Field Summary
Fields Modifier and Type Field Description private LanguageBundle
bundle
private Dictionary
dictionary
private javax.swing.text.Document
doc
private int
endOffset
end offset of current paragraphprivate int
endSentence
private int
endWord
private boolean
isFirstWordInSentence
private SpellCheckerOptions
options
private int
paragraphOffset
start offset of current paragraphprivate java.lang.String
phrase
private java.lang.String
sentence
private java.text.BreakIterator
sentences
private int
startSentence
private int
startWord
private int
wordOffset
private java.text.BreakIterator
words
-
Constructor Summary
Constructors Constructor Description Tokenizer(javax.swing.text.JTextComponent jText, Dictionary dictionary, java.util.Locale locale, int startOffset, int endOffset, SpellCheckerOptions options)
Create a tokenizer for the selected range.Tokenizer(javax.swing.text.JTextComponent jText, Dictionary dictionary, java.util.Locale locale, int offset, SpellCheckerOptions options)
Create a Tokenizer for the current paragraphTokenizer(javax.swing.text.JTextComponent jText, Dictionary dictionary, java.util.Locale locale, SpellCheckerOptions options)
Create a tokenizer for the completely text document.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) int
getWordOffset()
Get start offset of the last misspelling in the JTextComponent.(package private) boolean
isFirstWordInSentence()
Was the last invalid word the first word in a sentence.private boolean
isWebAddress(java.lang.String word)
Check if the word is a web address.private void
loadSentences()
Loads the sentences of the current paragraph.(package private) java.lang.String
nextInvalidWord()
Get the next misspelling word.private boolean
nextParagraph()
Initialize the variables for the next paragraph.private void
nextSentence()
Load the next Sentence in the word breaker.private void
setSentencesText()
Call sentences.setText( String ) based on the current value of paragraphOffset.(package private) void
updatePhrase()
Update the text after a word was replaced.
-
-
-
Field Detail
-
doc
private final javax.swing.text.Document doc
-
options
private final SpellCheckerOptions options
-
bundle
private final LanguageBundle bundle
-
paragraphOffset
private int paragraphOffset
start offset of current paragraph
-
endOffset
private int endOffset
end offset of current paragraph
-
phrase
private java.lang.String phrase
-
dictionary
private final Dictionary dictionary
-
sentences
private java.text.BreakIterator sentences
-
startSentence
private int startSentence
-
endSentence
private int endSentence
-
startWord
private int startWord
-
endWord
private int endWord
-
sentence
private java.lang.String sentence
-
words
private java.text.BreakIterator words
-
wordOffset
private int wordOffset
-
isFirstWordInSentence
private boolean isFirstWordInSentence
-
-
Constructor Detail
-
Tokenizer
Tokenizer(javax.swing.text.JTextComponent jText, Dictionary dictionary, java.util.Locale locale, SpellCheckerOptions options)
Create a tokenizer for the completely text document.
-
Tokenizer
Tokenizer(javax.swing.text.JTextComponent jText, Dictionary dictionary, java.util.Locale locale, int offset, SpellCheckerOptions options)
Create a Tokenizer for the current paragraph- Parameters:
jText
- the checking JTextComponentdictionary
- the used Dictionarylocale
- the used Locale, is needed for the word and sentence breakeroffset
- the current offset.
-
Tokenizer
Tokenizer(javax.swing.text.JTextComponent jText, Dictionary dictionary, java.util.Locale locale, int startOffset, int endOffset, SpellCheckerOptions options)
Create a tokenizer for the selected range.
-
-
Method Detail
-
nextInvalidWord
java.lang.String nextInvalidWord()
Get the next misspelling word. If not found then it return null.
-
isWebAddress
private boolean isWebAddress(java.lang.String word)
Check if the word is a web address. This means a email address or web page address.- Parameters:
word
- the word that should be check. It can not be null and can not include any whitespace.- Returns:
- true if it is a web address.
-
isFirstWordInSentence
boolean isFirstWordInSentence()
Was the last invalid word the first word in a sentence.- Returns:
- true if it was the first word.
-
nextParagraph
private boolean nextParagraph()
Initialize the variables for the next paragraph.- Returns:
- true, if there is a next paragraph
-
loadSentences
private void loadSentences()
Loads the sentences of the current paragraph.
-
setSentencesText
private void setSentencesText()
Call sentences.setText( String ) based on the current value of paragraphOffset.
-
nextSentence
private void nextSentence()
Load the next Sentence in the word breaker.
-
getWordOffset
int getWordOffset()
Get start offset of the last misspelling in the JTextComponent.
-
updatePhrase
void updatePhrase()
Update the text after a word was replaced. The changes in the text should be only after the current word offset.
-
-