com.wallstreetwise.app.jspell.domain
Class JSpellDictionaryLocal

java.lang.Object
  extended by com.wallstreetwise.app.jspell.domain.JSpellDictionary
      extended by com.wallstreetwise.app.jspell.domain.JSpellDictionaryLocal
All Implemented Interfaces:
JSpellDictionaryAccessor

public class JSpellDictionaryLocal
extends JSpellDictionary

This class manages local access to a JSpell dictionary.


Field Summary
static java.lang.String defaultCountry
          System default country.
static java.lang.String defaultDirectory
          System default directory.
static java.lang.String defaultLanguage
          System default language.
static java.lang.String defaultVersion
          Default version.
protected  java.lang.String dictionaryCountry
          The country code for the dictionary.
protected  java.lang.String dictionaryDirectory
          The directory for the dictionary files.
protected  java.lang.String dictionaryLanguage
          The language that this dictionary is using.
protected  java.lang.String dictionaryVersion
          The version code for the dictionary.
 
Fields inherited from class com.wallstreetwise.app.jspell.domain.JSpellDictionary
batchCount, batchSize, currentError, dictionaryReady, errorCache, errors, forceUpperCase, ignoreDoubleWords, ignoreFirstCaps, ignoreIrregularCaps, ignoreUpper, ignoreWords, ignoreWordsWithNumbers, learnWords, maxSuggestions, nextWord, suggestions, validWords
 
Constructor Summary
JSpellDictionaryLocal()
          Constructor which accepts no parameters and sets the dictionary to the value of the defaultFile variable.
JSpellDictionaryLocal(java.lang.String directory, java.lang.String language, java.lang.String country)
          Creates and initializes the JSpellDictionaryLocal object with the directory, language and country of the local dictionary.
JSpellDictionaryLocal(java.lang.String directory, java.lang.String language, java.lang.String country, java.lang.String version)
          Creates and initializes the JSpellDictionaryLocal object with the directory, language and country of the local dictionary.
 
Method Summary
 boolean checkWord(JSpellWordBundle word)
          Accepts a JSpellWordBundle to be checked against the dictionary.
 boolean checkWord(JSpellWordBundle word, Suggestions suggestions)
          Check a JSpellWordBundle.
 void close()
          Close the local dictionary.
 int getBufferHit()
          Get buffering statistics
 int getBufferMiss()
          Get buffering statistics
 java.lang.String getDictionaryCountry()
          Returns the country of the dictionary.
 java.lang.String getDictionaryDirectory()
          Returns the directory containing the JSpell dictionary.
 java.lang.String getDictionaryLanguage()
          Returns the language of the dictionary.
 java.lang.String getDictionaryVersion()
          Returns the version of the dictionary.
 void learnWord(java.lang.String word)
          Persist a word to the dictionary file.
 void open()
          This method is called to open the local dictionary.
 void removeWord(java.lang.String word)
          Remove a word from the dictionary file.
 void resetBufferStatistics()
          Reset buffer statistics
 void setDictionary(java.lang.String directory, java.lang.String language, java.lang.String country, java.lang.String version)
          Set the directory of the dictionary file, the language and country.
 void setDictionaryFileName(java.lang.String dictionaryFileName)
          Deprecated. see setDictionaryDirectory
 boolean wordIsInIndex(java.lang.String wordToCheck)
           
 
Methods inherited from class com.wallstreetwise.app.jspell.domain.JSpellDictionary
addFrequentWords, adjustErrorPositions, checkCaps, checkCaps, getBatchSize, getCurrentError, getDictionaryReady, getForceUpperCase, getIgnoreDoubleWords, getIgnoreFirstCaps, getIgnoreIrregularCaps, getIgnoreUpper, getIgnoreWordsWithNumbers, getLearnWords, getNextError, ignoreWord, init, learnWordManual, resetAll, resetErrors, setBatchSize, setDictionaryReady, setForceUpperCase, setIgnoreDoubleWords, setIgnoreFirstCaps, setIgnoreIrregularCaps, setIgnoreUpper, setIgnoreWordsWithNumbers, setLearnWords, setMaxSuggestions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dictionaryLanguage

protected java.lang.String dictionaryLanguage
The language that this dictionary is using.


dictionaryCountry

protected java.lang.String dictionaryCountry
The country code for the dictionary.


dictionaryVersion

protected java.lang.String dictionaryVersion
The version code for the dictionary.


dictionaryDirectory

protected java.lang.String dictionaryDirectory
The directory for the dictionary files.


defaultLanguage

public static java.lang.String defaultLanguage
System default language.


defaultCountry

public static java.lang.String defaultCountry
System default country.


defaultDirectory

public static java.lang.String defaultDirectory
System default directory.


defaultVersion

public static java.lang.String defaultVersion
Default version.

Constructor Detail

JSpellDictionaryLocal

public JSpellDictionaryLocal()
Constructor which accepts no parameters and sets the dictionary to the value of the defaultFile variable.


JSpellDictionaryLocal

public JSpellDictionaryLocal(java.lang.String directory,
                             java.lang.String language,
                             java.lang.String country)
Creates and initializes the JSpellDictionaryLocal object with the directory, language and country of the local dictionary.

Parameters:
directory - directory containing the JSpell dictionary file.
language - The language of the dictionary.
country - The country of the dictionary.

JSpellDictionaryLocal

public JSpellDictionaryLocal(java.lang.String directory,
                             java.lang.String language,
                             java.lang.String country,
                             java.lang.String version)
Creates and initializes the JSpellDictionaryLocal object with the directory, language and country of the local dictionary.

Parameters:
directory - directory containing the JSpell dictionary file.
language - The language of the dictionary.
country - The country of the dictionary.
version - The version of the dictionary, Medical, Legal, [custom].
Method Detail

setDictionary

public final void setDictionary(java.lang.String directory,
                                java.lang.String language,
                                java.lang.String country,
                                java.lang.String version)
Set the directory of the dictionary file, the language and country.

Parameters:
directory - directory where the dictionary file is located.
language - language of the dictionary.
country - country of the dictionary.

setDictionaryFileName

public final void setDictionaryFileName(java.lang.String dictionaryFileName)
Deprecated. see setDictionaryDirectory

Set the file name of the dictionary to use.

Parameters:
dictionaryFileName - no longer used.

getDictionaryLanguage

public final java.lang.String getDictionaryLanguage()
Returns the language of the dictionary.

Returns:
a String value representing the language.

getDictionaryCountry

public final java.lang.String getDictionaryCountry()
Returns the country of the dictionary.

Returns:
a String representing the country.

getDictionaryVersion

public final java.lang.String getDictionaryVersion()
Returns the version of the dictionary.

Returns:
a String representing the version.

getDictionaryDirectory

public final java.lang.String getDictionaryDirectory()
Returns the directory containing the JSpell dictionary.

Returns:
a String representing the dictionary directory.

open

public final void open()
                throws JSpellException
This method is called to open the local dictionary.

Throws:
JSpellException - an Exception object if there was an error opening the dictionary.

close

public final void close()
Close the local dictionary. This should be called before opening a new JSpell dictionary.


checkWord

public final boolean checkWord(JSpellWordBundle word,
                               Suggestions suggestions)
                        throws java.lang.Exception
Check a JSpellWordBundle.

Parameters:
word - a JSpellWordBundle object.
suggestions - a Suggestions object.
Returns:
true or false.
Throws:
java.lang.Exception - an Exception object.

wordIsInIndex

public final boolean wordIsInIndex(java.lang.String wordToCheck)

checkWord

public final boolean checkWord(JSpellWordBundle word)
                        throws java.lang.Exception
Accepts a JSpellWordBundle to be checked against the dictionary. Returns true if the caller can send more words to be checked before hitting the batchSize limitations. Returning false, indicates that the caller should check errors.

Specified by:
checkWord in interface JSpellDictionaryAccessor
Overrides:
checkWord in class JSpellDictionary
Parameters:
word - a JSpellWordBundle object.
Returns:
true or false.
Throws:
java.lang.Exception - an Exception object.

learnWord

public final void learnWord(java.lang.String word)
Persist a word to the dictionary file.

Specified by:
learnWord in interface JSpellDictionaryAccessor
Overrides:
learnWord in class JSpellDictionary
Parameters:
word - a String.

removeWord

public final void removeWord(java.lang.String word)
Remove a word from the dictionary file.

Parameters:
word - a String.

resetBufferStatistics

public final void resetBufferStatistics()
Reset buffer statistics


getBufferHit

public final int getBufferHit()
Get buffering statistics

Returns:
Returns the number of times the buffer was accessed instead of accessing the disk.

getBufferMiss

public final int getBufferMiss()
Get buffering statistics

Returns:
Returns the number of times the disk was accessed instead of the buffer.


JSpell SDK 2004 Spell Checker for the Java (tm) Platform
Copyright © 1996-2005 The Solution Cafe Inc, All Rights Reserved - http://www.thesolutioncafe.com