com.jspell.domain.net
Class JSpellServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.jspell.domain.net.JSpellServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
JSpellEvolutionServlet

public class JSpellServlet
extends javax.servlet.http.HttpServlet

The JSpellServlet class is designed to be accessed from a Java client running as an applet or an application. The applet or application will use the JSpellDictionaryServlet class to manage a connection to this servlet.

See Also:
Serialized Form

Field Summary
protected  java.text.SimpleDateFormat logDateFmt
          Date format for log files.
protected static JSpellDictionaryManager manager
           
protected  java.lang.String softwareID
           
protected  long startTime
           
protected  Suggestions suggestions
           
 
Constructor Summary
JSpellServlet()
          Constructs the JSpellServlet instance.
 
Method Summary
 void destroy()
          Closes any open logging and JSpellIndex resources.
 void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Handles incoming GET requests from clients and delegates to processClientData.
protected  void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Handles incoming POST requests from clients and delegates to processClientData.
 java.lang.String getCacheSize()
          Returns the current value of the cacheSize initialized by the Servlet init and context params.
 java.lang.String getIndexDirectory()
          Returns the location of the JSpell dictionary files.
 java.lang.String getLogFileName()
          Returns the current value of the logFileName.
 java.lang.String getPropertiesFile()
          Returns the current value of the propertiesFile.
 java.lang.String getServletInfo()
          Returns the name, copyright and authorship of the JSpellServlet.
protected  void indexChanged()
          Called whenever the language or country changes.
 void init(javax.servlet.ServletConfig config)
          Called whenever the JSpellServlet is loaded by the Java servlet container.
 void logAccess(java.lang.String msg)
          Provides logging ability for the JSpellServlet instances.
protected  void logFileNameChanged()
          Called whenever the logFileName changes.
 void markUsageBegin()
           
 void markUsageEnd()
           
protected  java.lang.StringBuffer processClientData(java.util.Vector text, JSpellDictionaryLocal jdLocal)
          Handles incoming client requests to search for a word and return suggestions or add a new word to the dictionary.
protected  void propertiesFileChanged()
          Called whenever the propertiesFile property is changed and upon initialization of the servlet.
 void setCacheSize(java.lang.String cacheSize)
          Changes the cacheSize value.
 void setIndexDirectory(java.lang.String indexDirectory)
          Sets the location of the JSpell dictionary files.
 void setLogFileName(java.lang.String logFileName)
          Changes the logFileName value.
 void setPropertiesFile(java.lang.String propertiesFile)
          Change the propertiesFile value.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

suggestions

protected Suggestions suggestions

manager

protected static JSpellDictionaryManager manager

logDateFmt

protected java.text.SimpleDateFormat logDateFmt
Date format for log files.


softwareID

protected java.lang.String softwareID

startTime

protected long startTime
Constructor Detail

JSpellServlet

public JSpellServlet()
Constructs the JSpellServlet instance.

Method Detail

propertiesFileChanged

protected void propertiesFileChanged()
                              throws javax.servlet.ServletException
Called whenever the propertiesFile property is changed and upon initialization of the servlet.

Throws:
javax.servlet.ServletException - a ServletException object.

indexChanged

protected void indexChanged()
                     throws javax.servlet.ServletException
Called whenever the language or country changes.

Throws:
javax.servlet.ServletException - a ServletException object.

logFileNameChanged

protected void logFileNameChanged()
                           throws javax.servlet.ServletException
Called whenever the logFileName changes.

Throws:
javax.servlet.ServletException - a ServletException object.

setPropertiesFile

public void setPropertiesFile(java.lang.String propertiesFile)
                       throws javax.servlet.ServletException
Change the propertiesFile value.

Parameters:
propertiesFile - a String.
Throws:
javax.servlet.ServletException - a ServletException object.

getPropertiesFile

public java.lang.String getPropertiesFile()
Returns the current value of the propertiesFile.

Returns:
a String.

setIndexDirectory

public void setIndexDirectory(java.lang.String indexDirectory)
                       throws javax.servlet.ServletException
Sets the location of the JSpell dictionary files.

Parameters:
indexDirectory - a String.
Throws:
javax.servlet.ServletException - a ServletException object.

getIndexDirectory

public java.lang.String getIndexDirectory()
Returns the location of the JSpell dictionary files.

Returns:
a String.

setLogFileName

public void setLogFileName(java.lang.String logFileName)
                    throws javax.servlet.ServletException
Changes the logFileName value.

Parameters:
logFileName - a String.
Throws:
javax.servlet.ServletException - a ServletException object.

getLogFileName

public java.lang.String getLogFileName()
Returns the current value of the logFileName.

Returns:
a String.

setCacheSize

public void setCacheSize(java.lang.String cacheSize)
                  throws javax.servlet.ServletException
Changes the cacheSize value. Takes a String and internally converts to int.

Parameters:
cacheSize - a String containing an int value representing the cache size.
Throws:
javax.servlet.ServletException - a ServletException object.

getCacheSize

public java.lang.String getCacheSize()
Returns the current value of the cacheSize initialized by the Servlet init and context params.

Returns:
a String.

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Called whenever the JSpellServlet is loaded by the Java servlet container.

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
Parameters:
config - a ServletConfig object.
Throws:
javax.servlet.ServletException - a ServletException object.

processClientData

protected final java.lang.StringBuffer processClientData(java.util.Vector text,
                                                         JSpellDictionaryLocal jdLocal)
Handles incoming client requests to search for a word and return suggestions or add a new word to the dictionary.

Parameters:
text - a Vector.
jdLocal - a JSpellDictionaryLocal object.
Returns:
a String.

logAccess

public final void logAccess(java.lang.String msg)
Provides logging ability for the JSpellServlet instances.

Parameters:
msg - a String.

destroy

public void destroy()
Closes any open logging and JSpellIndex resources.

Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class javax.servlet.GenericServlet

getServletInfo

public java.lang.String getServletInfo()
Returns the name, copyright and authorship of the JSpellServlet.

Specified by:
getServletInfo in interface javax.servlet.Servlet
Overrides:
getServletInfo in class javax.servlet.GenericServlet
Returns:
a String.

markUsageBegin

public void markUsageBegin()

markUsageEnd

public void markUsageEnd()

doPost

protected void doPost(javax.servlet.http.HttpServletRequest req,
                      javax.servlet.http.HttpServletResponse resp)
               throws javax.servlet.ServletException,
                      java.io.IOException
Handles incoming POST requests from clients and delegates to processClientData.

Overrides:
doPost in class javax.servlet.http.HttpServlet
Parameters:
req - an HttpServletRequest object.
resp - an HttpServletResponse object.
Throws:
javax.servlet.ServletException - a ServletException object.
java.io.IOException - an IOException object.

doGet

public void doGet(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse resp)
           throws javax.servlet.ServletException,
                  java.io.IOException
Handles incoming GET requests from clients and delegates to processClientData.

Overrides:
doGet in class javax.servlet.http.HttpServlet
Parameters:
req - an HttpServletRequest object.
resp - an HttpServletResponse object.
Throws:
javax.servlet.ServletException - a ServletException object.
java.io.IOException - an IOException object.


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