com.exoftware.exactor
Class Parameter

java.lang.Object
  extended bycom.exoftware.exactor.Parameter

public class Parameter
extends java.lang.Object

A parameter to a command. Provides convenience methods to obtain the numeric or boolean value of the parameter.

Author:
Brian Swan

Constructor Summary
Parameter(java.lang.String s)
          Create a new Parameter with the specified value.
 
Method Summary
 boolean booleanValue()
          Returns the boolean value of the parameter.
 double doubleValue()
          Returns the double value of the parameter.
 Command getCommand()
          Returns the command that owns this parameter.
 int intValue()
          Returns the int value of the parameter.
 boolean isNumeric()
          Check whether the parameter value represents a number.
 void setCommand(Command c)
          Set the owning command for this parameter.
 java.lang.String stringValue()
          Returns the string value of the parameter, with any substitutions replaced.
 java.lang.String toString()
          Returns a string representation of the paremeter.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Parameter

public Parameter(java.lang.String s)
Create a new Parameter with the specified value. If s represents an integer or double value the numeric equivalent can be obtained through the convenience methods, intValue and doubleValue. If s equals, ignoring case, the string 'true' the boolean equivalent can be obtained through the convenience method, booleanValue. In all cases the string value of the parameter can be obtained via stringValue or toString.

Parameters:
s - the value of the parameter.
See Also:
intValue(), doubleValue(), booleanValue()
Method Detail

stringValue

public java.lang.String stringValue()
Returns the string value of the parameter, with any substitutions replaced. A substitution is a value enclosed in square brackets, e.g. [xxx], where xxx represents a key in either the script or execution set context for the command owning this parameter. For example, as the execution set context contains all of the System properties, the following code would display Windows XP on a Windows XP machine.;
 
 Parameter p = new Parameter( "[os.name]" );
 p.setCommand( myCommand );
 System.out.println( p.stringValue() );
 
 

Returns:
the string value of the parameter.

toString

public java.lang.String toString()
Returns a string representation of the paremeter.

Returns:
a string representation of the parameter.

isNumeric

public boolean isNumeric()
Check whether the parameter value represents a number.

Returns:
true if the parameter represents a number, otherwise false.

intValue

public int intValue()
             throws java.lang.NumberFormatException
Returns the int value of the parameter. Behaves the same as Integer.parseInt.

Returns:
the int value of the parameter.
Throws:
java.lang.NumberFormatException - if the parameter value is not a number.
See Also:
Integer.parseInt(String)

doubleValue

public double doubleValue()
                   throws java.lang.NumberFormatException
Returns the double value of the parameter. Behaves the same as Double.parseDouble.

Returns:
the double value of the parameter.
Throws:
java.lang.NumberFormatException - if the parameter value is not a number.
See Also:
Double.parseDouble(String)

booleanValue

public boolean booleanValue()
Returns the boolean value of the parameter. Behaves the same as Boolean.valueOf.

Returns:
true if the parameter value is equal, ignoring case, to the String 'true', otherwise false.
See Also:
Boolean.valueOf(String)

setCommand

public void setCommand(Command c)
                throws java.lang.RuntimeException
Set the owning command for this parameter.

Parameters:
c - the command tnat owns this parameter.
Throws:
java.lang.RuntimeException - if the supplied command is null.

getCommand

public Command getCommand()
Returns the command that owns this parameter.

Returns:
the command that owns this parameter.