Package org.jivesoftware.smackx.commands
Class AdHocCommand
java.lang.Object
org.jivesoftware.smackx.commands.AbstractAdHocCommand
org.jivesoftware.smackx.commands.AdHocCommand
Represents a ad-hoc command invoked on a remote entity. Invoking one of the
execute()
, next(SubmitForm)
,
prev()
, cancel()
or
complete(SubmitForm)
actions results in executing that
action on the remote entity. In response to that action the internal state
of the this command instance will change. For example, if the command is a
single stage command, then invoking the execute action will execute this
action in the remote location. After that the local instance will have a
state of "completed" and a form or notes that applies.-
Constructor Summary
ModifierConstructorDescriptionprotected
AdHocCommand
(XMPPConnection connection, String node, Jid jid) Creates a new RemoteCommand that uses an specific connection to execute a command identified bynode
in the host identified byjid
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
cancel()
Cancels the execution of the command.complete
(SubmitForm filledForm) Completes the command execution with the information provided in theresponse
.final AdHocCommandResult
execute()
Executes the command.final AdHocCommandResult
execute
(FillableForm form) Executes the default action of the command with the information provided in the Form.final AdHocCommandResult
next
(SubmitForm filledForm) Executes the next action of the command with the information provided in theresponse
.final AdHocCommandResult
prev()
Goes to the previous stage.Methods inherited from class org.jivesoftware.smackx.commands.AbstractAdHocCommand
getActions, getExecuteAction, getLastRequest, getLastResult, getName, getNode, getNotes, getSessionId, getSpecificErrorCondition, getStatus, isCompleted, isValidAction, setSessionId
-
Constructor Details
-
AdHocCommand
Creates a new RemoteCommand that uses an specific connection to execute a command identified bynode
in the host identified byjid
- Parameters:
connection
- the connection to use for the execution.node
- the identifier of the command.jid
- the JID of the host.
-
-
Method Details
-
getOwnerJID
-
cancel
public final void cancel() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedExceptionDescription copied from class:AbstractAdHocCommand
Cancels the execution of the command. This can be invoked on any stage of the execution. If there is a problem executing the command it throws an XMPPException.- Specified by:
cancel
in classAbstractAdHocCommand
- Throws:
SmackException.NoResponseException
- if there was no response from the remote entity.XMPPException.XMPPErrorException
- if there is a problem executing the command.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
execute
public final AdHocCommandResult execute() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedExceptionExecutes the command. This is invoked only on the first stage of the command. It is invoked on every command. If there is a problem executing the command it throws an XMPPException.- Returns:
- an ad-hoc command result.
- Throws:
SmackException.NoResponseException
- if there was no response from the remote entity.XMPPException.XMPPErrorException
- if there is an error executing the command.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
next
public final AdHocCommandResult next(SubmitForm filledForm) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException Executes the next action of the command with the information provided in theresponse
. 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.- Parameters:
filledForm
- the form answer of the previous stage.- Returns:
- an ad-hoc command result.
- Throws:
SmackException.NoResponseException
- if there was no response from the remote entity.XMPPException.XMPPErrorException
- if there is a problem executing the command.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
complete
public AdHocCommandResult complete(SubmitForm filledForm) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException Completes the command execution with the information provided in theresponse
. 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.- Parameters:
filledForm
- the form answer of the previous stage.- Returns:
- an ad-hoc command result.
- Throws:
SmackException.NoResponseException
- if there was no response from the remote entity.XMPPException.XMPPErrorException
- if there is a problem executing the command.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
prev
public final AdHocCommandResult prev() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedExceptionGoes to the previous stage. The requester is asking to re-send the information of the previous stage. The command must change it state to the previous one. If there is a problem executing the command it throws an XMPPException.- Returns:
- an ad-hoc command result.
- Throws:
SmackException.NoResponseException
- if there was no response from the remote entity.XMPPException.XMPPErrorException
- if there is a problem executing the command.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
execute
public final AdHocCommandResult execute(FillableForm form) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException Executes the default action of the command with the information provided in the Form. This form must be the answer form of the previous stage. If there is a problem executing the command it throws an XMPPException.- Parameters:
form
- the form answer of the previous stage.- Returns:
- an ad-hoc command result.
- Throws:
XMPPException.XMPPErrorException
- if an error occurs.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-