com.jspell.domain
Class JSpellDictionaryLocal

java.lang.Object
  extended by com.jspell.domain.JSpellDictionary
      extended by com.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 defaultDirectory
          System default directory.
 
Fields inherited from class com.jspell.domain.JSpellDictionary
batchCount, batchSize, defaultCountry, defaultLanguage, defaultVersion, errors, language, learnWords, maxSuggestions, suggestions
 
Constructor Summary
JSpellDictionaryLocal()
          Constructor which accepts no parameters and sets the dictionary to the value of the defaultFile variable.
JSpellDictionaryLocal(java.lang.String directory, Language language)
           
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 getDictionaryDirectory()
          Returns the directory containing the JSpell 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
 java.lang.String toString()
           
 boolean wordIsInIndex(java.lang.String wordToCheck)
          Accepts a single word as a String.
 
Methods inherited from class com.jspell.domain.JSpellDictionary
adjustErrorPositions, checkCaps, checkCaps, getBatchSize, getCurrentError, getDictionaryCountry, getDictionaryLanguage, getDictionaryReady, getDictionaryVersion, getForceUpperCase, getIgnoreDoubleWords, getIgnoreFirstCaps, getIgnoreIrregularCaps, getIgnoreUpper, getIgnoreWordsWithNumbers, getLanguage, getLearnWords, getNextError, ignoreWord, init, isValidWord, learnWordManual, resetAll, resetErrors, setBatchSize, setDictionaryReady, setForceUpperCase, setIgnoreDoubleWords, setIgnoreFirstCaps, setIgnoreIrregularCaps, setIgnoreUpper, setIgnoreWordsWithNumbers, setLanguage, setLearnWords, setMaxSuggestions, validWordsPut
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultDirectory

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

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].

JSpellDictionaryLocal

public JSpellDictionaryLocal(java.lang.String directory,
                             Language language)
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.

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()
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)
Accepts a single word as a String. Returns true if the word is present in the dictionary, or false if not found.

Parameters:
wordToCheck - a String object.
Returns:
true or false.
Throws:
java.lang.Exception - an Exception object.

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.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


JSpell SDK - Spell Checker for the Java ™ Platform
Copyright © 2009 Page Scholar Inc, All Rights Reserved - http://www.jspell.com