Package weka.core
Class Settings
- java.lang.Object
-
- weka.core.Settings
-
- All Implemented Interfaces:
java.io.Serializable
public class Settings extends java.lang.Object implements java.io.SerializableMaintains 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 byDefaultsobjects) 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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSettings.SettingKeyClass implementing a key for a setting.
-
Constructor Summary
Constructors Constructor 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
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyDefaults(Defaults defaults)Applies a set of default settings.java.lang.StringgetID()Get the ID used for these settings<T> TgetSetting(java.lang.String ID, java.lang.String key, T defaultValue, Environment env)<T> TgetSetting(java.lang.String ID, Settings.SettingKey key, T defaultValue)Get the value of a setting<T> TgetSetting(java.lang.String ID, Settings.SettingKey key, T defaultValue, Environment env)Get the value of a settingjava.util.Map<Settings.SettingKey,java.lang.Object>getSettings(java.lang.String settingsID)Get the settings for a given IDjava.util.Set<java.lang.String>getSettingsIDs()Get a list of settings IDsjava.lang.StringgetStoreName()Get the store name for these settingsbooleanhasSetting(java.lang.String settingsID, java.lang.String propName)Returns true if a given setting has a valuebooleanhasSettings(java.lang.String settingsID)Returns true if there are settings available for a given IDvoidloadSettings()Load the settings with ID m_ID from store m_storeName.voidsaveSettings()Save the settings to the metastorevoidsetSetting(java.lang.String ID, Settings.SettingKey propName, java.lang.Object value)Set a value for a setting.
-
-
-
Method Detail
-
loadSettings
public void loadSettings() throws java.io.IOExceptionLoad the settings with ID m_ID from store m_storeName.- Throws:
java.io.IOException- if a problem occurs
-
getID
public java.lang.String getID()
Get the ID used for these settings- Returns:
- the ID used
-
getStoreName
public java.lang.String getStoreName()
Get the store name for these settings- Returns:
- the store name
-
applyDefaults
public void applyDefaults(Defaults defaults)
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
public java.util.Map<Settings.SettingKey,java.lang.Object> getSettings(java.lang.String settingsID)
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
public java.util.Set<java.lang.String> getSettingsIDs()
Get a list of settings IDs- Returns:
- a list of the settings IDs managed by this settings instance
-
getSetting
public <T> T getSetting(java.lang.String ID, java.lang.String key, T defaultValue, Environment env)
-
getSetting
public <T> T getSetting(java.lang.String ID, Settings.SettingKey key, T defaultValue)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
public <T> T getSetting(java.lang.String ID, Settings.SettingKey key, T defaultValue, Environment env)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
public void setSetting(java.lang.String ID, Settings.SettingKey propName, java.lang.Object value)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
public boolean hasSettings(java.lang.String settingsID)
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
public boolean hasSetting(java.lang.String settingsID, java.lang.String propName)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
public void saveSettings() throws java.io.IOExceptionSave the settings to the metastore- Throws:
java.io.IOException- if a problem occurs
-
-