|
java-gnome version 4.0.15 | ||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Objectorg.gnome.glib.Glib
org.freedesktop.enchant.Enchant
public final class Enchant
Get a handle to an Enchant dictionary for spell checking.
Enchant is not itself a spell checking library; it is, rather a facade to various common spelling mechanisms. It provides a simple and sufficient API for doing spelling operations. Which actual back-end provider will be employed depends on the system and user "ordering" files.
Enchant is straight-forward to use. For possibly misspelled
word
, you can do
Enchant.init(); dict = Enchant.requestDictionary("en_CA"); if (dict.check(word)) { return "Spelled correctly!"; } else { possibles = dict.suggest(word); str.append("The word "); str.append(word); str.append(" was misspelled. You could correct it with one of:\n" for (i = 0; i < possibles.length; i++) { str.append(possibles[i]); str.append('\n'); } return str.toString(); }
Method Summary | |
---|---|
static void |
init()
|
static Dictionary |
requestDictionary(String lang)
Get a Dictionary for the specified language. |
static Dictionary |
requestPersonalWordList(String filename)
Get a Dictionary for the specified personal word list. |
Methods inherited from class org.gnome.glib.Glib |
---|
getRealName, getSystemConfigDirs, getSystemDataDirs, getUserCacheDir, getUserConfigDir, getUserDataDir, getUserName, getUserSpecialDir, reloadUserSpecialDirsCache, setProgramName |
Methods inherited from class Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void init()
public static Dictionary requestDictionary(String lang)
Languages are indicated in a locale-like form; while you can use just
the language code en
, specifying a specific language
variant such as en_UK
or fr_CA
is preferred.
Returns null
if no suitable dictionary was found.
public static Dictionary requestPersonalWordList(String filename) throws FileNotFoundException
Word lists are simple files with one word per line. By creating a Dictionary of a personal word list you can add words to a file that is independent of a normal spelling engine back-end.
FileNotFoundException
|
![]() java-gnome |
||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |