Class ParamGroup
- java.lang.Object
-
- org.esa.snap.core.param.ParamGroup
-
public class ParamGroup extends Object
TheParamGroupclass represents a ordered list of parameters.- Version:
- $Revision$ $Date$
-
-
Constructor Summary
Constructors Constructor Description ParamGroup()Constructs a new parameter group.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddParamChangeListener(ParamChangeListener listener)Adds a parameter change listener to all parameters in this group.voidaddParameter(Parameter parameter)Adds the given parameter to this group.static ParamGroupcreate(PropertyMap propertyMap)Adds and configures parameters supplied through the given properties.ParametercreateParameter(String name)Creates a parameter for the given name.intgetNumParameters()Returns the number of parameters in this group.ParametergetParameter(String name)Returns the parameter with the given name.ParametergetParameterAt(int index)Returns the parameter with the given index.intgetParameterIndex(String name)Returns the index of the parameter with the given name.PropertyMapgetParameterValues()Gets the parameter values in this group as a property map instance.PropertyMapgetParameterValues(PropertyMap propertyMap)Gets the parameter values in this group as a property map instance.voidremoveParamChangeListener(ParamChangeListener listener)Removes the parameter change listener from all parameters in this group.voidremoveParameter(Parameter parameter)Removes the given parameter from this group.voidsetParameterValues(PropertyMap propertyMap, ParamExceptionHandler handler)Sets parameter values supplied through the given property map.
-
-
-
Method Detail
-
create
public static ParamGroup create(PropertyMap propertyMap)
Adds and configures parameters supplied through the given properties.For each entry in the properties having the form
any-string.name = param-namethe method creates a new parameter with the name given by param-name if it does not already exists in this list. Then, for each entry of the formparam-name.attrib-name = attrib-valuecontained in the given properties, the method sets/creates a new parameter attribute for the parameter'sgetProperties()field.If a parameter found in the properties has the
nullvalue, the method sets the value of this parameter to the value given byparam-name.defaultValue = default-value, if it can be found in the properties.- Parameters:
propertyMap- the properties used to add and configure new parameters- See Also:
Parameter.getProperties(),ParamProperties
-
setParameterValues
public void setParameterValues(PropertyMap propertyMap, ParamExceptionHandler handler)
Sets parameter values supplied through the given property map.For each parameter contained in this list having the name param-name this method searches for entries in the property ma having the form
param-name = param-value. If it can be found, the parameter is set to the given textual value using the parameter'ssetValueAsTextmethod.- Parameters:
propertyMap- the property map, must not benullhandler- an optional error handler, can benull- See Also:
Parameter.setValueAsText(java.lang.String)
-
getParameterValues
public PropertyMap getParameterValues()
Gets the parameter values in this group as a property map instance.Simply returns
getParameterValues(null).- Returns:
- the property map, never
null - See Also:
getParameterValues(PropertyMap)
-
getParameterValues
public PropertyMap getParameterValues(PropertyMap propertyMap)
Gets the parameter values in this group as a property map instance.For each parameter contained in this list a new entry in the property map instance is created. The key is always the paramer's name and the value is created by using the parameter's
getValueAsTextmethod.- Parameters:
propertyMap- if notnullused as return value, otherwise a newPropertiesinstance will be created and returned- Returns:
- the property map, never
null - See Also:
Parameter.getValueAsText()
-
getNumParameters
public int getNumParameters()
Returns the number of parameters in this group.
-
getParameterAt
public Parameter getParameterAt(int index)
Returns the parameter with the given index.- Parameters:
index- the parameter index- Throws:
IndexOutOfBoundsException- if the index is negative or greater or equal togetNumParameters().
-
getParameter
public Parameter getParameter(String name)
Returns the parameter with the given name.- Returns:
- the parameter or
nullif the a parameter with the given name was not found in this group
-
createParameter
public Parameter createParameter(String name)
Creates a parameter for the given name. If a parameter with the given name already exists in this group, its reference is returned.- Returns:
- the parameter, never
null
-
getParameterIndex
public int getParameterIndex(String name)
Returns the index of the parameter with the given name. If a parameter with the given name was not found,-1is returned.- Returns:
- the parameter index, or
-1if it was not found
-
addParameter
public void addParameter(Parameter parameter)
Adds the given parameter to this group. If the parameter isnullor the parameter already exists in this group, nothing happens.- Parameters:
parameter- the parameter to be added
-
removeParameter
public void removeParameter(Parameter parameter)
Removes the given parameter from this group. If the parameter isnullor the parameter does not exists in this group, nothing happens.- Parameters:
parameter- the parameter to be removed
-
addParamChangeListener
public void addParamChangeListener(ParamChangeListener listener)
Adds a parameter change listener to all parameters in this group.- Parameters:
listener- the listener to be added to all parameters
-
removeParamChangeListener
public void removeParamChangeListener(ParamChangeListener listener)
Removes the parameter change listener from all parameters in this group.- Parameters:
listener- the listener to be removed from all parameters
-
-