Class Argument

java.lang.Object
org.cybergarage.upnp.Argument

public class Argument extends Object
Represents an argument of a UPnP action.

Arguments are the parameters passed to and returned from UPnP actions. Each argument has:

  • A name identifying the argument
  • A direction (in or out) indicating if it's an input or output parameter
  • A related state variable defining its data type and constraints
  • A value holding the actual data

Example usage:


 // Creating an input argument
 Argument volumeArg = new Argument("DesiredVolume", "50");

 // Checking direction
 if (argument.isInDirection()) {
     String value = argument.getValue();
 }

 // Getting related state variable
 StateVariable stateVar = argument.getRelatedStateVariable();
 
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The XML element name for argument nodes in SCPD documents.
    static final String
    Direction constant for input arguments.
    static final String
    Direction constant for output arguments.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an empty argument.
    Argument(String name, String value)
    Constructs an argument with the specified name and value.
    Argument(org.cybergarage.xml.Node servNode)
    Constructs an argument associated with a service node.
    Argument(org.cybergarage.xml.Node servNode, org.cybergarage.xml.Node argNode)
    Constructs an argument from existing service and argument XML nodes.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the action that contains this argument.
    org.cybergarage.xml.Node
    Returns the XML node representing the action that contains this argument.
    org.cybergarage.xml.Node
    Returns the underlying XML node representing this argument.
    Returns the direction of this argument.
    int
    Returns the value of this argument as an integer.
    Returns the name of this argument.
    Returns the related state variable object.
    Returns the name of the related state variable.
    Returns the service that contains this argument.
    Returns the custom user data associated with this argument.
    Returns the value of this argument.
    static boolean
    isArgumentNode(org.cybergarage.xml.Node node)
    Checks if the given XML node represents an argument element.
    boolean
    Checks if this argument is an input parameter.
    boolean
    Checks if this argument is an output parameter.
    void
    Sets the direction of this argument.
    void
    setName(String value)
    Sets the name of this argument.
    void
    Sets the name of the related state variable.
    void
    Sets custom user data associated with this argument.
    void
    setValue(int value)
    Sets the value of this argument from an integer.
    void
    Sets the value of this argument.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Argument

      public Argument()
      Constructs an empty argument.
    • Argument

      public Argument(org.cybergarage.xml.Node servNode)
      Constructs an argument associated with a service node.
      Parameters:
      servNode - the XML node representing the parent service
    • Argument

      public Argument(org.cybergarage.xml.Node servNode, org.cybergarage.xml.Node argNode)
      Constructs an argument from existing service and argument XML nodes.
      Parameters:
      servNode - the XML node representing the parent service
      argNode - the XML node representing the argument definition
    • Argument

      public Argument(String name, String value)
      Constructs an argument with the specified name and value.
      Parameters:
      name - the argument name
      value - the argument value
  • Method Details

    • getArgumentNode

      public org.cybergarage.xml.Node getArgumentNode()
      Returns the underlying XML node representing this argument.
      Returns:
      the argument XML node
    • getService

      public Service getService()
      Returns the service that contains this argument.
      Returns:
      the parent service of this argument
    • getActionNode

      public org.cybergarage.xml.Node getActionNode()
      Returns the XML node representing the action that contains this argument.
      Returns:
      the action XML node, or null if not found
    • getAction

      public Action getAction()
      Returns the action that contains this argument.
      Returns:
      the parent action of this argument
    • isArgumentNode

      public static boolean isArgumentNode(org.cybergarage.xml.Node node)
      Checks if the given XML node represents an argument element.
      Parameters:
      node - the XML node to check
      Returns:
      true if the node's name matches the argument element name, false otherwise
    • setName

      public void setName(String value)
      Sets the name of this argument.
      Parameters:
      value - the argument name
    • getName

      public String getName()
      Returns the name of this argument.
      Returns:
      the argument name
    • setDirection

      public void setDirection(String value)
      Sets the direction of this argument.
      Parameters:
      value - the direction, either IN or OUT
    • getDirection

      public String getDirection()
      Returns the direction of this argument.
      Returns:
      the direction string, or null if not set
    • isInDirection

      public boolean isInDirection()
      Checks if this argument is an input parameter.
      Returns:
      true if the direction is "in", false otherwise
    • isOutDirection

      public boolean isOutDirection()
      Checks if this argument is an output parameter.
      Returns:
      true if the direction is not "in", false otherwise
    • setRelatedStateVariableName

      public void setRelatedStateVariableName(String value)
      Sets the name of the related state variable.

      The related state variable defines the data type, range, and constraints for this argument's value.

      Parameters:
      value - the name of the related state variable
    • getRelatedStateVariableName

      public String getRelatedStateVariableName()
      Returns the name of the related state variable.
      Returns:
      the name of the related state variable
    • getRelatedStateVariable

      public StateVariable getRelatedStateVariable()
      Returns the related state variable object.

      Looks up the state variable by name in the parent service's state table.

      Returns:
      the related state variable, or null if not found or if the service is not available
      See Also:
    • setValue

      public void setValue(String value)
      Sets the value of this argument.
      Parameters:
      value - the argument value as a string
    • setValue

      public void setValue(int value)
      Sets the value of this argument from an integer.

      The integer is converted to a string representation.

      Parameters:
      value - the argument value as an integer
    • getValue

      public String getValue()
      Returns the value of this argument.
      Returns:
      the argument value as a string
    • getIntegerValue

      public int getIntegerValue()
      Returns the value of this argument as an integer.

      If the value cannot be parsed as an integer, returns 0.

      Returns:
      the argument value as an integer, or 0 if parsing fails
    • setUserData

      public void setUserData(Object data)
      Sets custom user data associated with this argument.

      Allows applications to attach arbitrary data to an argument instance for application-specific purposes.

      Parameters:
      data - the user data object to associate with this argument
    • getUserData

      public Object getUserData()
      Returns the custom user data associated with this argument.
      Returns:
      the user data object, or null if none has been set