Package weka.core

Class Settings

java.lang.Object
weka.core.Settings
All Implemented Interfaces:
Serializable

public class Settings extends Object implements 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:
  • Constructor Details

    • Settings

      public Settings(String storeName, String ID)
      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 metastore
      ID - the ID/name to use
  • Method Details

    • loadSettings

      public void loadSettings() throws IOException
      Load the settings with ID m_ID from store m_storeName.
      Throws:
      IOException - if a problem occurs
    • getID

      public String getID()
      Get the ID used for these settings
      Returns:
      the ID used
    • getStoreName

      public 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 Map<Settings.SettingKey,Object> getSettings(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 Set<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(String ID, String key, T defaultValue, Environment env)
    • getSetting

      public <T> T getSetting(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 lookup
      defaultValue - 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(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 lookup
      defaultValue - the default value to use if the setting is not known
      env - 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(String ID, Settings.SettingKey propName, 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 store
      value - the value of the setting to store
    • hasSettings

      public boolean hasSettings(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(String settingsID, String propName)
      Returns true if a given setting has a value
      Parameters:
      settingsID - the ID of the settings group
      propName - the actual setting to check for
      Returns:
      true if the setting has a value
    • saveSettings

      public void saveSettings() throws IOException
      Save the settings to the metastore
      Throws:
      IOException - if a problem occurs