Using the SpellChecker Control
SpellChecker Control provides a simple java interface
com.bea.powertoys.spellchecker.SpellChecker. The interface is mentioned
below.
com.bea.powertoys.spellcheck.SpellingError[] checkSpelling(java.util.List words) throws java.io.IOException;
Input Parameter
SpellChecker interface takes only one parameter
java.util.List words
|
List of words (as
java.lang.String objects) to be cheked for spelling errors. This
parameter cannot be null.
|
Invoking the control
checkSpelling method of the SpellChecker is invoked as follows:
List words = new ArrayList();
words.add("helli");
SpellingError[] spellingErrors = control.checkSpelling(words);
Using the result
Control returns a array of com.bea.powertoys.spellcheck.SpellingError
objects.
If the returned array is zero length, it means that there are no
errors identified for the words provided to the control. Incase the
word(s) contains error the returned array will not be of zero
length.
com.bea.powertoys.spellcheck.SpellingError provides a simple interface
to extract the result of 'word' failing spell check. It provides four
methods as described below:
public int getErrorIndex();
Failing word is located at this index, in the word list provided.
public String getOrignalWord();
Failing word, which has failed for spell check.
public String[] getSuggestions();
Suggestions for the failing word as string array.
public String suggestionsAsString();
Suggestions for the failing word as comma delimited string.
Note
Presently SpellChecker only uses english dictionary, hence can only
check spellings for english words.
The Java Page Flow sample that accompanies the SpellChecker Control
demonstrates
how to use the control.