Class Parameter
java.lang.Object
gov.nih.mipav.model.scripting.parameters.Parameter
- Direct Known Subclasses:
ParameterBoolean,ParameterDouble,ParameterFloat,ParameterInt,ParameterList,ParameterLong,ParameterShort,ParameterString,ParameterUShort
This is an abstract base class for all script action parameters. Subclasses must implement the functions
getValueString() and setValue(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
FieldsModifier and TypeFieldDescriptionprivate booleanWhether the parameter needs to be given a value by the user in the ActionDiscovery system.private booleanWhether a value has been set for this parameter.private final StringThe label/name of the parameter.static final intParameter data type indicating a boolean value.static final intParameter data type indicating a double value.static final intParameter data type indicating an externally-specified (not script produced) image placeholder variable string value.static final intParameter data type indicating a file variable string value.static final intParameter data type indicating a float value.static final intParameter data type indicating an image placeholder variable string value.static final intParameter data type indicating a integer value.static final intParameter data type indicating a list of values of a second type.static final intParameter data type indicating a long value.static final intParameter data type indicating a signed short value.static final intParameter data type indicating a boolean value.private static final String[]String values for all of the parameter value data types (the strings written out to the script).static final intParameter data type indicating a unsigned short value.private ParameterA reference to another Parameter who this parameter relies on.private StringThe value to check the parent Parameter against before enabling this Parameter, in string format.private final intThe parameter value data type. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the String representation of this Parameter, suitable for inclusion in a script line (e.g., "label type value" (including the quotes)).getLabel()Returns the parameter's label/name.protected ParameterReturns a reference to another Parameter upon which this Parameter depends.protected StringReturns the parent Parameter condition value to test against when deciding whether to ask for a value for this Parameter when using the ActionDiscovery interface.intgetType()Returns the parameter data type.static final intgetTypeFromString(String typeString) Extracts and returns the base data type (e.g.,PARAM_LISTif 'list_float') from a type String read in from a script.Returns the String representation of the parameter's data type.static final StringgetTypeString(int paramType) Returns the String which should be used to indicate a given parameter data type when writing it to a script.abstract StringReturns the value of the Parameter converted into String form (suitable for writing out to a script).booleanReturns whether this parameter needs to be set by the user when using the ActionDiscovery system.booleanTests whether the value of the parent parameter is the same as the parent value that this Parameter requires.booleanReturns whether a value has been set for this parameter.voidsetOptional(boolean flag) Sets whether this parameter needs to be set by the user when using the ActionDiscovery system.protected voidSets the reference to another Parameter who this parameter relies on.voidChanges 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 voidChanges 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 voidChanges this parameter's value.protected voidsetValueAssigned(boolean flag) Sets whether a value has been set for this parameter.
-
Field Details
-
PARAM_BOOLEAN
public static final int PARAM_BOOLEANParameter data type indicating a boolean value.- See Also:
-
PARAM_INT
public static final int PARAM_INTParameter data type indicating a integer value.- See Also:
-
PARAM_LONG
public static final int PARAM_LONGParameter data type indicating a long value.- See Also:
-
PARAM_SHORT
public static final int PARAM_SHORTParameter data type indicating a signed short value.- See Also:
-
PARAM_USHORT
public static final int PARAM_USHORTParameter data type indicating a unsigned short value.- See Also:
-
PARAM_FLOAT
public static final int PARAM_FLOATParameter data type indicating a float value.- See Also:
-
PARAM_DOUBLE
public static final int PARAM_DOUBLEParameter data type indicating a double value.- See Also:
-
PARAM_STRING
public static final int PARAM_STRINGParameter data type indicating a boolean value.- See Also:
-
PARAM_LIST
public static final int PARAM_LISTParameter data type indicating a list of values of a second type.- See Also:
-
PARAM_IMAGE
public static final int PARAM_IMAGEParameter data type indicating an image placeholder variable string value.- See Also:
-
PARAM_EXTERNAL_IMAGE
public static final int PARAM_EXTERNAL_IMAGEParameter data type indicating an externally-specified (not script produced) image placeholder variable string value.- See Also:
-
PARAM_FILE
public static final int PARAM_FILEParameter data type indicating a file variable string value.- See Also:
-
PARAM_STRINGS_TABLE
String values for all of the parameter value data types (the strings written out to the script). -
label
The label/name of the parameter. -
type
private final int typeThe parameter value data type. -
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
The value to check the parent Parameter against before enabling this Parameter, in string format. -
isOptional
private boolean isOptionalWhether the parameter needs to be given a value by the user in the ActionDiscovery system. -
isValueAssigned
private boolean isValueAssignedWhether 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 Details
-
Parameter
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
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 Details
-
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
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
Extracts and returns the base data type (e.g.,PARAM_LISTif '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
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
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
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
Returns the String representation of the parameter's data type.- Returns:
- The data type of the parameter's value in String form.
-
setParent
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
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
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
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
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.
-