Class Parameter
- java.lang.Object
-
- gov.nih.mipav.model.scripting.parameters.Parameter
-
- Direct Known Subclasses:
ParameterBoolean
,ParameterDouble
,ParameterFloat
,ParameterInt
,ParameterList
,ParameterLong
,ParameterShort
,ParameterString
,ParameterUShort
public abstract class Parameter extends java.lang.Object
This is an abstract base class for all script action parameters. Subclasses must implement the functionsgetValueString()
andsetValue(String)
to get the value of the parameter in string form (suitable for output in a script) and to set the parameter's value by parsing a String (which may have been read in from a script).
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
isOptional
Whether the parameter needs to be given a value by the user in the ActionDiscovery system.private boolean
isValueAssigned
Whether a value has been set for this parameter.private java.lang.String
label
The label/name of the parameter.static int
PARAM_BOOLEAN
Parameter data type indicating a boolean value.static int
PARAM_DOUBLE
Parameter data type indicating a double value.static int
PARAM_EXTERNAL_IMAGE
Parameter data type indicating an externally-specified (not script produced) image placeholder variable string value.static int
PARAM_FILE
Parameter data type indicating a file variable string value.static int
PARAM_FLOAT
Parameter data type indicating a float value.static int
PARAM_IMAGE
Parameter data type indicating an image placeholder variable string value.static int
PARAM_INT
Parameter data type indicating a integer value.static int
PARAM_LIST
Parameter data type indicating a list of values of a second type.static int
PARAM_LONG
Parameter data type indicating a long value.static int
PARAM_SHORT
Parameter data type indicating a signed short value.static int
PARAM_STRING
Parameter data type indicating a boolean value.private static java.lang.String[]
PARAM_STRINGS_TABLE
String values for all of the parameter value data types (the strings written out to the script).static int
PARAM_USHORT
Parameter data type indicating a unsigned short value.private Parameter
parent
A reference to another Parameter who this parameter relies on.private java.lang.String
parentValueString
The value to check the parent Parameter against before enabling this Parameter, in string format.private int
type
The parameter value data type.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.String
convertToString()
Retrieves the String representation of this Parameter, suitable for inclusion in a script line (e.g., "label type value" (including the quotes)).java.lang.String
getLabel()
Returns the parameter's label/name.protected Parameter
getParent()
Returns a reference to another Parameter upon which this Parameter depends.protected java.lang.String
getParentConditionValueString()
Returns the parent Parameter condition value to test against when deciding whether to ask for a value for this Parameter when using the ActionDiscovery interface.int
getType()
Returns the parameter data type.static int
getTypeFromString(java.lang.String typeString)
Extracts and returns the base data type (e.g.,PARAM_LIST
if 'list_float') from a type String read in from a script.java.lang.String
getTypeString()
Returns the String representation of the parameter's data type.static java.lang.String
getTypeString(int paramType)
Returns the String which should be used to indicate a given parameter data type when writing it to a script.abstract java.lang.String
getValueString()
Returns the value of the Parameter converted into String form (suitable for writing out to a script).boolean
isOptional()
Returns whether this parameter needs to be set by the user when using the ActionDiscovery system.boolean
isParentConditionValueMet()
Tests whether the value of the parent parameter is the same as the parent value that this Parameter requires.boolean
isValueAssigned()
Returns whether a value has been set for this parameter.void
setOptional(boolean flag)
Sets whether this parameter needs to be set by the user when using the ActionDiscovery system.protected void
setParent(Parameter p)
Sets the reference to another Parameter who this parameter relies on.void
setParentCondition(Parameter p, java.lang.String s)
Changes the parent Parameter and parent Parameter condition value to test against when deciding whether to ask for a value for this Parameter when using the ActionDiscovery interface.protected void
setParentConditionValue(java.lang.String s)
Changes the parent Parameter condition value to test against when deciding whether to ask for a value for this Parameter when using the ActionDiscovery interface.abstract void
setValue(java.lang.String paramValueString)
Changes this parameter's value.protected void
setValueAssigned(boolean flag)
Sets whether a value has been set for this parameter.
-
-
-
Field Detail
-
PARAM_BOOLEAN
public static final int PARAM_BOOLEAN
Parameter data type indicating a boolean value.- See Also:
ParameterBoolean
, Constant Field Values
-
PARAM_INT
public static final int PARAM_INT
Parameter data type indicating a integer value.- See Also:
ParameterInt
, Constant Field Values
-
PARAM_LONG
public static final int PARAM_LONG
Parameter data type indicating a long value.- See Also:
ParameterLong
, Constant Field Values
-
PARAM_SHORT
public static final int PARAM_SHORT
Parameter data type indicating a signed short value.- See Also:
ParameterShort
, Constant Field Values
-
PARAM_USHORT
public static final int PARAM_USHORT
Parameter data type indicating a unsigned short value.- See Also:
ParameterUShort
, Constant Field Values
-
PARAM_FLOAT
public static final int PARAM_FLOAT
Parameter data type indicating a float value.- See Also:
ParameterFloat
, Constant Field Values
-
PARAM_DOUBLE
public static final int PARAM_DOUBLE
Parameter data type indicating a double value.- See Also:
ParameterDouble
, Constant Field Values
-
PARAM_STRING
public static final int PARAM_STRING
Parameter data type indicating a boolean value.- See Also:
ParameterString
, Constant Field Values
-
PARAM_LIST
public static final int PARAM_LIST
Parameter data type indicating a list of values of a second type.- See Also:
ParameterList
, Constant Field Values
-
PARAM_IMAGE
public static final int PARAM_IMAGE
Parameter data type indicating an image placeholder variable string value.- See Also:
ParameterImage
, Constant Field Values
-
PARAM_EXTERNAL_IMAGE
public static final int PARAM_EXTERNAL_IMAGE
Parameter data type indicating an externally-specified (not script produced) image placeholder variable string value.- See Also:
ParameterExternalImage
, Constant Field Values
-
PARAM_FILE
public static final int PARAM_FILE
Parameter data type indicating a file variable string value.- See Also:
ParameterFile
, Constant Field Values
-
PARAM_STRINGS_TABLE
private static final java.lang.String[] PARAM_STRINGS_TABLE
String values for all of the parameter value data types (the strings written out to the script).
-
label
private final java.lang.String label
The label/name of the parameter.
-
type
private final int type
The parameter value data type.
-
parent
private Parameter parent
A reference to another Parameter who this parameter relies on. The parent parameter's value can be tested against a parentCondition field (specified by individual Parameter subclasses) to see whether this Parameter needs to be assigned a value. Basically, this provides for a primitive conditional Parameter dependency tree.
-
parentValueString
private java.lang.String parentValueString
The value to check the parent Parameter against before enabling this Parameter, in string format.
-
isOptional
private boolean isOptional
Whether the parameter needs to be given a value by the user in the ActionDiscovery system.
-
isValueAssigned
private boolean isValueAssigned
Whether a value has been set for this parameter. Should be set to true at the first call to any constructor or method that gives the parameter a value. Used to distinguish from the default value some primitives have when they are created.
-
-
Constructor Detail
-
Parameter
protected Parameter(java.lang.String paramLabel, int paramType) throws ParserException
Creates a new Parameter object.- Parameters:
paramLabel
- The label/name of the new parameter.paramType
- The type of the new parameter.- Throws:
ParserException
- If there is a problem creating the new Parameter.
-
Parameter
protected Parameter(java.lang.String paramLabel, java.lang.String paramTypeString) throws ParserException
Creates a new Parameter object.- Parameters:
paramLabel
- The label/name of the new parameter.paramTypeString
- A String containing the data type of the parameter value.- Throws:
ParserException
- If there is a problem creating the new Parameter.
-
-
Method Detail
-
getValueString
public abstract java.lang.String getValueString()
Returns the value of the Parameter converted into String form (suitable for writing out to a script).- Returns:
- A String representation of this Parameter's value (suitable for writing out to a script).
-
setValue
public abstract void setValue(java.lang.String paramValueString) throws ParserException
Changes this parameter's value.- Parameters:
paramValueString
- The value to assign to this parameter, in string format. May be a parameter value read in from a script.- Throws:
ParserException
- If there the new value is invalid for this type of Parameter.
-
getTypeFromString
public static final int getTypeFromString(java.lang.String typeString)
Extracts and returns the base data type (e.g.,PARAM_LIST
if 'list_float') from a type String read in from a script.- Parameters:
typeString
- The type String to parse and find the base type of.- Returns:
- The type indicated by
typeString
.
-
getTypeString
public static final java.lang.String getTypeString(int paramType)
Returns the String which should be used to indicate a given parameter data type when writing it to a script.- Parameters:
paramType
- The parameter type.- Returns:
- The String representation of the given parameter type.
-
convertToString
public java.lang.String convertToString()
Retrieves the String representation of this Parameter, suitable for inclusion in a script line (e.g., "label type value" (including the quotes)).- Returns:
- A String representation of this Parameter.
-
getLabel
public java.lang.String getLabel()
Returns the parameter's label/name.- Returns:
- The parameter label.
-
getType
public int getType()
Returns the parameter data type.- Returns:
- The data type of the parameter's value.
-
getTypeString
public java.lang.String getTypeString()
Returns the String representation of the parameter's data type.- Returns:
- The data type of the parameter's value in String form.
-
setParent
protected void setParent(Parameter p)
Sets the reference to another Parameter who this parameter relies on. The parent parameter's value can be tested against a parentCondition field (specified by individual Parameter subclasses) to see whether this Parameter needs to be assigned a value.- Parameters:
p
- The parent Parameter of this Parameter.
-
getParent
protected Parameter getParent()
Returns a reference to another Parameter upon which this Parameter depends.- Returns:
- The parent Parameter.
-
isParentConditionValueMet
public boolean isParentConditionValueMet()
Tests whether the value of the parent parameter is the same as the parent value that this Parameter requires. Both the parent and the parent value string need to be set.- Returns:
- True if this Parameter should be displayed, false if the conditions for this parameter have not been met.
-
getParentConditionValueString
protected java.lang.String getParentConditionValueString()
Returns the parent Parameter condition value to test against when deciding whether to ask for a value for this Parameter when using the ActionDiscovery interface.- Returns:
- The value to check the parent Parameter against before enabling this Parameter, in string format.
-
setParentConditionValue
protected void setParentConditionValue(java.lang.String s) throws ParserException
Changes the parent Parameter condition value to test against when deciding whether to ask for a value for this Parameter when using the ActionDiscovery interface.- Parameters:
s
- The value to check the parent Parameter against before enabling this Parameter, in string format.- Throws:
ParserException
- If there the new value is invalid for this type of Parameter.
-
setParentCondition
public void setParentCondition(Parameter p, java.lang.String s) throws ParserException
Changes the parent Parameter and parent Parameter condition value to test against when deciding whether to ask for a value for this Parameter when using the ActionDiscovery interface.- Parameters:
p
- The parent Parameter of this Parameter.s
- The value to check the parent Parameter against before enabling this Parameter, in string format.- Throws:
ParserException
- If there the new value is invalid for this type of Parameter.
-
setOptional
public void setOptional(boolean flag)
Sets whether this parameter needs to be set by the user when using the ActionDiscovery system.- Parameters:
flag
- True if the parameter is optional.
-
isOptional
public boolean isOptional()
Returns whether this parameter needs to be set by the user when using the ActionDiscovery system.- Returns:
- True if the parameter is optional.
-
setValueAssigned
protected void setValueAssigned(boolean flag)
Sets whether a value has been set for this parameter. Should be set to true at the first call to any constructor or method that gives the parameter a value. Used to distinguish from the default value some primitives have when they are created.- Parameters:
flag
- Whether a value has been set for this parameter.
-
isValueAssigned
public boolean isValueAssigned()
Returns whether a value has been set for this parameter. Should be set to true at the first call to any constructor or method that gives the parameter a value. Used to distinguish from the default value some primitives have when they are created.- Returns:
- Whether a value has been set for this parameter.
-
-