public abstract class AbstractUserConfiguration extends Object
User configuration base class. It defines basic methods of
manipulation with the configuration parameters. The class is abstract and
all successors must implement the get()
and put()
methods.
Each parameter value is stored as a string. The class provides methods
such as getDouble()
, setDouble()
,
getInteger()
and setInteger()
that
perform conversion between number and string.
The configuration is also capable of saving a set of numbers as one parameter.
The numbers are converted to a string which contains the numbers formatted
by US number format separated by semicolon. The associated methods are
getListOfNumbers(java.lang.String)
and
setListOfNumbers(java.lang.String, java.util.List<? extends java.lang.Number>)
. The numbers are always saved and
restored in the same order (the same as in the vector).
If a component depends on any option value in this class, it should
register itself using the method
addConfigurationListener()
and it will be notified
about any changes in the configuration immediately when a set method is
called.
T-Plan Robot Enterprise, (C) 2009-2022 T-Plan Limited. All rights reserved.
Constructor and Description |
---|
AbstractUserConfiguration()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addConfigurationListener(ConfigurationChangeListener l)
Add a configuration change listener
|
void |
addConfigurationListener(WeakReference<ConfigurationChangeListener> l) |
List<? extends Number> |
convertToListOfNumbers(Object obj)
Perform conversion from an object to a list of numbers.
|
void |
fireConfigurationChanged(ConfigurationChangeEvent e)
Fire a ChangeEvent to all registered listeners when the configuration
gets changed.
|
byte[] |
getArrayOfBytes(String parameterName)
Get the value of a parameter as an array of integers.
|
int[] |
getArrayOfInts(String parameterName)
Get the value of a parameter as an array of integers.
|
Boolean |
getBoolean(String parameterName)
Get a parameter as a Boolean.
|
Boolean |
getBooleanStrict(String parameterName)
Get a parameter as a Boolean.
|
Color |
getColor(String parameterName)
Get a parameter value and try to convert it to a Color instance.
|
Color[] |
getColors(String parameterName)
Get a parameter value and try to convert it to an array of colors.
|
Double |
getDouble(String parameterName)
Get a parameter as a Double.
|
Double |
getDoubleStrict(String parameterName)
Get a parameter as a Double.
|
Integer |
getInteger(String parameterName)
Get a parameter as an Integer.
|
Integer |
getIntegerStrict(String parameterName)
Get a parameter as an Integer.
|
List<? extends Number> |
getListOfNumbers(String parameterName)
Get the value of a parameter as a vector of double values.
|
List<String> |
getListOfStrings(String parameterName)
Get the value of a parameter as a vector of String values.
|
String |
getString(String parameterName)
Get a parameter as a String.
|
boolean |
isModified()
Get value of the modification flag.
|
void |
removeConfigurationListener(ConfigurationChangeListener l)
Remove a configuration change listener
|
void |
setBoolean(String parameterName,
Boolean b)
Set the parameter as an Boolean
|
void |
setDouble(String parameterName,
Number number) |
void |
setHTMLColor(String parameterName,
Color color) |
void |
setHTMLColorArray(String parameterName,
Color[] colors) |
void |
setInteger(String parameterName,
Number number)
Set the parameter as an Integer
|
void |
setListOfNumbers(String parameterName,
List<? extends Number> values)
Set a parameter as a vector of double values.
|
void |
setListOfObjects(String parameterName,
List values)
Set a parameter as a vector of objects.
|
void |
setString(String parameterName,
String value)
Set a String parameter.
|
public void removeConfigurationListener(ConfigurationChangeListener l)
l
- a configuration change listenerpublic void addConfigurationListener(ConfigurationChangeListener l)
l
- a configuration change listenerpublic void addConfigurationListener(WeakReference<ConfigurationChangeListener> l)
public void fireConfigurationChanged(ConfigurationChangeEvent e)
e
- a change event.public Double getDouble(String parameterName)
parameterName
- parameter nameNumberFormatException
- if the parameter cannot be converted
to Doublepublic Double getDoubleStrict(String parameterName)
parameterName
- parameter nameIllegalArgumentException
- if the parameter is not a valid number.public Integer getInteger(String parameterName)
parameterName
- parameter nameNumberFormatException
- if the parameter cannot be converted
to Integerpublic Integer getIntegerStrict(String parameterName)
parameterName
- parameter nameIllegalArgumentException
- if the parameter is not a valid number.public void setInteger(String parameterName, Number number)
parameterName
- parameter namenumber
- a number to be saved as integer under the parameter namepublic Boolean getBoolean(String parameterName)
parameterName
- parameter namepublic Boolean getBooleanStrict(String parameterName) throws IllegalArgumentException
IllegalArgumentException
.parameterName
- parameter nameIllegalArgumentException
public void setBoolean(String parameterName, Boolean b)
parameterName
- parameter nameb
- a boolean value to be savedpublic List<String> getListOfStrings(String parameterName)
parameterName
- parameter name.public List<? extends Number> getListOfNumbers(String parameterName)
parameterName
- parameter name.public int[] getArrayOfInts(String parameterName)
parameterName
- parameter name.public byte[] getArrayOfBytes(String parameterName)
parameterName
- parameter name.public List<? extends Number> convertToListOfNumbers(Object obj)
obj
- an object (a user parameter value)public void setListOfNumbers(String parameterName, List<? extends Number> values)
parameterName
- parameter name.values
- a Vector which contains Number instances.public void setListOfObjects(String parameterName, List values)
parameterName
- parameter name.values
- a Vector.public String getString(String parameterName)
parameterName
- parameter name.public void setString(String parameterName, String value)
parameterName
- parameter name.value
- a String value to be saved under the parameter name.public boolean isModified()
public Color getColor(String parameterName)
setHTMLColor(java.lang.String, java.awt.Color)
method for more information.parameterName
- name of the parameter.public Color[] getColors(String parameterName)
setHTMLColor(java.lang.String, java.awt.Color)
method for more information.parameterName
- name of the parameter.