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 Object
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

    Fields
    Modifier and Type
    Field
    Description
    private boolean
    Whether the parameter needs to be given a value by the user in the ActionDiscovery system.
    private boolean
    Whether a value has been set for this parameter.
    private final String
    The label/name of the parameter.
    static final int
    Parameter data type indicating a boolean value.
    static final int
    Parameter data type indicating a double value.
    static final int
    Parameter data type indicating an externally-specified (not script produced) image placeholder variable string value.
    static final int
    Parameter data type indicating a file variable string value.
    static final int
    Parameter data type indicating a float value.
    static final int
    Parameter data type indicating an image placeholder variable string value.
    static final int
    Parameter data type indicating a integer value.
    static final int
    Parameter data type indicating a list of values of a second type.
    static final int
    Parameter data type indicating a long value.
    static final int
    Parameter data type indicating a signed short value.
    static final int
    Parameter 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 int
    Parameter data type indicating a unsigned short value.
    private Parameter
    A reference to another Parameter who this parameter relies on.
    private String
    The value to check the parent Parameter against before enabling this Parameter, in string format.
    private final int
    The parameter value data type.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Parameter(String paramLabel, int paramType)
    Creates a new Parameter object.
    protected
    Parameter(String paramLabel, String paramTypeString)
    Creates a new Parameter object.
  • Method Summary

    Modifier and Type
    Method
    Description
    Retrieves the String representation of this Parameter, suitable for inclusion in a script line (e.g., "label type value" (including the quotes)).
    Returns the parameter's label/name.
    protected Parameter
    Returns a reference to another Parameter upon which this Parameter depends.
    protected String
    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
    Returns the parameter data type.
    static final int
    Extracts and returns the base data type (e.g., PARAM_LIST if 'list_float') from a type String read in from a script.
    Returns the String representation of the parameter's data type.
    static final 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 String
    Returns the value of the Parameter converted into String form (suitable for writing out to a script).
    boolean
    Returns whether this parameter needs to be set by the user when using the ActionDiscovery system.
    boolean
    Tests whether the value of the parent parameter is the same as the parent value that this Parameter requires.
    boolean
    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
    Sets the reference to another Parameter who this parameter relies on.
    void
    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
    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(String paramValueString)
    Changes this parameter's value.
    protected void
    setValueAssigned(boolean flag)
    Sets whether a value has been set for this parameter.

    Methods inherited from class java.lang.Object

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

    • PARAM_BOOLEAN

      public static final int PARAM_BOOLEAN
      Parameter data type indicating a boolean value.
      See Also:
    • PARAM_INT

      public static final int PARAM_INT
      Parameter data type indicating a integer value.
      See Also:
    • PARAM_LONG

      public static final int PARAM_LONG
      Parameter data type indicating a long value.
      See Also:
    • PARAM_SHORT

      public static final int PARAM_SHORT
      Parameter data type indicating a signed short value.
      See Also:
    • PARAM_USHORT

      public static final int PARAM_USHORT
      Parameter data type indicating a unsigned short value.
      See Also:
    • PARAM_FLOAT

      public static final int PARAM_FLOAT
      Parameter data type indicating a float value.
      See Also:
    • PARAM_DOUBLE

      public static final int PARAM_DOUBLE
      Parameter data type indicating a double value.
      See Also:
    • PARAM_STRING

      public static final int PARAM_STRING
      Parameter data type indicating a boolean value.
      See Also:
    • PARAM_LIST

      public static final int PARAM_LIST
      Parameter data type indicating a list of values of a second type.
      See Also:
    • PARAM_IMAGE

      public static final int PARAM_IMAGE
      Parameter data type indicating an image placeholder variable string value.
      See Also:
    • 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:
    • PARAM_FILE

      public static final int PARAM_FILE
      Parameter data type indicating a file variable string value.
      See Also:
    • PARAM_STRINGS_TABLE

      private static final String[] PARAM_STRINGS_TABLE
      String values for all of the parameter value data types (the strings written out to the script).
    • label

      private final 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 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 Details

    • Parameter

      protected Parameter(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(String paramLabel, 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 Details

    • getValueString

      public abstract 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(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(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 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 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 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 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 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(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, 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.