java.lang.Object
org.cybergarage.upnp.Action

public class Actionextends Object
Represents a UPnP action with its associated service, arguments, and control functionality.
  • Field Details

    • ELEM_NAME

      public static final String ELEM_NAME
      The element name for action nodes in XML
      See Also:
    • serviceNode

      private Node serviceNode
      The service node this action belongs to
    • actionNode

      private final Node actionNode
      The action node containing action definition
    • mutex

      private Mutex mutex
      Mutex for thread synchronization
    • NAME

      private static final String NAME
      The name attribute for action nodes
      See Also:
    • upnpStatus

      private UPnPStatus upnpStatus
      The UPnP status for this action
    • userData

      private Object userData
      User-defined data associated with this action
  • Constructor Details

    • Action

      public Action(Node serviceNode)
      Creates a new Action with a given service node.
      Parameters:
      serviceNode - service node this action belongs to
    • Action

      public Action(Node serviceNode, Node actionNode)
      Creates a new Action with given service and action nodes.
      Parameters:
      serviceNode - service node this action belongs to
      actionNode - action node containing action definition
    • Action

      public Action(Action action)
      Creates a copy of an existing Action.
      Parameters:
      action - Action to copy
  • Method Details

    • getServiceNode

      private Node getServiceNode()
      Gets the service node this action belongs to.
      Returns:
      the service node
    • getService

      public Service getService()
      Gets the service this action belongs to.
      Returns:
      the service object
    • setService

      void setService(Service s)
      Sets the service this action belongs to.
      Parameters:
      s - the service to set
    • getActionNode

      public Node getActionNode()
      Gets the action node.
      Returns:
      the action node
    • lock

      public void lock()
      Locks the mutex for this action.
    • unlock

      public void unlock()
      Unlocks the mutex for this action.
    • isActionNode

      public static boolean isActionNode(Node node)
      Checks if the given node is an action node.
      Parameters:
      node - node to check
      Returns:
      true if the node is an action node, false otherwise
    • setName

      public void setName(String value)
      Sets name of this action.
      Parameters:
      value - name to set
    • getName

      public String getName()
      Gets name of this action.
      Returns:
      action name
    • getArgumentList

      public ArgumentList getArgumentList()
      Gets list of all arguments for this action.
      Returns:
      argument list
    • setArgumentList

      public void setArgumentList(ArgumentList al)
      Sets the argument list for this action.
      Parameters:
      al - the argument list to set
    • getInputArgumentList

      public ArgumentList getInputArgumentList()
      Gets the list of input arguments for this action.
      Returns:
      the input argument list
    • getOutputArgumentList

      public ArgumentList getOutputArgumentList()
      Gets the list of output arguments for this action.
      Returns:
      the output argument list
    • getArgument

      public Argument getArgument(String name)
      Gets an argument by name.
      Parameters:
      name - the name of the argument to find
      Returns:
      the argument if found, null otherwise
    • setInArgumentValues

      public void setInArgumentValues(ArgumentList argList)
      /** Sets the values of input arguments.
      Parameters:
      argList - the argument list containing input values
    • setOutArgumentValues

      public void setOutArgumentValues(ArgumentList argList)
      Sets the values of output arguments.
      Parameters:
      argList - the argument list containing output values
    • setArgumentValue

      public void setArgumentValue(String name, String value)
      Sets the value of an argument by name.
      Parameters:
      name - the name of the argument
      value - the value to set
    • setArgumentValue

      public void setArgumentValue(String name, int value)
      Sets the value of an argument by name using an integer value.
      Parameters:
      name - the name of the argument
      value - the integer value to set
    • clearOutputAgumentValues

      private void clearOutputAgumentValues()
      Clears all output argument values by setting them to empty strings.
    • getArgumentValue

      public String getArgumentValue(String name)
      Gets the value of an argument by name.
      Parameters:
      name - the name of the argument
      Returns:
      the argument value, or empty string if argument not found
    • getArgumentIntegerValue

      public int getArgumentIntegerValue(String name)
      Gets the integer value of an argument by name.
      Parameters:
      name - the name of the argument
      Returns:
      the argument integer value, or 0 if argument not found
    • getActionData

      private ActionData getActionData()
      Gets the action data associated with this action.
      Returns:
      the action data object
    • getActionListener

      public ActionListener getActionListener()
      Gets the action listener for this action.
      Returns:
      the action listener
    • setActionListener

      public void setActionListener(ActionListener listener)
      Sets the action listener for this action.
      Parameters:
      listener - the action listener to set
    • performActionListener

      public boolean performActionListener(ActionRequest actionReq)
      Performs the action listener for this action.
      Parameters:
      actionReq - the action request
      Returns:
      true if the listener was called, false if no listener is set
    • getControlResponse

      private ControlResponse getControlResponse()
      Gets the control response for this action.
      Returns:
      the control response
    • setControlResponse

      private void setControlResponse(ControlResponse res)
      Sets the control response for this action.
      Parameters:
      res - the control response to set
    • getControlStatus

      public UPnPStatus getControlStatus()
      Gets the control status for this action.
      Returns:
      the UPnP status
    • postControlAction

      public boolean postControlAction()
      Posts this control action without binding to a specific local address.
      Returns:
      true if successful, false otherwise
    • postControlAction

      public boolean postControlAction(String fromHost)
      Posts this control action, optionally binding to a specific local host address. I2P - bind HTTP socket to specified local host address
      Parameters:
      fromHost - null to not bind to a particular local address
      Returns:
      true if successful, false otherwise
    • print

      public void print()
      Prints debug information about this action and its arguments.
    • setStatus

      public void setStatus(int code, String descr)
      Sets the status code and description for this action.
      Parameters:
      code - the status code
      descr - the status description
    • setStatus

      public void setStatus(int code)
      Sets the status code for this action using the default description.
      Parameters:
      code - the status code
    • getStatus

      public UPnPStatus getStatus()
      Gets the UPnP status for this action.
      Returns:
      the UPnP status
    • setUserData

      public void setUserData(Object data)
      Sets user-defined data for this action.
      Parameters:
      data - the user data to set
    • getUserData

      public Object getUserData()
      Gets the user-defined data associated with this action.
      Returns:
      the user data