|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.msi.network.server.Command
Defines the common API for server commands.
A command is instantiated with a name and generally the default isValid() method will adequately identify that the request is for this command. Subclasses should maintain this behaviour.
Most of the processing occurs in the processCommand method:
public class myCommand extents Command {
public boolean processCommand(Connection conn) {
// do all the magic your command requires:
// - update/fetch data from a db
// - format your response
setResponse(yourAnswerObject.toString());
return true; // indicate success
}
}
| Field Summary | |
protected java.lang.String |
_commandInput
Describe variable _commandInput here. |
protected CommandProcessor |
_commandProcessor
Describe variable _commandProcessor here. |
protected java.lang.String |
_name
Each command has a unique string name. |
protected java.lang.String |
_response
The response sent to the client including all punctuation. |
protected java.util.StringTokenizer |
_tokes
Describe variable _tokes here. |
| Constructor Summary | |
Command(java.lang.String nm)
Set the minimum required state for command execution. |
|
| Method Summary | |
java.lang.String |
getResponse()
Get the value of _response. |
boolean |
isLast()
When a command terminates a client session true is returned. |
boolean |
isValid()
Verifies the client supplied information against this command. |
boolean |
processCommand(Connection conn)
To be over-ridden in the sub-class implementing the specific command. |
boolean |
processCommand(java.lang.String cmd,
Connection conn,
CommandProcessor cmdProc)
Set the command, and if it is valid do the right thing. |
void |
setResponse(java.lang.String v)
Set the value of _response. |
java.lang.String |
usage()
Provide a description of the Request Handler syntax and usage. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected java.lang.String _name
protected java.lang.String _response
The command response is buffered to support commands requiring response editing.
protected java.lang.String _commandInput
_commandInput here.
protected CommandProcessor _commandProcessor
_commandProcessor here.
protected java.util.StringTokenizer _tokes
_tokes here.
| Constructor Detail |
public Command(java.lang.String nm)
nm - name of the command used for parsing entry.| Method Detail |
public boolean isValid()
public boolean processCommand(java.lang.String cmd,
Connection conn,
CommandProcessor cmdProc)
cmd - the first line of the command sequence.conn - the communications channel to the client.cmdProc - reference allowing access to other commands and the server.
public boolean processCommand(Connection conn)
conn - a Connection value
public java.lang.String getResponse()
public void setResponse(java.lang.String v)
v - Value to assign to _response.public boolean isLast()
public java.lang.String usage()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||