Package org.esa.snap.core.param
Class ParamProperties
- java.lang.Object
-
- org.esa.snap.core.param.ParamProperties
-
public class ParamProperties extends Object
TheParamPropertiesclass 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 voidaddPropertyChangeListener(PropertyChangeListener listener)booleancontainsProperty(String key)Returnstrueif an attribute with given name was found.ParamPropertiescreateCopy()Creates and returns a copy of this object.protected Map<String,Object>createPropertyMap(Map<String,Object> map)Creates aMapto be used to store the attributes.ParamValidatorcreateValidator()Creates an appropriate validator for this parameter info.FileFilter[]getChoosableFileFilters()Gets an array ofchoosable FileFilterwhich was set in theFileChooserdisplayed when the button fromFileEditorwas klicked.FileFiltergetCurrentFileFilter()Gets thecurrent FileFilterwhich was set in theFileChooserdisplayed when the button fromFileEditorwas klicked.ObjectgetDefaultValue()StringgetDescription()ClassgetEditorClass()intgetFileSelectionMode()NumbergetIncrement()StringgetLabel()NumbergetMaxValue()NumbergetMinValue()intgetNumCols()intgetNumRows()StringgetPhysicalUnit()Map<String,Object>getProperties(String namePrefix)Creates a subset of the properties in this map, containing only properties whose name start with the givennamePrefix.ObjectgetPropertyValue(String key)Returns the value of the attribute with the given name.booleangetPropertyValue(String key, boolean defaultValue)Returns thebooleanvalue of the attribute with the given name.doublegetPropertyValue(String key, double defaultValue)Returns thedoublevalue of the attribute with the given name.intgetPropertyValue(String key, int defaultValue)Returns theintvalue of the attribute with the given name.ClassgetPropertyValue(String key, Class defaultValue)Returns theClassvalue of the attribute with the given name.ObjectgetPropertyValue(String key, Object defaultValue)Returns theObjectvalue of the attribute with the given name.StringgetPropertyValue(String key, String defaultValue)Returns theStringvalue of the attribute with the given name.ClassgetValidatorClass()String[]getValueSet()chargetValueSetDelim()ClassgetValueType()booleanisCaseSensitive()booleanisEmptyValuesNotAllowed()booleanisHidden()booleanisIdentifiersOnly()booleanisNullValueAllowed()booleanisReadOnly()booleanisValueSetBound()protected ClassloadClass(String className)Loads the class with the specified name.voidremovePropertyChangeListener(PropertyChangeListener listener)voidsetCaseSensitive(boolean caseSensitive)voidsetChoosableFileFilters(FileFilter[] filters)Sets an array ofchoosable FileFilterused in theFileChooserdisplayed when the button fromFileEditorwas klicked.voidsetCurrentFileFilter(FileFilter filter)Sets thecurrent FileFilterused in theFileChooserdisplayed when the button fromFileEditorwas klicked.voidsetDefaultValue(Object defaultValue)voidsetDescription(String description)voidsetEditorClass(Class editorClass)voidsetEmptyValuesNotAllowed(boolean emptyAllowed)voidsetFileSelectionMode(int fsm)voidsetHidden(boolean hidden)voidsetIdentifiersOnly(boolean identifiersOnly)voidsetIncrement(Number increment)voidsetLabel(String label)voidsetMaxValue(Number maxValue)voidsetMinValue(Number minValue)voidsetNullValueAllowed(boolean nullAllowed)voidsetNumCols(int numCols)voidsetNumRows(int numRows)voidsetPhysicalUnit(String unit)voidsetPropertyValue(String key, boolean value)voidsetPropertyValue(String key, double value)voidsetPropertyValue(String key, float value)voidsetPropertyValue(String key, int value)voidsetPropertyValue(String key, long value)voidsetPropertyValue(String key, Object value)voidsetPropertyValues(String paramName, PropertyMap propertyMap)Sets the properties to the values found in the givenPropertiesinstance.voidsetReadOnly(boolean readOnly)voidsetValidatorClass(Class validatorClass)voidsetValueSet(String[] valueSet)voidsetValueSetBound(boolean valueSetBound)voidsetValueSetDelim(char delim)voidsetValueType(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 FileFilterused in theFileChooserdisplayed when the button fromFileEditorwas klicked.- Parameters:
filter- a javax.swing.filechooser.FileFilter
-
getCurrentFileFilter
public FileFilter getCurrentFileFilter()
Gets thecurrent FileFilterwhich was set in theFileChooserdisplayed when the button fromFileEditorwas klicked.
-
setChoosableFileFilters
public void setChoosableFileFilters(FileFilter[] filters)
Sets an array ofchoosable FileFilterused in theFileChooserdisplayed when the button fromFileEditorwas klicked. If noFileFilterCurrentwas set, the firstFileFilterin this array is thecurrent FileFilter- Parameters:
filters- a javax.swing.filechooser.FileFilter[]
-
getChoosableFileFilters
public FileFilter[] getChoosableFileFilters()
Gets an array ofchoosable FileFilterwhich was set in theFileChooserdisplayed when the button fromFileEditorwas 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 givenPropertiesinstance.This utility method searches for all keys in the given
Propertiesinstance whose keys start withparamName + ".". The rest of the key is expected to be a validParamPropertiesattribute 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)
Returnstrueif an attribute with given name was found.- Parameters:
key- the attribute key, must not benull
-
getPropertyValue
public boolean getPropertyValue(String key, boolean defaultValue)
Returns thebooleanvalue of the attribute with the given name.- Parameters:
key- the attribute key, must not benulldefaultValue- 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 theintvalue of the attribute with the given name.- Parameters:
key- the attribute key, must not benulldefaultValue- 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 thedoublevalue of the attribute with the given name.- Parameters:
key- the attribute key, must not benulldefaultValue- 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 theClassvalue of the attribute with the given name.- Parameters:
key- the attribute key, must not benulldefaultValue- 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 theStringvalue of the attribute with the given name.- Parameters:
key- the attribute key, must not benulldefaultValue- 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 theObjectvalue of the attribute with the given name.- Parameters:
key- the attribute key, must not benulldefaultValue- 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 aMapto 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
-
-