Package weka.core
Class Settings
java.lang.Object
weka.core.Settings
- All Implemented Interfaces:
Serializable
Maintains a collection of settings. Settings are key value pairs which can be
grouped together under a given name. All settings managed by an instance
of this class are persisted in the central metastore under a given store
name. For example, the store name could be the name/ID of an application/
system, and settings could be grouped according to applications, components,
panels etc. Default settings (managed by
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).- Version:
- $Revision: $
- Author:
- Mark Hall (mhall{[at]}pentaho{[dot]}com)
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Class implementing a key for a setting. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
applyDefaults
(Defaults defaults) Applies a set of default settings.getID()
Get the ID used for these settings<T> T
getSetting
(String ID, String key, T defaultValue, Environment env) <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 settinggetSettings
(String settingsID) Get the settings for a given IDGet a list of settings IDsGet the store name for these settingsboolean
hasSetting
(String settingsID, String propName) Returns true if a given setting has a valueboolean
hasSettings
(String settingsID) Returns true if there are settings available for a given IDvoid
Load the settings with ID m_ID from store m_storeName.void
Save the settings to the metastorevoid
setSetting
(String ID, Settings.SettingKey propName, Object value) Set a value for a setting.
-
Constructor Details
-
Settings
Construct a new Settings object to be stored in the supplied store under the given ID/name- Parameters:
storeName
- the name of the store to load/save to in the metastoreID
- the ID/name to use
-
-
Method Details
-
loadSettings
Load the settings with ID m_ID from store m_storeName.- Throws:
IOException
- if a problem occurs
-
getID
Get the ID used for these settings- Returns:
- the ID used
-
getStoreName
Get the store name for these settings- Returns:
- the store name
-
applyDefaults
Applies a set of default settings. If the ID of default settings is not known then a new entry is made for it. Otherwise we examine all settings in the default set supplied and add any that we don't have a value for.- Parameters:
defaults
- the defaults to apply
-
getSettings
Get the settings for a given ID- Parameters:
settingsID
- the ID to get settings for- Returns:
- a map of settings, or null if the given ID is unknown
-
getSettingsIDs
Get a list of settings IDs- Returns:
- a list of the settings IDs managed by this settings instance
-
getSetting
-
getSetting
Get the value of a setting- Type Parameters:
T
- the type of the vaue- Parameters:
ID
- 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 known- Returns:
- the setting value, or the default value if not found
-
getSetting
Get the value of a setting- Type Parameters:
T
- the type of the vaue- Parameters:
ID
- 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 automatically- Returns:
- the setting value, or the default value if not found
-
setSetting
Set a value for a setting.- Parameters:
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 store
-
hasSettings
Returns true if there are settings available for a given ID- Parameters:
settingsID
- the ID to check- Returns:
- true if there are settings available for that ID
-
hasSetting
Returns true if a given setting has a value- Parameters:
settingsID
- the ID of the settings grouppropName
- the actual setting to check for- Returns:
- true if the setting has a value
-
saveSettings
Save the settings to the metastore- Throws:
IOException
- if a problem occurs
-