Class ParameterList
- java.lang.Object
-
- gov.nih.mipav.model.scripting.parameters.Parameter
-
- gov.nih.mipav.model.scripting.parameters.ParameterList
-
public class ParameterList extends Parameter
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
Fields Modifier and Type Field Description private java.util.Vector<Parameter>
list
The list of parameters.private int
listType
The 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
Constructors Constructor Description ParameterList(java.lang.String paramLabel, int listContentsType)
Creates a new ParameterList object.ParameterList(java.lang.String paramLabel, int listContentsType, java.lang.String paramValueString)
Creates a new ParameterList object.ParameterList(java.lang.String paramLabel, java.lang.String paramTypeString, java.lang.String paramValueString)
Creates a new ParameterList object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addToList(Parameter elem)
Add a parameter to the end of the list.Parameter
elementAt(int index)
Returns the parameter at a particular position in the list.private static java.lang.String
escapeSpecialCharacters(java.lang.String str)
Escape special list characters with backslashes.boolean[]
getAsBooleanArray()
Returns the contents of this list as an array of booleans, if the list contains ParameterBoolean elements.double[]
getAsDoubleArray()
Returns the contents of this list as an array of doubles, if the list contains ParameterDoubl elements.float[]
getAsFloatArray()
Returns the contents of this list as an array of floats, if the list contains ParameterFloat elements.int[]
getAsIntArray()
Returns the contents of this list as an array of ints, if the list contains ParameterInt elements.long[]
getAsLongArray()
Returns the contents of this list as an array of longs, if the list contains ParameterLong elements.java.util.Vector<Parameter>
getList()
Return the parameter list.int
getListSize()
Return the size of the parameter list.int
getListType()
Return the type of parameters in this parameter list.private int
getListTypeFromString(java.lang.String paramTypeString)
Returns the type of the parameters contained in this list, based on the full type string for the list.java.lang.String
getTypeString()
Return the full type of this parameter (e.g.java.lang.String
getValueString()
Returns the parameter list in String form, separated by commas (with commas in the list elements escaped with backslashes ('\')).private static java.util.Vector<Parameter>
parseList(java.lang.String listString, int listContentsType)
Extracts individual parameter list elements from a comma delimited String.void
removeAllFromList()
Removes all of the parameters from the list.private static java.lang.String
replaceEscapedSpecialCharacters(java.lang.String str)
Removes backslashes escaping any special list characters.void
setListType(int paramListType)
Changes the type of the elements in the list.void
setValue(java.lang.String paramValueString)
Sets the list of parameters based on a comma delimited String containing parameter values.void
setValue(java.util.Vector<Parameter> paramValue)
Changes 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 Detail
-
list
private java.util.Vector<Parameter> list
The list of parameters.
-
listType
private int listType
The data type of the elements in this parameter list.
-
-
Constructor Detail
-
ParameterList
public ParameterList(java.lang.String paramLabel, int listContentsType) 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.- Throws:
ParserException
- If there is a problem creating the parameter list.
-
ParameterList
public ParameterList(java.lang.String paramLabel, int listContentsType, java.lang.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(java.lang.String paramLabel, java.lang.String paramTypeString, java.lang.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 Detail
-
addToList
public void addToList(Parameter elem)
Add a parameter to the end of the list.- Parameters:
elem
- A parameter (should not be another list).
-
elementAt
public Parameter elementAt(int index)
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
public java.util.Vector<Parameter> 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
public java.lang.String getTypeString()
Return the full type of this parameter (e.g. 'list_int').- Overrides:
getTypeString
in classParameter
- Returns:
- The full type identifier of this parameter list (identifies that this is a list and the type of the list elements).
-
getValueString
public java.lang.String getValueString()
Returns the parameter list in String form, separated by commas (with commas in the list elements escaped with backslashes ('\')).- Specified by:
getValueString
in 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
public void setValue(java.lang.String paramValueString) throws ParserException
Sets the list of parameters based on a comma delimited String containing parameter values.- Specified by:
setValue
in classParameter
- Parameters:
paramValueString
- A comma delimited String containing parameter values.- Throws:
ParserException
- If there is a problem encountered parsing the list element values.
-
setValue
public void setValue(java.util.Vector<Parameter> paramValue)
Changes the parameter list elements.- Parameters:
paramValue
- The new parameter list elements.
-
escapeSpecialCharacters
private static java.lang.String escapeSpecialCharacters(java.lang.String str)
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
private static java.lang.String replaceEscapedSpecialCharacters(java.lang.String str)
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
private int getListTypeFromString(java.lang.String paramTypeString) throws ParserException
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 java.util.Vector<Parameter> parseList(java.lang.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.
-
-