|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Settings
Interface used to store the settings of an application.
It provides a kind of service able to store some object values and retrieve them using a string key. It also provide
PropertyChangeListener support to listen to settings changes (if needed).
This settings store allows to convert the file properties (strings representing file paths) from absolute to relative (and vice-versa). The idea is that the file settings values are always stored relatively to the base path (and always get as absolute). So if you move or copy your application to another directory (and if the base path is correctly updated by the application) every file property will be resolved to the correct location.
| Method Summary | ||
|---|---|---|
void |
addPropertyChangeListener(String settingKey,
PropertyChangeListener listener)
Add a PropertyChangeListener for a specific setting. |
|
boolean |
containsProperty(String key)
Check if there is a property value defined for the given key. |
|
boolean |
getBooleanProperty(String key,
boolean defaultValue)
Get a boolean property value. |
|
Boolean |
getBooleanProperty(String key,
Boolean defaultValue)
Get a Boolean property value. |
|
Color |
getColorProperty(String key,
Color defaultValue)
Get a Color property value. |
|
Dimension |
getDimensionProperty(String key,
Dimension defaultValue)
Get a Dimension property value. |
|
double |
getDoubleProperty(String key,
double defaultValue)
Get a double property value. |
|
|
getEnumProperty(String key,
T defaultValue)
Get a enumerated property value. |
|
FilePathUtils |
getFilePathUtils()
Get the FilePathUtils used by this settings object. |
|
String |
getFileProperty(String key,
String defaultValue)
Get a absolute File or Directory property value. |
|
String |
getFileProperty(String key,
String defaultValue,
boolean absolute)
Get a File or Directory property value. |
|
int[] |
getIntArrayProperty(String key,
int[] defaultValue)
Get a int array property value. |
|
Integer |
getIntegerProperty(String key,
Integer defaultValue)
Get a Integer property value. |
|
int |
getIntProperty(String key,
int defaultValue)
Get a int property value. |
|
Iterator<String> |
getKeys()
Return an iterator for all the defined keys. |
|
String |
getPasswordProperty(String key,
String defaultValue)
Get a String property value to be used as a password. |
|
|
getProperty(String key,
TypeHelper<T> helper,
T defaultValue)
Get a property of type defined by the helper. |
|
String |
getPropertyAsInternalString(String key)
Get a property as stored internally by the map (as string). |
|
String |
getPropertyFilePath()
Get the path to the property file used to store the settings. |
|
Rectangle |
getRectangleProperty(String key,
Rectangle defaultValue)
Get a Rectangle property value. |
|
String[] |
getStringArrayProperty(String key,
String[] defaultValue)
Get a String array property value. |
|
String |
getStringProperty(String key,
String defaultValue)
Get a String property value. |
|
void |
load()
Ask the settings implementation to load the settings values. |
|
void |
removeProperty(String key)
Remove the property. |
|
void |
removePropertyChangeListener(String settingKey,
PropertyChangeListener listener)
Remove a PropertyChangeListener for a specific setting. |
|
void |
save()
Ask the settings implementation to save the settings values. |
|
void |
saveAs(File fil)
Save all the settings to a new property file. |
|
void |
setBooleanProperty(String key,
boolean value)
Set a new value for a boolean property. |
|
void |
setBooleanProperty(String key,
Boolean value)
Set a new value for a Boolean property. |
|
void |
setColorProperty(String key,
Color value)
Set a new value for a Color property. |
|
void |
setDimensionProperty(String key,
Dimension value)
Set a new value for a Dimension property. |
|
void |
setDoubleProperty(String key,
double value)
Set a new value for a double property. |
|
|
setEnumProperty(String key,
T value)
Set a new value for a enumerated property. |
|
void |
setFileProperty(String key,
String value)
Set a new value for a File or Directory property. |
|
void |
setIntArrayProperty(String key,
int[] value)
Set a new value for a int array property. |
|
void |
setIntegerProperty(String key,
Integer value)
Set a new value for a Integer property. |
|
void |
setIntProperty(String key,
int value)
Set a new value for a int property. |
|
void |
setPasswordProperty(String key,
String value)
Set a new value for a String property. |
|
|
setProperty(String key,
TypeHelper<T> helper,
T value)
Set a property of type defined by the helper. |
|
void |
setPropertyAsInternalString(String key,
String value)
Set a property value using its internal string representation. |
|
void |
setPropertyFile(File fil)
Set a new property file to store the settings. |
|
void |
setRectangleProperty(String key,
Rectangle value)
Set a new value for a Rectangle property. |
|
void |
setStringArrayProperty(String key,
String[] value)
Set a new value for a String array property. |
|
void |
setStringProperty(String key,
String value)
Set a new value for a String property. |
|
| Method Detail |
|---|
FilePathUtils getFilePathUtils()
String getPropertyFilePath()
void load()
throws IOException
Settings implementation.)
IOException - If something prevents the settings to be loaded.
void save()
throws IOException
Settings implementation.)
IOException - If something prevents the settings to be saved.void setPropertyFile(File fil)
fil - The new properties file.
void saveAs(File fil)
throws IOException
fil - The new properties file.
IOException - If something prevents the settings to be saved.boolean containsProperty(String key)
key - Key for the value.
void removeProperty(String key)
key - Key of the property to remove.Iterator<String> getKeys()
String getStringProperty(String key,
String defaultValue)
key - Key for the value.defaultValue - Default value to be returned if no value is found for the key.
void setStringProperty(String key,
String value)
key - Key for the value.value - New value to be associated with the key.
String getPasswordProperty(String key,
String defaultValue)
key - Key for the value.defaultValue - Default value to be returned if no value is found for the key.
void setPasswordProperty(String key,
String value)
key - Key for the value.value - New value to be associated with the key.
String[] getStringArrayProperty(String key,
String[] defaultValue)
key - Key for the value.defaultValue - Default value to be returned if no value is found for the key.
void setStringArrayProperty(String key,
String[] value)
key - Key for the value.value - New value to be associated with the key.
int getIntProperty(String key,
int defaultValue)
key - Key for the value.defaultValue - Default value to be returned if no value is found for the key.
void setIntProperty(String key,
int value)
key - Key for the value.value - New value to be associated with the key.
Integer getIntegerProperty(String key,
Integer defaultValue)
key - Key for the value.defaultValue - Default value to be returned if no value is found for the key.
void setIntegerProperty(String key,
Integer value)
key - Key for the value.value - New value to be associated with the key.
double getDoubleProperty(String key,
double defaultValue)
key - Key for the value.defaultValue - Default value to be returned if no value is found for the key.
void setDoubleProperty(String key,
double value)
key - Key for the value.value - New value to be associated with the key.
boolean getBooleanProperty(String key,
boolean defaultValue)
key - Key for the value.defaultValue - Default value to be returned if no value is found for the key.
void setBooleanProperty(String key,
boolean value)
key - Key for the value.value - New value to be associated with the key.
Boolean getBooleanProperty(String key,
Boolean defaultValue)
key - Key for the value.defaultValue - Default value to be returned if no value is found for the key.
void setBooleanProperty(String key,
Boolean value)
key - Key for the value.value - New value to be associated with the key.
int[] getIntArrayProperty(String key,
int[] defaultValue)
key - Key for the value.defaultValue - Default value to be returned if no value is found for the key.
void setIntArrayProperty(String key,
int[] value)
key - Key for the value.value - New value to be associated with the key.
Rectangle getRectangleProperty(String key,
Rectangle defaultValue)
key - Key for the value.defaultValue - Default value to be returned if no value is found for the key.
void setRectangleProperty(String key,
Rectangle value)
key - Key for the value.value - New value to be associated with the key.
Dimension getDimensionProperty(String key,
Dimension defaultValue)
key - Key for the value.defaultValue - Default value to be returned if no value is found for the key.
void setDimensionProperty(String key,
Dimension value)
key - Key for the value.value - New value to be associated with the key.
Color getColorProperty(String key,
Color defaultValue)
key - Key for the value.defaultValue - Default value to be returned if no value is found for the key.
void setColorProperty(String key,
Color value)
key - Key for the value.value - New value to be associated with the key.
<T extends Enum<T>> T getEnumProperty(String key,
T defaultValue)
key - Key for the value.defaultValue - Default value to be returned if no value is found for the key.
<T extends Enum<T>> void setEnumProperty(String key,
T value)
key - Key for the value.value - New value to be associated with the key.
String getFileProperty(String key,
String defaultValue)
key - Key for the value.defaultValue - Default value to be returned if no value is found for the key. (if used, the default value will be processed to
ensure it's absolute)
String getFileProperty(String key,
String defaultValue,
boolean absolute)
key - Key for the value.defaultValue - Default value to be returned if no value is found for the key. (if used, the default value will be processed to
ensure it's relative or absolute as requested)absolute - tells if the returned file should be absolute or relative to the settings base directory.
void setFileProperty(String key,
String value)
throws InvalidPathException
key - Key for the value.value - New value to be associated with the key.
InvalidPathException - if the file set is invalid.String getPropertyAsInternalString(String key)
key - Key for the property value.
void setPropertyAsInternalString(String key,
String value)
key - Key for the property value.value - The new value of the property to associate to the given key.
<T> T getProperty(String key,
TypeHelper<T> helper,
T defaultValue)
TypeHelper classes). For properties using a pre-defined type you should use the type-specific
method.
Note that if you create a new data type the same type helper INSTANCE should be used in all set and get for this type.
key - Key for the property value.helper - Helper identifying the value type and knowing how to convert between string and the requested type. If the helper
is null, a string value is returned.
<T> void setProperty(String key,
TypeHelper<T> helper,
T value)
TypeHelper classes). For properties using a pre-defined type you should use the type-specific
method. Note that if you create a new data type the same type helper INSTANCE should be used in all set and get for this type.
key - Key for the property value.helper - Helper identifying the value type and knowing how to convert between string and the requested type. If the given
helper is null, the property will be stored as string (with basic toString conversion in the backing
properties map). When the given helper is null, no propertyChange event is generated.value - The new value of the property to associate to the given key.
void addPropertyChangeListener(String settingKey,
PropertyChangeListener listener)
settingKey - The key of the setting to listen on.listener - The PropertyChangeListener to be added
void removePropertyChangeListener(String settingKey,
PropertyChangeListener listener)
settingKey - The key of the setting that was listened on.listener - The PropertyChangeListener to be removed
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||