org.esa.beam.framework.param
Class ParamProperties

java.lang.Object
  extended by org.esa.beam.framework.param.ParamProperties

public class ParamProperties
extends Object

The ParamProperties 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$
Author:
Norman Fomferra, Sabine Embacher
See Also:
Parameter, ParamEditor, ParamValidator

Field Summary
static String CASESENSITIVE_KEY
           
static String CHOOSABLE_FILE_FILTERS_KEY
           
static String COMP_PRODUCTS_FOR_BAND_ARITHMETHIK_KEY
           
static String CURRENT_FILE_FILTER_KEY
           
static String DEFAULTVALUE_KEY
           
static String DESCRIPTION_KEY
           
static String EDITORCLASS_KEY
           
static String EMPTYVALUESNOTALLOWED_KEY
           
static String FILE_SELECTION_MODE_KEY
           
static int FSM_DIRECTORIES_ONLY
          File selection mode JFileChooser.DIRECTORIES_ONLY
static int FSM_FILES_AND_DIRECTORIES
          File selection mode JFileChooser.FILES_AND_DIRECTORIES
static int FSM_FILES_ONLY
          File selection mode JFileChooser.FILES_ONLY
static String HIDDEN_KEY
           
static String IDENTIFIERSONLY_KEY
           
static String INCREMENT_KEY
           
static String LABEL_KEY
           
static String LAST_DIR_KEY
           
static String LISTMODEL_KEY
           
static String MAXVALUE_KEY
           
static String MINVALUE_KEY
           
static String NULLVALUEALLOWED_KEY
           
static String NUMCOLS_KEY
           
static String NUMROWS_KEY
           
static String PHYSICALUNIT_KEY
           
static String READONLY_KEY
           
static String SEL_PRODUCT_FOR_BAND_ARITHMETHIK_KEY
           
static String SELECT_ALL_ON_FOCUS_KEY
           
static String VALIDATORCLASS_KEY
           
static String VALUESET_KEY
           
static String VALUESETBOUND_KEY
           
static String VALUESETDELIM_KEY
           
static String VALUETYPE_KEY
           
static String WORD_WRAP_KEY
           
 
Constructor Summary
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
 void addPropertyChangeListener(PropertyChangeListener listener)
           
 boolean containsProperty(String key)
          Returns true 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 a Map to be used to store the attributes.
 ParamValidator createValidator()
          Creates an appropriate validator for this parameter info.
 FileFilter[] getChoosableFileFilters()
          Gets an array of choosable FileFilter which was set in the FileChooser displayed when the button from FileEditor was klicked.
 FileFilter getCurrentFileFilter()
          Gets the current FileFilter which was set in the FileChooser displayed when the button from FileEditor 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 given namePrefix.
 Object getPropertyValue(String key)
          Returns the value of the attribute with the given name.
 boolean getPropertyValue(String key, boolean defaultValue)
          Returns the boolean value of the attribute with the given name.
 Class getPropertyValue(String key, Class defaultValue)
          Returns the Class value of the attribute with the given name.
 double getPropertyValue(String key, double defaultValue)
          Returns the double value of the attribute with the given name.
 int getPropertyValue(String key, int defaultValue)
          Returns the int value of the attribute with the given name.
 Object getPropertyValue(String key, Object defaultValue)
          Returns the Object value of the attribute with the given name.
 String getPropertyValue(String key, String defaultValue)
          Returns the String 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 of choosable FileFilter used in the FileChooser displayed when the button from FileEditor was klicked.
 void setCurrentFileFilter(FileFilter filter)
          Sets the current FileFilter used in the FileChooser displayed when the button from FileEditor 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 given Properties 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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)

ParamProperties

public ParamProperties(Class valueType,
                       Object defaultValue,
                       String[] valueSet)

ParamProperties

public ParamProperties(Class valueType,
                       Object defaultValue,
                       String[] valueSet,
                       boolean valueSetBound)

ParamProperties

public ParamProperties(Class valueType,
                       Number defaultValue,
                       Number minValue,
                       Number maxValue)

ParamProperties

public ParamProperties(Class valueType,
                       Number defaultValue,
                       Number minValue,
                       Number maxValue,
                       Number increment)
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 the current FileFilter used in the FileChooser displayed when the button from FileEditor was klicked.

Parameters:
filter - a javax.swing.filechooser.FileFilter

getCurrentFileFilter

public FileFilter getCurrentFileFilter()
Gets the current FileFilter which was set in the FileChooser displayed when the button from FileEditor was klicked.


setChoosableFileFilters

public void setChoosableFileFilters(FileFilter[] filters)
Sets an array of choosable FileFilter used in the FileChooser displayed when the button from FileEditor was klicked. If no FileFilterCurrent was set, the first FileFilter in this array is the current FileFilter

Parameters:
filters - a javax.swing.filechooser.FileFilter[]

getChoosableFileFilters

public FileFilter[] getChoosableFileFilters()
Gets an array of choosable FileFilter which was set in the FileChooser displayed when the button from FileEditor 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)

setPropertyValue

public void setPropertyValue(String key,
                             Object value)

setPropertyValues

public void setPropertyValues(String paramName,
                              PropertyMap propertyMap)
Sets the properties to the values found in the given Properties instance.

This utility method searches for all keys in the given Properties instance whose keys start with paramName + ".". The rest of the key is expected to be a valid ParamProperties 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 given namePrefix.

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 returns null.

Parameters:
key - the attribute key, must not be null
Returns:
the attribute value

containsProperty

public boolean containsProperty(String key)
Returns true if an attribute with given name was found.

Parameters:
key - the attribute key, must not be null

getPropertyValue

public boolean getPropertyValue(String key,
                                boolean defaultValue)
Returns the boolean value of the attribute with the given name.

Parameters:
key - the attribute key, must not be null
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 the int value of the attribute with the given name.

Parameters:
key - the attribute key, must not be null
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 the double value of the attribute with the given name.

Parameters:
key - the attribute key, must not be null
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 the Class value of the attribute with the given name.

Parameters:
key - the attribute key, must not be null
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 the String value of the attribute with the given name.

Parameters:
key - the attribute key, must not be null
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 the Object value of the attribute with the given name.

Parameters:
key - the attribute key, must not be null
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 a Map to be used to store the attributes. This method can be overridden in order to return a specialized Map. The default implementation returns a new HashMap() instance.

Parameters:
map - the map whose mappings are to be initially placed in the new map, can be null.

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


Copyright © 2002-2012 Brockmann Consult GmbH. All Rights Reserved.