| 
 | Smack | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jivesoftware.smackx.commands.AdHocCommand
public abstract class AdHocCommand
An ad-hoc command is responsible for executing the provided service and
 storing the result of the execution. Each new request will create a new
 instance of the command, allowing information related to executions to be
 stored in it. For example suppose that a command that retrieves the list of
 users on a server is implemented. When the command is executed it gets that
 list and the result is stored as a form in the command instance, i.e. the
 getForm method retrieves a form with all the users.
 
Each command has a node that should be unique within a given JID.
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 being executed. However, users may request the "cancel" action when submitting 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).
 All the actions may throw an XMPPException if there is a problem executing
 them. The XMPPError of that exception may have some specific
 information about the problem. The possible extensions are:
 
 
 See the SpecificErrorCondition class for detailed description
 of each one.
 
 Use the getSpecificErrorConditionFrom to obtain the specific
 information from an XMPPError.
| Nested Class Summary | |
|---|---|
| static class | AdHocCommand.Action | 
| static class | AdHocCommand.SpecificErrorCondition | 
| static class | AdHocCommand.StatusThe status of the stage in the adhoc command. | 
| Constructor Summary | |
|---|---|
| AdHocCommand() | |
| Method Summary | |
|---|---|
| protected  void | addActionAvailable(AdHocCommand.Action action)Add an action to the current stage available actions. | 
| protected  void | addNote(AdHocCommandNote note)Adds a note to the current stage. | 
| abstract  void | cancel()Cancels the execution of the command. | 
| abstract  void | complete(Form response)Completes the command execution with the information provided in the response. | 
| abstract  void | execute()Executes the command. | 
| protected  List<AdHocCommand.Action> | getActions()Returns a collection with the allowed actions based on the current stage. | 
| protected  AdHocCommand.Action | getExecuteAction()Returns the action available for the current stage which is considered the equivalent to "execute". | 
|  Form | getForm()Returns the form of the current stage. | 
|  String | getName()Returns the human readable name of the command. | 
|  String | getNode()Returns the unique identifier of the command. | 
|  List<AdHocCommandNote> | getNotes()Returns the notes that the command has at the current stage. | 
| abstract  String | getOwnerJID()Returns the full JID of the owner of this command. | 
|  String | getRaw() | 
| static AdHocCommand.SpecificErrorCondition | getSpecificErrorCondition(XMPPError error)Returns the specific condition of the erroror null if the
 error doesn't have any. | 
|  AdHocCommand.Status | getStatus()Returns the status of the current stage. | 
| protected  boolean | isValidAction(AdHocCommand.Action action)Returns true if the actionis available in the current stage. | 
| abstract  void | next(Form response)Executes the next action of the command with the information provided in the response. | 
| abstract  void | prev()Goes to the previous stage. | 
| protected  void | setExecuteAction(AdHocCommand.Action action)Sets which of the actions available for the current stage is considered the equivalent to "execute". | 
| protected  void | setForm(Form form)Sets the form of the current stage. | 
|  void | setName(String name)Set the the human readable name of the command, usually used for displaying in a UI. | 
|  void | setNode(String node)Sets the unique identifier of the command. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
|---|
public AdHocCommand()
| Method Detail | 
|---|
public static AdHocCommand.SpecificErrorCondition getSpecificErrorCondition(XMPPError error)
error or null if the
 error doesn't have any.
error - the error the get the specific condition from.
public void setName(String name)
name - the name.public String getName()
public void setNode(String node)
OwnerJID.
node - the unique identifier of the command.public String getNode()
OwnerJID.
public abstract String getOwnerJID()
public List<AdHocCommandNote> getNotes()
protected void addNote(AdHocCommandNote note)
getNotes() method during the current stage.
 Once the stage changes all the notes are discarded.
note - the note.public String getRaw()
public Form getForm()
protected void setForm(Form form)
form - the form of the current stage to fill out or the result of the
      execution.
public abstract void execute()
                      throws XMPPException
XMPPException - if there is an error executing the command.
public abstract void next(Form response)
                   throws XMPPException
response. This form must be the answer form of the
 previous stage. This method will be only invoked for commands that have one
 or more stages. If there is a problem executing the command it throws an
 XMPPException.
response - the form answer of the previous stage.
XMPPException - if there is a problem executing the command.
public abstract void complete(Form response)
                       throws XMPPException
response. This form must be the answer form of the
 previous stage. This method will be only invoked for commands that have one
 or more stages. If there is a problem executing the command it throws an
 XMPPException.
response - the form answer of the previous stage.
XMPPException - if there is a problem executing the command.
public abstract void prev()
                   throws XMPPException
XMPPException - if there is a problem executing the command.
public abstract void cancel()
                     throws XMPPException
XMPPException - if there is a problem executing the command.protected List<AdHocCommand.Action> getActions()
prev, next and
 complete. This method will be only invoked for commands that
 have one or more stages.
protected void addActionAvailable(AdHocCommand.Action action)
action - the action.protected AdHocCommand.Action getExecuteAction()
protected void setExecuteAction(AdHocCommand.Action action)
action - the action.public AdHocCommand.Status getStatus()
protected boolean isValidAction(AdHocCommand.Action action)
action is available in the current stage.
 The cancel action is always allowed. To define the
 available actions use the addActionAvailable method.
action - The action to check if it is available.
| 
 | Smack | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||