public class Settings
extends java.lang.Object
implements java.io.Serializable
Defaults
objects) can be applied to provide initial defaults (or to allow new settings
that have yet to be persisted to be added in the future).Modifier and Type | Class and Description |
---|---|
static class |
Settings.SettingKey
Class implementing a key for a setting.
|
Constructor and Description |
---|
Settings(java.lang.String storeName,
java.lang.String ID)
Construct a new Settings object to be stored in the supplied store under
the given ID/name
|
Modifier and Type | Method and Description |
---|---|
void |
applyDefaults(Defaults defaults)
Applies a set of default settings.
|
java.lang.String |
getID()
Get the ID used for these settings
|
<T> T |
getSetting(java.lang.String ID,
Settings.SettingKey key,
T defaultValue)
Get the value of a setting
|
<T> T |
getSetting(java.lang.String ID,
Settings.SettingKey key,
T defaultValue,
Environment env)
Get the value of a setting
|
<T> T |
getSetting(java.lang.String ID,
java.lang.String key,
T defaultValue,
Environment env) |
java.util.Map<Settings.SettingKey,java.lang.Object> |
getSettings(java.lang.String settingsID)
Get the settings for a given ID
|
java.util.Set<java.lang.String> |
getSettingsIDs()
Get a list of settings IDs
|
java.lang.String |
getStoreName()
Get the store name for these settings
|
boolean |
hasSetting(java.lang.String settingsID,
java.lang.String propName)
Returns true if a given setting has a value
|
boolean |
hasSettings(java.lang.String settingsID)
Returns true if there are settings available for a given ID
|
void |
loadSettings()
Load the settings with ID m_ID from store m_storeName.
|
void |
saveSettings()
Save the settings to the metastore
|
void |
setSetting(java.lang.String ID,
Settings.SettingKey propName,
java.lang.Object value)
Set a value for a setting.
|
public Settings(java.lang.String storeName, java.lang.String ID)
storeName
- the name of the store to load/save to in the metastoreID
- the ID/name to usepublic void loadSettings() throws java.io.IOException
java.io.IOException
- if a problem occurspublic java.lang.String getID()
public java.lang.String getStoreName()
public void applyDefaults(Defaults defaults)
defaults
- the defaults to applypublic java.util.Map<Settings.SettingKey,java.lang.Object> getSettings(java.lang.String settingsID)
settingsID
- the ID to get settings forpublic java.util.Set<java.lang.String> getSettingsIDs()
public <T> T getSetting(java.lang.String ID, java.lang.String key, T defaultValue, Environment env)
public <T> T getSetting(java.lang.String ID, Settings.SettingKey key, T defaultValue)
T
- the type of the vaueID
- the ID for settings map to lookup (typically the ID of a
perspective)key
- the name of the setting value to lookupdefaultValue
- the default value to use if the setting is not knownpublic <T> T getSetting(java.lang.String ID, Settings.SettingKey key, T defaultValue, Environment env)
T
- the type of the vaueID
- the ID for settings map to lookup (typically the ID of a
perspective)key
- the name of the setting value to lookupdefaultValue
- the default value to use if the setting is not knownenv
- environment variables to use. String setting values will have
environment variables replaced automaticallypublic void setSetting(java.lang.String ID, Settings.SettingKey propName, java.lang.Object value)
ID
- the for the settings map to store the setting in (typically the
ID of a perspective or application)propName
- the name of the setting to storevalue
- the value of the setting to storepublic boolean hasSettings(java.lang.String settingsID)
settingsID
- the ID to checkpublic boolean hasSetting(java.lang.String settingsID, java.lang.String propName)
settingsID
- the ID of the settings grouppropName
- the actual setting to check forpublic void saveSettings() throws java.io.IOException
java.io.IOException
- if a problem occurs