public final class NoSpellChecker extends Object implements SpellChecker
SpellChecker
. Use it when no
real implementation is available.Modifier and Type | Field and Description |
---|---|
static NoSpellChecker |
INSTANCE |
ERR_DUPLICATE, ERR_NONE, ERR_PUNCTUATION, ERR_REPLACE, ERR_UNKNOWN_WORD, ERR_WRONG_CAP
Constructor and Description |
---|
NoSpellChecker() |
Modifier and Type | Method and Description |
---|---|
int |
checkNext()
Detects the next error in the input text specified
using
SpellChecker.setInput(java.lang.CharSequence) . |
CharSequence |
getInput()
Returns the input text last specified using
SpellChecker.setInput(java.lang.CharSequence) . |
int |
getPosition()
Gets the current position relatively to the current text sequence.
|
String |
getReplacement(String word)
Returns a replacement value learned using
SpellChecker.learnAutoReplacement(java.lang.String, java.lang.String) . |
String |
getSelectedLanguage()
Returns the name of the currently selected language.
|
String[] |
getSuggestions()
Returns suggestions for the erroneous word detected by
SpellChecker.checkNext() . |
String |
getWord()
Returns the erroneous word detected by
SpellChecker.checkNext() . |
boolean |
learnAutoReplacement(String word,
String replacement)
Record an ``automatic replacement'' for an erroneous word.
|
boolean |
learnSuggestion(String word,
String suggestion)
Record the best suggestion for an erroneous word.
|
boolean |
learnWord(String word,
boolean persist)
Stores a word into the personal dictionary or into the temporary
(session wise) dictionary.
|
void |
setInput(CharSequence input)
Sets the input text before calling
SpellChecker.checkNext() . |
boolean |
setSelectedLanguage(String lang)
Selects a language.
|
public static final NoSpellChecker INSTANCE
public boolean setSelectedLanguage(String lang)
SpellChecker
setSelectedLanguage
in interface SpellChecker
lang
- ISO-639-1 code of the languagetrue
if the language has been selected;
false
otherwise (unknown language, corrupted dictionary,
etc)public String getSelectedLanguage()
SpellChecker
null
.getSelectedLanguage
in interface SpellChecker
public void setInput(CharSequence input)
SpellChecker
SpellChecker.checkNext()
.setInput
in interface SpellChecker
input
- a fragment of text to check. This fragment must not begin
or end in the middle of a word.public CharSequence getInput()
SpellChecker
SpellChecker.setInput(java.lang.CharSequence)
.getInput
in interface SpellChecker
public int checkNext()
SpellChecker
SpellChecker.setInput(java.lang.CharSequence)
.checkNext
in interface SpellChecker
public int getPosition()
SpellChecker
getPosition
in interface SpellChecker
public String getWord()
SpellChecker
SpellChecker.checkNext()
.getWord
in interface SpellChecker
public String[] getSuggestions()
SpellChecker
SpellChecker.checkNext()
.
Applicable to ERR_UNKNOWN_WORD, ERR_PUNCTUATION, ERR_WRONG_CAP.
getSuggestions
in interface SpellChecker
null
) list of suggestionspublic boolean learnWord(String word, boolean persist)
SpellChecker
Notice that there is no savePersonalDictionary method. Learned words are automatically saved to disk.
learnWord
in interface SpellChecker
word
- word to learnpersist
- if true
, store word
into personal dictionary; otherwise store it in a temporary
(session wise) dictionarytrue
if the word has been learned;
false
otherwise (no language is selected, the word contains
an illegal character, etc)public boolean learnSuggestion(String word, String suggestion)
SpellChecker
The next time the word will be passed to SpellChecker.getSuggestions()
,
the replacement value will be put atop the suggestion list.
This method should be used only when the correction entered by a
user is not among the (first) suggestions proposed by
getSuggestions
.
learnSuggestion
in interface SpellChecker
word
- word to learnsuggestion
- best suggestion for wordtrue
if the word has been learned;
false
otherwise (no language is selected, the word contains
an illegal character, etc)public boolean learnAutoReplacement(String word, String replacement)
SpellChecker
learnAutoReplacement
in interface SpellChecker
word
- word to learnreplacement
- automatic replacement for wordtrue
if the word has been learned;
false
otherwise (no language is selected, the word contains
an illegal character, etc)public String getReplacement(String word)
SpellChecker
SpellChecker.learnAutoReplacement(java.lang.String, java.lang.String)
.getReplacement
in interface SpellChecker
null
if
a replacement word has not been learned