public class Settings extends Object implements 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(String storeName,
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.
|
String |
getID()
Get the ID used for these settings
|
<T> T |
getSetting(String ID,
Settings.SettingKey key,
T defaultValue)
Get the value of a setting
|
<T> T |
getSetting(String ID,
Settings.SettingKey key,
T defaultValue,
Environment env)
Get the value of a setting
|
<T> T |
getSetting(String ID,
String key,
T defaultValue,
Environment env) |
Map<Settings.SettingKey,Object> |
getSettings(String settingsID)
Get the settings for a given ID
|
Set<String> |
getSettingsIDs()
Get a list of settings IDs
|
String |
getStoreName()
Get the store name for these settings
|
boolean |
hasSetting(String settingsID,
String propName)
Returns true if a given setting has a value
|
boolean |
hasSettings(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(String ID,
Settings.SettingKey propName,
Object value)
Set a value for a setting.
|
public void loadSettings()
throws IOException
IOException - if a problem occurspublic String getID()
public String getStoreName()
public void applyDefaults(Defaults defaults)
defaults - the defaults to applypublic Map<Settings.SettingKey,Object> getSettings(String settingsID)
settingsID - the ID to get settings forpublic Set<String> getSettingsIDs()
public <T> T getSetting(String ID, String key, T defaultValue, Environment env)
public <T> T getSetting(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(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(String ID, Settings.SettingKey propName, 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(String settingsID)
settingsID - the ID to checkpublic boolean hasSetting(String settingsID, String propName)
settingsID - the ID of the settings grouppropName - the actual setting to check forpublic void saveSettings()
throws IOException
IOException - if a problem occursCopyright © 2016 University of Waikato, Hamilton, NZ. All Rights Reserved.