org.indy
Class CommandHandler

java.lang.Object
  |
  +--org.indy.CommandHandler

public class CommandHandler
extends java.lang.Object

Provides the basis for TCPServer command handling.

Version:
1.0
Author:
OTG

Constructor Summary
CommandHandler(CommandHandlers collection)
          Constructs a new instance.
 
Method Summary
 void addCommandListener(CommandHandlerListener l)
          Registers an IdCommandListener instance to be informed of events from this handler.
protected  void doCommand(CommandEvent command)
          Calls all CommandListener's CommandListener#onCommand() method.
 char getCmdDelimiter()
          Gets the command delimiter for this command handler
 java.lang.String getCommand()
          Gets the command attribute of the IdCommandHandler object
 CommandHandlers getCommandHandlers()
          Returns the containing collection of this command handler.
 char getParamDelimiter()
          Gets the paramDelimiter attribute of the IdCommandHandler object
 int getReplyExceptionCode()
          Gets the replyExceptionCode attribute of the CommandHandler object
 RFCReply getReplyNormal()
          Gets the replyNormal attribute of the CommandHandler object
 StringList getResponse()
          Gets the response attribute of the CommandHandler object
 int getTag()
          Gets the tag attribute of the CommandHandler object
 boolean isDisconnected()
          Gets the disconnect attribute of the CommandHandler object
 boolean isEnabled()
          Gets the enabled attribute of the IdCommandHandler object
 boolean isParseParams()
          Gets the parseParams attribute of the CommandHandler object
 void removeCommandListener(CommandHandlerListener l)
          Unregisters an IdCommandListener instance.
 void setCmdDelimiter(char cmdDelimiter)
          Sets the command delimiter for this handler object.
 void setCommand(java.lang.String command)
          Sets command string that this handler is associated with.
 void setDisconnect(boolean disconnect)
          Sets whether this handler should disconnect from the client when it has finished.
 void setEnabled(boolean enabled)
          Enables / disables this handler.
 void setParamDelimiter(char paramDelimiter)
          Sets the parameter delimiter for this handler.
 void setParseParams(boolean parseParams)
          Sets whether this handler should attempt to parse the parameters sent to it.
 void setReplyExceptionCode(int replyExceptionCode)
          Sets the numerical code for this handler to use if an exception is encountered during processing (e.g.
 void setReplyNormal(RFCReply replyNormal)
          Sets the standard RFCReply object to use as a response to this command
 void setResponse(StringList response)
          Sets the StringList that form the textual reponse for this command handler.
 void setTag(int tag)
          Sets the tag attribute of the CommandHandler object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandHandler

public CommandHandler(CommandHandlers collection)
Constructs a new instance. Takes a reference to this handler's containing CommandHandlers collection.
Parameters:
collection - The CommandHandlers collection that contains this handler.
Method Detail

setCmdDelimiter

public void setCmdDelimiter(char cmdDelimiter)
Sets the command delimiter for this handler object.
Parameters:
cmdDelimiter - The new delimiter value

setDisconnect

public void setDisconnect(boolean disconnect)
Sets whether this handler should disconnect from the client when it has finished.
Parameters:
disconnect - The new disconnect value

setEnabled

public void setEnabled(boolean enabled)
Enables / disables this handler.
Parameters:
enabled - true to enable the handler, false to disable.

setCommand

public void setCommand(java.lang.String command)
Sets command string that this handler is associated with.
Parameters:
command - The new command value

setParamDelimiter

public void setParamDelimiter(char paramDelimiter)
Sets the parameter delimiter for this handler.
Parameters:
paramDelimiter - The new parameter delimiter.

setParseParams

public void setParseParams(boolean parseParams)
Sets whether this handler should attempt to parse the parameters sent to it.
Parameters:
parseParams - true to enable parsing, false to disable.

setReplyExceptionCode

public void setReplyExceptionCode(int replyExceptionCode)
Sets the numerical code for this handler to use if an exception is encountered during processing (e.g. 500 for an http server).
Parameters:
replyExceptionCode - The numerical reply for exception conditions

setReplyNormal

public void setReplyNormal(RFCReply replyNormal)
Sets the standard RFCReply object to use as a response to this command
Parameters:
replyNormal - The new replyNormal value

setResponse

public void setResponse(StringList response)
Sets the StringList that form the textual reponse for this command handler.
Parameters:
response - The new response value

setTag

public void setTag(int tag)
Sets the tag attribute of the CommandHandler object
Parameters:
tag - The new tag value

getCommandHandlers

public CommandHandlers getCommandHandlers()
Returns the containing collection of this command handler.
Returns:
The commandHandlers value

getCmdDelimiter

public char getCmdDelimiter()
Gets the command delimiter for this command handler
Returns:
The cmdDelimiter value

isDisconnected

public boolean isDisconnected()
Gets the disconnect attribute of the CommandHandler object
Returns:
The disconnect value

isEnabled

public boolean isEnabled()
Gets the enabled attribute of the IdCommandHandler object
Returns:
The enabled value

getCommand

public java.lang.String getCommand()
Gets the command attribute of the IdCommandHandler object
Returns:
The command value

getParamDelimiter

public char getParamDelimiter()
Gets the paramDelimiter attribute of the IdCommandHandler object
Returns:
The paramDelimiter value

isParseParams

public boolean isParseParams()
Gets the parseParams attribute of the CommandHandler object
Returns:
The parseParams value

getReplyExceptionCode

public int getReplyExceptionCode()
Gets the replyExceptionCode attribute of the CommandHandler object
Returns:
The replyExceptionCode value

getReplyNormal

public RFCReply getReplyNormal()
Gets the replyNormal attribute of the CommandHandler object
Returns:
The replyNormal value

getResponse

public StringList getResponse()
Gets the response attribute of the CommandHandler object
Returns:
The response value

getTag

public int getTag()
Gets the tag attribute of the CommandHandler object
Returns:
The tag value

doCommand

protected void doCommand(CommandEvent command)
                  throws IndyException
Calls all CommandListener's CommandListener#onCommand() method.
Parameters:
command - The IdCommand object to pass.
Throws:
IdException - If an exception is thrown by the IdCommandListener

removeCommandListener

public void removeCommandListener(CommandHandlerListener l)
Unregisters an IdCommandListener instance.
Parameters:
l - The listener to remove.

addCommandListener

public void addCommandListener(CommandHandlerListener l)
Registers an IdCommandListener instance to be informed of events from this handler.
Parameters:
l - The listener to add.


Copyright © 2002-2002 IndyJ. All Rights Reserved.