java.lang.Object
org.cybergarage.upnp.Argument
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 -
Constructor Summary
ConstructorsConstructorDescriptionArgument()Constructs an empty argument.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 TypeMethodDescriptionReturns the action that contains this argument.org.cybergarage.xml.NodeReturns the XML node representing the action that contains this argument.org.cybergarage.xml.NodeReturns the underlying XML node representing this argument.Returns the direction of this argument.intReturns the value of this argument as an integer.getName()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.getValue()Returns the value of this argument.static booleanisArgumentNode(org.cybergarage.xml.Node node) Checks if the given XML node represents an argument element.booleanChecks if this argument is an input parameter.booleanChecks if this argument is an output parameter.voidsetDirection(String value) Sets the direction of this argument.voidSets the name of this argument.voidSets the name of the related state variable.voidsetUserData(Object data) Sets custom user data associated with this argument.voidsetValue(int value) Sets the value of this argument from an integer.voidSets the value of this argument.
-
Field Details
-
ELEM_NAME
The XML element name for argument nodes in SCPD documents.- See Also:
-
IN
Direction constant for input arguments.- See Also:
-
OUT
Direction constant for output arguments.- See Also:
-
-
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 serviceargNode- the XML node representing the argument definition
-
Argument
Constructs an argument with the specified name and value.- Parameters:
name- the argument namevalue- 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
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
nullif not found
-
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:
trueif the node's name matches the argument element name,falseotherwise
-
setName
Sets the name of this argument.- Parameters:
value- the argument name
-
getName
Returns the name of this argument.- Returns:
- the argument name
-
setDirection
Sets the direction of this argument. -
getDirection
Returns the direction of this argument.- Returns:
- the direction string, or
nullif not set
-
isInDirection
public boolean isInDirection()Checks if this argument is an input parameter.- Returns:
trueif the direction is "in",falseotherwise
-
isOutDirection
public boolean isOutDirection()Checks if this argument is an output parameter.- Returns:
trueif the direction is not "in",falseotherwise
-
setRelatedStateVariableName
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
Returns the name of the related state variable.- Returns:
- the name of the related state variable
-
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
nullif not found or if the service is not available - See Also:
-
setValue
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
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
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
Returns the custom user data associated with this argument.- Returns:
- the user data object, or
nullif none has been set
-