Class Tokenizer


  • class Tokenizer
    extends java.lang.Object
    Break the text and words and search for misspelling.
    • Field Detail

      • doc

        private final javax.swing.text.Document doc
      • paragraphOffset

        private int paragraphOffset
        start offset of current paragraph
      • endOffset

        private int endOffset
        end offset of current paragraph
      • phrase

        private java.lang.String phrase
      • 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 JTextComponent
        dictionary - the used Dictionary
        locale - the used Locale, is needed for the word and sentence breaker
        offset - 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.