Package org.esa.snap.core.param
Class ParamProperties
- java.lang.Object
-
- org.esa.snap.core.param.ParamProperties
-
public class ParamProperties extends Object
TheParamProperties
class is used to store parameter attributes such as parameter type and description or validation information such as minimum and maximum values. An instance of this class which implements this interface can contain any number of attributes. The interpretation of particular attributes is handed over to specialized parameter editors and validators.Important note: Attribute keys must NOT contain the period (.) character.
- Version:
- $Revision$ $Date$
- See Also:
Parameter
,ParamEditor
,ParamValidator
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ParamProperties()
ParamProperties(Class valueType)
ParamProperties(Class valueType, Number defaultValue, Number minValue, Number maxValue)
ParamProperties(Class valueType, Number defaultValue, Number minValue, Number maxValue, Number increment)
ParamProperties(Class valueType, Object defaultValue)
ParamProperties(Class valueType, Object defaultValue, String[] valueSet)
ParamProperties(Class valueType, Object defaultValue, String[] valueSet, boolean valueSetBound)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPropertyChangeListener(PropertyChangeListener listener)
boolean
containsProperty(String key)
Returnstrue
if an attribute with given name was found.ParamProperties
createCopy()
Creates and returns a copy of this object.protected Map<String,Object>
createPropertyMap(Map<String,Object> map)
Creates aMap
to be used to store the attributes.ParamValidator
createValidator()
Creates an appropriate validator for this parameter info.FileFilter[]
getChoosableFileFilters()
Gets an array ofchoosable FileFilter
which was set in theFileChooser
displayed when the button fromFileEditor
was klicked.FileFilter
getCurrentFileFilter()
Gets thecurrent FileFilter
which was set in theFileChooser
displayed when the button fromFileEditor
was klicked.Object
getDefaultValue()
String
getDescription()
Class
getEditorClass()
int
getFileSelectionMode()
Number
getIncrement()
String
getLabel()
Number
getMaxValue()
Number
getMinValue()
int
getNumCols()
int
getNumRows()
String
getPhysicalUnit()
Map<String,Object>
getProperties(String namePrefix)
Creates a subset of the properties in this map, containing only properties whose name start with the givennamePrefix
.Object
getPropertyValue(String key)
Returns the value of the attribute with the given name.boolean
getPropertyValue(String key, boolean defaultValue)
Returns theboolean
value of the attribute with the given name.double
getPropertyValue(String key, double defaultValue)
Returns thedouble
value of the attribute with the given name.int
getPropertyValue(String key, int defaultValue)
Returns theint
value of the attribute with the given name.Class
getPropertyValue(String key, Class defaultValue)
Returns theClass
value of the attribute with the given name.Object
getPropertyValue(String key, Object defaultValue)
Returns theObject
value of the attribute with the given name.String
getPropertyValue(String key, String defaultValue)
Returns theString
value of the attribute with the given name.Class
getValidatorClass()
String[]
getValueSet()
char
getValueSetDelim()
Class
getValueType()
boolean
isCaseSensitive()
boolean
isEmptyValuesNotAllowed()
boolean
isHidden()
boolean
isIdentifiersOnly()
boolean
isNullValueAllowed()
boolean
isReadOnly()
boolean
isValueSetBound()
protected Class
loadClass(String className)
Loads the class with the specified name.void
removePropertyChangeListener(PropertyChangeListener listener)
void
setCaseSensitive(boolean caseSensitive)
void
setChoosableFileFilters(FileFilter[] filters)
Sets an array ofchoosable FileFilter
used in theFileChooser
displayed when the button fromFileEditor
was klicked.void
setCurrentFileFilter(FileFilter filter)
Sets thecurrent FileFilter
used in theFileChooser
displayed when the button fromFileEditor
was klicked.void
setDefaultValue(Object defaultValue)
void
setDescription(String description)
void
setEditorClass(Class editorClass)
void
setEmptyValuesNotAllowed(boolean emptyAllowed)
void
setFileSelectionMode(int fsm)
void
setHidden(boolean hidden)
void
setIdentifiersOnly(boolean identifiersOnly)
void
setIncrement(Number increment)
void
setLabel(String label)
void
setMaxValue(Number maxValue)
void
setMinValue(Number minValue)
void
setNullValueAllowed(boolean nullAllowed)
void
setNumCols(int numCols)
void
setNumRows(int numRows)
void
setPhysicalUnit(String unit)
void
setPropertyValue(String key, boolean value)
void
setPropertyValue(String key, double value)
void
setPropertyValue(String key, float value)
void
setPropertyValue(String key, int value)
void
setPropertyValue(String key, long value)
void
setPropertyValue(String key, Object value)
void
setPropertyValues(String paramName, PropertyMap propertyMap)
Sets the properties to the values found in the givenProperties
instance.void
setReadOnly(boolean readOnly)
void
setValidatorClass(Class validatorClass)
void
setValueSet(String[] valueSet)
void
setValueSetBound(boolean valueSetBound)
void
setValueSetDelim(char delim)
void
setValueType(Class valueType)
-
-
-
Field Detail
-
VALUETYPE_KEY
public static final String VALUETYPE_KEY
- See Also:
- Constant Field Values
-
DEFAULTVALUE_KEY
public static final String DEFAULTVALUE_KEY
- See Also:
- Constant Field Values
-
NUMCOLS_KEY
public static final String NUMCOLS_KEY
- See Also:
- Constant Field Values
-
NUMROWS_KEY
public static final String NUMROWS_KEY
- See Also:
- Constant Field Values
-
WORD_WRAP_KEY
public static final String WORD_WRAP_KEY
- See Also:
- Constant Field Values
-
MINVALUE_KEY
public static final String MINVALUE_KEY
- See Also:
- Constant Field Values
-
MAXVALUE_KEY
public static final String MAXVALUE_KEY
- See Also:
- Constant Field Values
-
INCREMENT_KEY
public static final String INCREMENT_KEY
- See Also:
- Constant Field Values
-
VALUESET_KEY
public static final String VALUESET_KEY
- See Also:
- Constant Field Values
-
VALUESETBOUND_KEY
public static final String VALUESETBOUND_KEY
- See Also:
- Constant Field Values
-
VALUESETDELIM_KEY
public static final String VALUESETDELIM_KEY
- See Also:
- Constant Field Values
-
NULLVALUEALLOWED_KEY
public static final String NULLVALUEALLOWED_KEY
- See Also:
- Constant Field Values
-
EMPTYVALUESNOTALLOWED_KEY
public static final String EMPTYVALUESNOTALLOWED_KEY
- See Also:
- Constant Field Values
-
IDENTIFIERSONLY_KEY
public static final String IDENTIFIERSONLY_KEY
- See Also:
- Constant Field Values
-
CASESENSITIVE_KEY
public static final String CASESENSITIVE_KEY
- See Also:
- Constant Field Values
-
READONLY_KEY
public static final String READONLY_KEY
- See Also:
- Constant Field Values
-
HIDDEN_KEY
public static final String HIDDEN_KEY
- See Also:
- Constant Field Values
-
LABEL_KEY
public static final String LABEL_KEY
- See Also:
- Constant Field Values
-
DESCRIPTION_KEY
public static final String DESCRIPTION_KEY
- See Also:
- Constant Field Values
-
PHYSICALUNIT_KEY
public static final String PHYSICALUNIT_KEY
- See Also:
- Constant Field Values
-
VALIDATORCLASS_KEY
public static final String VALIDATORCLASS_KEY
- See Also:
- Constant Field Values
-
EDITORCLASS_KEY
public static final String EDITORCLASS_KEY
- See Also:
- Constant Field Values
-
LISTMODEL_KEY
public static final String LISTMODEL_KEY
- See Also:
- Constant Field Values
-
FILE_SELECTION_MODE_KEY
public static final String FILE_SELECTION_MODE_KEY
- See Also:
- Constant Field Values
-
LAST_DIR_KEY
public static final String LAST_DIR_KEY
- See Also:
- Constant Field Values
-
CHOOSABLE_FILE_FILTERS_KEY
public static final String CHOOSABLE_FILE_FILTERS_KEY
- See Also:
- Constant Field Values
-
CURRENT_FILE_FILTER_KEY
public static final String CURRENT_FILE_FILTER_KEY
- See Also:
- Constant Field Values
-
COMP_PRODUCTS_FOR_BAND_ARITHMETHIK_KEY
public static final String COMP_PRODUCTS_FOR_BAND_ARITHMETHIK_KEY
- See Also:
- Constant Field Values
-
SEL_PRODUCT_FOR_BAND_ARITHMETHIK_KEY
public static final String SEL_PRODUCT_FOR_BAND_ARITHMETHIK_KEY
- See Also:
- Constant Field Values
-
SELECT_ALL_ON_FOCUS_KEY
public static final String SELECT_ALL_ON_FOCUS_KEY
- See Also:
- Constant Field Values
-
FSM_FILES_ONLY
public static final int FSM_FILES_ONLY
File selection mode JFileChooser.FILES_ONLY- See Also:
- Constant Field Values
-
FSM_DIRECTORIES_ONLY
public static final int FSM_DIRECTORIES_ONLY
File selection mode JFileChooser.DIRECTORIES_ONLY- See Also:
- Constant Field Values
-
FSM_FILES_AND_DIRECTORIES
public static final int FSM_FILES_AND_DIRECTORIES
File selection mode JFileChooser.FILES_AND_DIRECTORIES- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ParamProperties
public ParamProperties()
-
ParamProperties
public ParamProperties(Class valueType)
-
ParamProperties
public ParamProperties(Class valueType, Object defaultValue, String[] valueSet, boolean valueSetBound)
-
ParamProperties
public ParamProperties(Class valueType, Number defaultValue, Number minValue, Number maxValue)
-
-
Method Detail
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener listener)
-
setValueType
public void setValueType(Class valueType)
-
getValueType
public Class getValueType()
-
setValidatorClass
public void setValidatorClass(Class validatorClass)
-
getValidatorClass
public Class getValidatorClass()
-
setEditorClass
public void setEditorClass(Class editorClass)
-
getEditorClass
public Class getEditorClass()
-
setDefaultValue
public void setDefaultValue(Object defaultValue)
-
getDefaultValue
public Object getDefaultValue()
-
setNumCols
public void setNumCols(int numCols)
-
getNumCols
public int getNumCols()
-
setNumRows
public void setNumRows(int numRows)
-
getNumRows
public int getNumRows()
-
setMinValue
public void setMinValue(Number minValue)
-
getMinValue
public Number getMinValue()
-
setMaxValue
public void setMaxValue(Number maxValue)
-
getMaxValue
public Number getMaxValue()
-
setIncrement
public void setIncrement(Number increment)
-
getIncrement
public Number getIncrement()
-
setValueSet
public void setValueSet(String[] valueSet)
-
getValueSet
public String[] getValueSet()
-
setValueSetDelim
public void setValueSetDelim(char delim)
-
getValueSetDelim
public char getValueSetDelim()
-
setValueSetBound
public void setValueSetBound(boolean valueSetBound)
-
isValueSetBound
public boolean isValueSetBound()
-
setNullValueAllowed
public void setNullValueAllowed(boolean nullAllowed)
-
isNullValueAllowed
public boolean isNullValueAllowed()
-
setEmptyValuesNotAllowed
public void setEmptyValuesNotAllowed(boolean emptyAllowed)
-
isEmptyValuesNotAllowed
public boolean isEmptyValuesNotAllowed()
-
setIdentifiersOnly
public void setIdentifiersOnly(boolean identifiersOnly)
-
isIdentifiersOnly
public boolean isIdentifiersOnly()
-
setCaseSensitive
public void setCaseSensitive(boolean caseSensitive)
-
isCaseSensitive
public boolean isCaseSensitive()
-
setReadOnly
public void setReadOnly(boolean readOnly)
-
isReadOnly
public boolean isReadOnly()
-
setHidden
public void setHidden(boolean hidden)
-
isHidden
public boolean isHidden()
-
setLabel
public void setLabel(String label)
-
getLabel
public String getLabel()
-
setDescription
public void setDescription(String description)
-
getDescription
public String getDescription()
-
setPhysicalUnit
public void setPhysicalUnit(String unit)
-
getPhysicalUnit
public String getPhysicalUnit()
-
setFileSelectionMode
public void setFileSelectionMode(int fsm)
-
getFileSelectionMode
public int getFileSelectionMode()
-
setCurrentFileFilter
public void setCurrentFileFilter(FileFilter filter)
Sets thecurrent FileFilter
used in theFileChooser
displayed when the button fromFileEditor
was klicked.- Parameters:
filter
- a javax.swing.filechooser.FileFilter
-
getCurrentFileFilter
public FileFilter getCurrentFileFilter()
Gets thecurrent FileFilter
which was set in theFileChooser
displayed when the button fromFileEditor
was klicked.
-
setChoosableFileFilters
public void setChoosableFileFilters(FileFilter[] filters)
Sets an array ofchoosable FileFilter
used in theFileChooser
displayed when the button fromFileEditor
was klicked. If noFileFilterCurrent
was set, the firstFileFilter
in this array is thecurrent FileFilter
- Parameters:
filters
- a javax.swing.filechooser.FileFilter[]
-
getChoosableFileFilters
public FileFilter[] getChoosableFileFilters()
Gets an array ofchoosable FileFilter
which was set in theFileChooser
displayed when the button fromFileEditor
was klicked.
-
setPropertyValue
public void setPropertyValue(String key, boolean value)
-
setPropertyValue
public void setPropertyValue(String key, int value)
-
setPropertyValue
public void setPropertyValue(String key, long value)
-
setPropertyValue
public void setPropertyValue(String key, float value)
-
setPropertyValue
public void setPropertyValue(String key, double value)
-
setPropertyValues
public void setPropertyValues(String paramName, PropertyMap propertyMap)
Sets the properties to the values found in the givenProperties
instance.This utility method searches for all keys in the given
Properties
instance whose keys start withparamName + "."
. The rest of the key is expected to be a validParamProperties
attribute key and the property value a corresponding textual representation of the attribute's value.The method can be used to automatically configure parameters from Java property files.
- Parameters:
paramName
- the parameter name
-
getProperties
public Map<String,Object> getProperties(String namePrefix)
Creates a subset of the properties in this map, containing only properties whose name start with the givennamePrefix
.- Parameters:
namePrefix
- the name prefix- Returns:
- the map subset
-
getPropertyValue
public Object getPropertyValue(String key)
Returns the value of the attribute with the given name. If an attribute with given name could not be found the method returnsnull
.- Parameters:
key
- the attribute key, must not benull
- Returns:
- the attribute value
-
containsProperty
public boolean containsProperty(String key)
Returnstrue
if an attribute with given name was found.- Parameters:
key
- the attribute key, must not benull
-
getPropertyValue
public boolean getPropertyValue(String key, boolean defaultValue)
Returns theboolean
value of the attribute with the given name.- Parameters:
key
- the attribute key, must not benull
defaultValue
- the default value which is returned if an attribute with the given name was not found- Returns:
- the attribute value
-
getPropertyValue
public int getPropertyValue(String key, int defaultValue)
Returns theint
value of the attribute with the given name.- Parameters:
key
- the attribute key, must not benull
defaultValue
- the default value which is returned if an attribute with the given name was not found- Returns:
- the attribute value
-
getPropertyValue
public double getPropertyValue(String key, double defaultValue)
Returns thedouble
value of the attribute with the given name.- Parameters:
key
- the attribute key, must not benull
defaultValue
- the default value which is returned if an attribute with the given name was not found- Returns:
- the attribute value
-
getPropertyValue
public Class getPropertyValue(String key, Class defaultValue)
Returns theClass
value of the attribute with the given name.- Parameters:
key
- the attribute key, must not benull
defaultValue
- the default value which is returned if an attribute with the given name was not found- Returns:
- the attribute value
-
getPropertyValue
public String getPropertyValue(String key, String defaultValue)
Returns theString
value of the attribute with the given name.- Parameters:
key
- the attribute key, must not benull
defaultValue
- the default value which is returned if an attribute with the given name was not found- Returns:
- the attribute value
-
getPropertyValue
public Object getPropertyValue(String key, Object defaultValue)
Returns theObject
value of the attribute with the given name.- Parameters:
key
- the attribute key, must not benull
defaultValue
- the default value which is returned if an attribute with the given name was not found- Returns:
- the attribute value
-
createValidator
public ParamValidator createValidator()
Creates an appropriate validator for this parameter info.- Returns:
- a validator, never
null
-
createCopy
public ParamProperties createCopy()
Creates and returns a copy of this object.
-
createPropertyMap
protected Map<String,Object> createPropertyMap(Map<String,Object> map)
Creates aMap
to be used to store the attributes. This method can be overridden in order to return a specializedMap
. The default implementation returns a newHashMap()
instance.- Parameters:
map
- the map whose mappings are to be initially placed in the new map, can benull
.
-
loadClass
protected Class loadClass(String className) throws ClassNotFoundException
Loads the class with the specified name.This method can be overridden in order to implement a specialized mechanism to load parameter validator and editor classes. The default implementation simply returns
getClass().getClassLoader().loadClass(className)
.- Parameters:
className
- the fully qualified name of the class- Returns:
- the resulting Class object
- Throws:
ClassNotFoundException
- if the class was not found
-
-