Class ParameterList
java.lang.Object
gov.nih.mipav.model.scripting.parameters.Parameter
gov.nih.mipav.model.scripting.parameters.ParameterList
This is a special kind of script parameter, which contains other parameters. All of these parameters must be of the
same type and are comma separated.
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe list of parameters.private intThe data type of the elements in this parameter list.Fields inherited from class gov.nih.mipav.model.scripting.parameters.Parameter
PARAM_BOOLEAN, PARAM_DOUBLE, PARAM_EXTERNAL_IMAGE, PARAM_FILE, PARAM_FLOAT, PARAM_IMAGE, PARAM_INT, PARAM_LIST, PARAM_LONG, PARAM_SHORT, PARAM_STRING, PARAM_USHORT -
Constructor Summary
ConstructorsConstructorDescriptionParameterList(String paramLabel, int listContentsType) Creates a new ParameterList object.ParameterList(String paramLabel, int listContentsType, String paramValueString) Creates a new ParameterList object.ParameterList(String paramLabel, String paramTypeString, String paramValueString) Creates a new ParameterList object. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a parameter to the end of the list.elementAt(int index) Returns the parameter at a particular position in the list.private static StringEscape special list characters with backslashes.boolean[]Returns the contents of this list as an array of booleans, if the list contains ParameterBoolean elements.double[]Returns the contents of this list as an array of doubles, if the list contains ParameterDoubl elements.float[]Returns the contents of this list as an array of floats, if the list contains ParameterFloat elements.int[]Returns the contents of this list as an array of ints, if the list contains ParameterInt elements.long[]Returns the contents of this list as an array of longs, if the list contains ParameterLong elements.getList()Return the parameter list.intReturn the size of the parameter list.intReturn the type of parameters in this parameter list.private intgetListTypeFromString(String paramTypeString) Returns the type of the parameters contained in this list, based on the full type string for the list.Return the full type of this parameter (e.g.Returns the parameter list in String form, separated by commas (with commas in the list elements escaped with backslashes ('\')).Extracts individual parameter list elements from a comma delimited String.voidRemoves all of the parameters from the list.private static StringRemoves backslashes escaping any special list characters.voidsetListType(int paramListType) Changes the type of the elements in the list.voidSets the list of parameters based on a comma delimited String containing parameter values.voidChanges the parameter list elements.Methods inherited from class gov.nih.mipav.model.scripting.parameters.Parameter
convertToString, getLabel, getParent, getParentConditionValueString, getType, getTypeFromString, getTypeString, isOptional, isParentConditionValueMet, isValueAssigned, setOptional, setParent, setParentCondition, setParentConditionValue, setValueAssigned
-
Field Details
-
list
The list of parameters. -
listType
private int listTypeThe data type of the elements in this parameter list.
-
-
Constructor Details
-
ParameterList
Creates a new ParameterList object.- Parameters:
paramLabel- The label/name to give to this parameter.listContentsType- The type of the parameters contained in this list.- Throws:
ParserException- If there is a problem creating the parameter list.
-
ParameterList
public ParameterList(String paramLabel, int listContentsType, String paramValueString) throws ParserException Creates a new ParameterList object.- Parameters:
paramLabel- The label/name to give to this parameter.listContentsType- The type of the parameters contained in this list.paramValueString- The list of parameters in string form.- Throws:
ParserException- If there is a problem creating the parameter list.
-
ParameterList
public ParameterList(String paramLabel, String paramTypeString, String paramValueString) throws ParserException Creates a new ParameterList object.- Parameters:
paramLabel- The label/name to give to this parameter.paramTypeString- The type of this parameter, in string form. The first part should indicate that it is a list, the second part should indicate the type of the elements in the parameter list.paramValueString- The list of parameters in string form.- Throws:
ParserException- If there is a problem creating the parameter list.
-
-
Method Details
-
addToList
Add a parameter to the end of the list.- Parameters:
elem- A parameter (should not be another list).
-
elementAt
Returns the parameter at a particular position in the list.- Parameters:
index- The index of the parameter to retrieve.- Returns:
- A parameter from the list.
-
getAsBooleanArray
public boolean[] getAsBooleanArray()Returns the contents of this list as an array of booleans, if the list contains ParameterBoolean elements.- Returns:
- The list converted into an array of booleans.
-
getAsFloatArray
public float[] getAsFloatArray()Returns the contents of this list as an array of floats, if the list contains ParameterFloat elements.- Returns:
- The list converted into an array of floats.
-
getAsDoubleArray
public double[] getAsDoubleArray()Returns the contents of this list as an array of doubles, if the list contains ParameterDoubl elements.- Returns:
- The list converted into an array of doubles.
-
getAsIntArray
public int[] getAsIntArray()Returns the contents of this list as an array of ints, if the list contains ParameterInt elements.- Returns:
- The list converted into an array of ints.
-
getAsLongArray
public long[] getAsLongArray()Returns the contents of this list as an array of longs, if the list contains ParameterLong elements.- Returns:
- The list converted into an array of longs.
-
getList
Return the parameter list.- Returns:
- The vector containing the list elements.
-
getListSize
public int getListSize()Return the size of the parameter list.- Returns:
- The number of parameters in the list.
-
getListType
public int getListType()Return the type of parameters in this parameter list.- Returns:
- The type of parameters in this list.
-
getTypeString
Return the full type of this parameter (e.g. 'list_int').- Overrides:
getTypeStringin classParameter- Returns:
- The full type identifier of this parameter list (identifies that this is a list and the type of the list elements).
-
getValueString
Returns the parameter list in String form, separated by commas (with commas in the list elements escaped with backslashes ('\')).- Specified by:
getValueStringin classParameter- Returns:
- The parameter list in String form, suitable for writing out as part of a script.
-
removeAllFromList
public void removeAllFromList()Removes all of the parameters from the list. -
setListType
public void setListType(int paramListType) Changes the type of the elements in the list.- Parameters:
paramListType- The new parameter type.
-
setValue
Sets the list of parameters based on a comma delimited String containing parameter values.- Specified by:
setValuein classParameter- Parameters:
paramValueString- A comma delimited String containing parameter values.- Throws:
ParserException- If there is a problem encountered parsing the list element values.
-
setValue
Changes the parameter list elements.- Parameters:
paramValue- The new parameter list elements.
-
escapeSpecialCharacters
Escape special list characters with backslashes. Used on the String representation of parameter elements before converting the entire list to a comma-delimited string.- Parameters:
str- A string to escape.- Returns:
- The escaped string.
-
replaceEscapedSpecialCharacters
Removes backslashes escaping any special list characters. Used to remove any comma-escaping while parsing the individual values from a string and adding them to the list.- Parameters:
str- The escaped string.- Returns:
- The un-escaped string.
-
getListTypeFromString
Returns the type of the parameters contained in this list, based on the full type string for the list.- Parameters:
paramTypeString- The full type string for the list (e.g., 'list_float')- Returns:
- The data type of the parameters which should be in this parameter list.
- Throws:
ParserException- If there is a problem encountered determining the type of the list elements.
-
parseList
private static final Vector<Parameter> parseList(String listString, int listContentsType) throws ParserException Extracts individual parameter list elements from a comma delimited String.- Parameters:
listString- A comma delimited String containing parameter values.listContentsType- The parameter data type of the list.- Returns:
- A vector containing the extracted parameters.
- Throws:
ParserException- If there is a problem encountered parsing the list element values.
-