public abstract class AdHocCommand extends Object
Commands may have zero or more stages. Each stage is usually used for gathering information required for the command execution. Users are able to move forward or backward across the different stages. Commands may not be cancelled while they are beig executed. However, users may request the "cancel" action when submiting a stage response indicating that the command execution should be aborted. Thus, releasing any collected information. Commands that require user interaction (i.e. have more than one stage) will have to provide the data forms the user must complete in each stage and the allowed actions the user might perform during each stage (e.g. go to the previous stage or go to the next stage).
Modifier and Type | Class and Description |
---|---|
static class |
AdHocCommand.Action |
static class |
AdHocCommand.Status |
Constructor and Description |
---|
AdHocCommand() |
Modifier and Type | Method and Description |
---|---|
void |
addNextStageInformation(SessionData data,
org.dom4j.Element command)
Increments the stage number by one and adds to the command element the new data form and
new allowed actions that the user might perform.
|
void |
addPreviousStageInformation(SessionData data,
org.dom4j.Element command)
Decrements the stage number by one and adds to the command the data form and allowed
actions that the user might perform of the previous stage.
|
protected void |
addStageActions(SessionData data,
org.dom4j.Element command)
Adds the allowed actions to follow from the current stage.
|
protected abstract void |
addStageInformation(SessionData data,
org.dom4j.Element command)
Adds to the command element the data form or notes required by the current stage.
|
abstract void |
execute(SessionData data,
org.dom4j.Element command)
Executes the command with the specified session data.
|
protected String |
get(Map<String,List<String>> data,
String key,
int value) |
protected abstract List<AdHocCommand.Action> |
getActions(SessionData data)
Returns a collection with the allowed actions based on the current stage as defined
in the SessionData.
|
abstract String |
getCode()
Returns the unique identifier for this command for the containing JID.
|
abstract String |
getDefaultLabel()
Returns the default label used for describing this commmand.
|
protected abstract AdHocCommand.Action |
getExecuteAction(SessionData data)
Returns which of the actions available for the current stage is considered the equivalent
to "execute".
|
String |
getLabel() |
abstract int |
getMaxStages(SessionData data)
Returns the max number of stages for this command.
|
boolean |
hasPermission(org.xmpp.packet.JID requester)
Returns true if the requester is allowed to execute this command.
|
void |
setLabel(String label) |
public String getLabel()
public void setLabel(String label)
public boolean hasPermission(org.xmpp.packet.JID requester)
Note: The bare JID of the requester will be compared with the bare JID of the admins.
requester
- the JID of the user requesting to execute this command.public abstract String getCode()
public abstract String getDefaultLabel()
setLabel(String)
to set a new label and reset to the default value at any time.public abstract int getMaxStages(SessionData data)
data
- the gathered data through the command stages or null if the
command does not have stages or the requester is requesting the execution for the
first time.public abstract void execute(SessionData data, org.dom4j.Element command)
data
- the gathered data through the command stages or null if the
command does not have stages.command
- the command element to be sent to the command requester with a reported
data result or note element with the answer of the execution.protected abstract void addStageInformation(SessionData data, org.dom4j.Element command)
data
- the gathered data through the command stages or null if the
command does not have stages or the requester is requesting the execution for the
first time.command
- the command element to be sent to the command requester.protected abstract List<AdHocCommand.Action> getActions(SessionData data)
data
- the gathered data through the command stages or null if the
command does not have stages or the requester is requesting the execution for the
first time.protected abstract AdHocCommand.Action getExecuteAction(SessionData data)
data
- the gathered data through the command stages or null if the
command does not have stages or the requester is requesting the execution for the
first time.public void addNextStageInformation(SessionData data, org.dom4j.Element command)
data
- the gathered data through the command stages.command
- the command element to be sent to the command requester.public void addPreviousStageInformation(SessionData data, org.dom4j.Element command)
data
- the gathered data through the command stages.command
- the command element to be sent to the command requester.protected void addStageActions(SessionData data, org.dom4j.Element command)
data
- the gathered data through the command stages or null if the
command does not have stages or the requester is requesting the execution for the
first time.command
- the command element to be sent to the command requester.Copyright © 2003-2008 Jive Software.