Smack

org.jivesoftware.smackx.commands
Class LocalCommand

java.lang.Object
  extended by org.jivesoftware.smackx.commands.AdHocCommand
      extended by org.jivesoftware.smackx.commands.LocalCommand

public abstract class LocalCommand
extends AdHocCommand

Represents a command that can be executed locally from a remote location. This class must be extended to implement an specific ad-hoc command. This class provides some useful and common useful:

  • Node code
  • Node name
  • Session ID
  • Current Stage
  • Available actions
  • Default action
  • To implement a new command extend this class and implement all the abstract methods. When implementing the actions remember that they could be invoked several times, and that you must use the current stage number to know what to do.

    Author:
    Gabriel Guardincerri

    Nested Class Summary
     
    Nested classes/interfaces inherited from class org.jivesoftware.smackx.commands.AdHocCommand
    AdHocCommand.Action, AdHocCommand.SpecificErrorCondition, AdHocCommand.Status
     
    Constructor Summary
    LocalCommand()
               
     
    Method Summary
     long getCreationStamp()
              Returns the time in milliseconds since this command was executed for first time.
     int getCurrentStage()
              Returns the currently executing stage number.
     String getOwnerJID()
              Gets the full JID of the owner of this command.
     String getSessionID()
              Returns the session ID of this execution.
    abstract  boolean hasPermission(String jid)
              Returns if the specified requester has permission to execute all the stages of this action.
    abstract  boolean isLastStage()
              Returns if the current stage is the last one.
     void setOwnerJID(String ownerJID)
              Sets the JID of the command host.
     void setSessionID(String sessionID)
              The sessionID is an unique identifier of an execution request.
     
    Methods inherited from class org.jivesoftware.smackx.commands.AdHocCommand
    addActionAvailable, addNote, cancel, complete, execute, getActions, getExecuteAction, getForm, getName, getNode, getNotes, getSpecificErrorConditionFrom, getStatus, isValidAction, next, prev, setExecuteAction, setForm, setName, setNode
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    LocalCommand

    public LocalCommand()
    Method Detail

    setSessionID

    public void setSessionID(String sessionID)
    The sessionID is an unique identifier of an execution request. This is automatically handled and should not be called.

    Parameters:
    sessionID - the unique session id of this execution

    getSessionID

    public String getSessionID()
    Returns the session ID of this execution.

    Returns:
    the unique session id of this execution

    setOwnerJID

    public void setOwnerJID(String ownerJID)
    Sets the JID of the command host. This is automatically handled and should not be called.

    Parameters:
    ownerJID - the JID of the owner.

    getOwnerJID

    public String getOwnerJID()
    Description copied from class: AdHocCommand
    Gets the full JID of the owner of this command. This JID is the "to" of a execution request.

    Specified by:
    getOwnerJID in class AdHocCommand
    Returns:
    the owner JID.

    getCreationStamp

    public long getCreationStamp()
    Returns the time in milliseconds since this command was executed for first time.

    Returns:
    the time in milliseconds since the command was executed for the first time.

    isLastStage

    public abstract boolean isLastStage()
    Returns if the current stage is the last one. If it is, then the execution of some action will complete the execution of the command.

    Returns:
    true if the command is in the last stage.

    getCurrentStage

    public int getCurrentStage()
    Returns the currently executing stage number. The first stage number is 0. So during the execution of the first action this method will answer 0.

    Returns:
    the current stage number.

    hasPermission

    public abstract boolean hasPermission(String jid)
    Returns if the specified requester has permission to execute all the stages of this action. This is checked when the first request is received, if the permission is grant then the requester will be able to execute all the stages of the command. It is not checked again during the execution.

    Parameters:
    jid - the JID to check permissions on.
    Returns:
    true if the user has permission to execute this action

    Smack

    Copyright © 2003-2007 Jive Software.