Package com.isode.som
Class SomCommand
- java.lang.Object
-
- com.isode.som.SomCommand
-
- All Implemented Interfaces:
SomResponseProcessor
- Direct Known Subclasses:
SomPumiceCommand,SomQmgrCommand
public abstract class SomCommand extends java.lang.Object implements SomResponseProcessor
Class which represents a generic SOM command.- Author:
- tc
-
-
Field Summary
Fields Modifier and Type Field Description protected SomCommandListeneropListenerprotected SomSessionopSession
-
Constructor Summary
Constructors Constructor Description SomCommand(SomSession sess)Create a new SomCommand object.SomCommand(SomSession sess, SomHandler handler)Create a new SomCommand object.SomCommand(SomSession sess, SomHandler handler, SomCommandListener listener)Create a new SomCommand object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispatch()Send off a command once constructed.protected java.lang.StringgetCommandString()protected SomSessiongetSession()Obtain the SomSession object with which a command is associated.voidnotifyListener(int status)Tell the command listener about an event.voidnotifyListener(int status, java.lang.String detail)Tell the command listener about an event which includes a detail stringvoidnotifyListener(int status, java.lang.String[] pairs)Tell the listener about an event which includes an array of data pairsvoidprocessResponse(java.lang.String commandData, byte[] data, int status)Process response to command.
-
-
-
Field Detail
-
opSession
protected SomSession opSession
-
opListener
protected SomCommandListener opListener
-
-
Constructor Detail
-
SomCommand
public SomCommand(SomSession sess)
Create a new SomCommand object.- Parameters:
sess- SomSession to use for command
-
SomCommand
public SomCommand(SomSession sess, SomHandler handler)
Create a new SomCommand object.- Parameters:
sess- SomSession to use for command which must not be nullhandler- SomHandler which will be used during session establishment which must not be null
-
SomCommand
public SomCommand(SomSession sess, SomHandler handler, SomCommandListener listener)
Create a new SomCommand object.- Parameters:
sess- SomSession to use for commandhandler- SomHandler which be will used during session establishment which must not be nulllistener- SomCommandListener which will handle results and error info which may be null
-
-
Method Detail
-
dispatch
public void dispatch() throws SomExceptionSend off a command once constructed. Wait for a response if we are operating synchronously.- Throws:
SomException- Indicating a problem with the command
-
getSession
protected SomSession getSession()
Obtain the SomSession object with which a command is associated.- Returns:
- SomSession object
-
processResponse
public void processResponse(java.lang.String commandData, byte[] data, int status)Process response to command.- Specified by:
processResponsein interfaceSomResponseProcessor
-
getCommandString
protected java.lang.String getCommandString() throws SomException- Returns:
- The command string to be sent over the wire.
- Throws:
SomException- Indicating a problem with the command
-
notifyListener
public void notifyListener(int status)
Tell the command listener about an event.- Parameters:
status- the status code
-
notifyListener
public void notifyListener(int status, java.lang.String detail)Tell the command listener about an event which includes a detail string- Parameters:
status- the status codedetail- which must not be null
-
notifyListener
public void notifyListener(int status, java.lang.String[] pairs)Tell the listener about an event which includes an array of data pairs- Parameters:
status- the status codepairs- which must not be null
-
-