com.alee.managers.settings
Class SettingsManager

java.lang.Object
  extended by com.alee.managers.settings.SettingsManager

public final class SettingsManager
extends java.lang.Object

This manager allows you to quickly and easily save any serializable data into settings files using simple XML format.

You can define settings group file name (they are equal to the SettingsGroup name and should be unique), its location on local or remote drive and each separate property key. Any amount of properties could be stored in each group. Also there are some additional manager settings that allows you to configure SettingsManager to work the way you want it to. The rest of the work is done by the SettingsManager - it decides where, when and how to save the settings files.

Settings data aliasing (see XStream documentation and XmlUtils class) or SettingsGroup file location changes should be done before requesting any of the settings, preferably right at the application startup. Otherwise data might not be properly read and settings will appear empty.

Author:
Mikle Garin
See Also:
How to use SettingsManager, ComponentSettingsManager, XmlUtils

Constructor Summary
SettingsManager()
           
 
Method Summary
static void addSettingsListener(java.lang.String key, SettingsListener listener)
          Adds setting listener.
static void addSettingsListener(java.lang.String group, java.lang.String key, SettingsListener listener)
          Adds setting listener.
static void disableSave()
          Disables saving settings into files.
static void enableSave()
          Enables saving settings into files.
static
<T> T
get(java.lang.String key)
          Returns Object value.
static
<T extends DefaultValue>
T
get(java.lang.String key, java.lang.Class<T> defaultValueClass)
          Returns typed value.
static
<T extends DefaultValue>
T
get(java.lang.String group, java.lang.String key, java.lang.Class<T> defaultValueClass)
          Returns typed value.
static
<T> T
get(java.lang.String group, java.lang.String key, T defaultValue)
          Returns typed value.
static
<T> T
get(java.lang.String key, T defaultValue)
          Returns typed value.
static java.lang.String getBackupFilesExtension()
          Returns backup files extension.
static java.lang.Boolean getBoolean(java.lang.String key)
          Returns Boolean value.
static java.lang.Boolean getBoolean(java.lang.String group, java.lang.String key)
          Returns Boolean value.
static java.awt.Color getColor(java.lang.String key)
          Returns Color value.
static java.awt.Color getColor(java.lang.String group, java.lang.String key)
          Returns Color value.
static java.lang.String getDefaultSettingsDir()
          Returns default settings directory.
static java.lang.String getDefaultSettingsDirName()
          Returns default settings directory name.
static java.lang.String getDefaultSettingsGroup()
          Returns default settings group name.
static
<T extends DefaultValue>
T
getDefaultValue(java.lang.Class<T> defaultValueClass)
          Returns default value for the specified class.
static java.awt.Dimension getDimension(java.lang.String key)
          Returns Dimension value.
static java.awt.Dimension getDimension(java.lang.String group, java.lang.String key)
          Returns Dimension value.
static java.lang.Double getDouble(java.lang.String key)
          Returns Double value.
static java.lang.Double getDouble(java.lang.String group, java.lang.String key)
          Returns Double value.
static java.lang.Float getFloat(java.lang.String key)
          Returns Float value.
static java.lang.Float getFloat(java.lang.String group, java.lang.String key)
          Returns Float value.
static java.lang.String getGroupFileLocation(java.lang.String group)
          Returns directory where settings group file is saved.
static java.awt.Insets getInsets(java.lang.String key)
          Returns Insets value.
static java.awt.Insets getInsets(java.lang.String group, java.lang.String key)
          Returns Insets value.
static java.lang.Integer getInteger(java.lang.String key)
          Returns Integer value.
static java.lang.Integer getInteger(java.lang.String group, java.lang.String key)
          Returns Integer value.
static java.util.List<SettingsGroup> getLoadedGroups()
          Returns list of all loaded settings groups.
static java.util.Map<java.lang.String,SettingsGroup> getLoadedGroupsMap()
          Returns map of all loaded settings groups.
static java.lang.Long getLong(java.lang.String key)
          Returns Long value.
static java.lang.Long getLong(java.lang.String group, java.lang.String key)
          Returns Long value.
static java.awt.Point getPoint(java.lang.String key)
          Returns Point value.
static java.awt.Point getPoint(java.lang.String group, java.lang.String key)
          Returns Point value.
static java.awt.Rectangle getRectangle(java.lang.String key)
          Returns Rectangle value.
static java.awt.Rectangle getRectangle(java.lang.String group, java.lang.String key)
          Returns Rectangle value.
static long getSaveOnChangeDelay()
          Returns save-on-change delay in milliseconds.
static java.lang.Object getSettings(java.lang.String fileName)
          Returns value read from the settings file.
static
<T> T
getSettings(java.lang.String fileName, T defaultValue)
          Returns value read from the settings file.
static java.lang.String getSettingsFilesExtension()
          Returns settings files extension.
static SettingsGroup getSettingsGroup(java.lang.String group)
          Returns settings group for the specified name.
 SettingsGroupState getSettingsGroupState(java.lang.String group)
          Returns settings group state.
static java.lang.String getString(java.lang.String key)
          Returns String value.
static java.lang.String getString(java.lang.String group, java.lang.String key)
          Returns String value.
static void initialize()
          Initializes SettingsManager.
static boolean isAllowSave()
          Returns whether should allow saving settings into files or not.
static boolean isDisplayExceptions()
          Returns whether should display settings load and save error messages or not.
static boolean isSaveDefaultValues()
          Sets whether should save provided default value in "get" calls or not.
static boolean isSaveOnChange()
          Returns whether should save settings right after any changes made or not.
static void loadComponentSettings(java.awt.Component component)
          Loads saved settings into the component if it is registered.
static void registerComponent(java.awt.Component component, SettingsProcessor settingsProcessor)
          Registers component for settings auto-save.
static void registerComponent(java.awt.Component component, java.lang.String key)
          Registers component for settings auto-save.
static void registerComponent(java.awt.Component component, java.lang.String key, boolean loadInitialSettings, boolean applySettingsChanges)
          Registers component for settings auto-save.
static
<T extends DefaultValue>
void
registerComponent(java.awt.Component component, java.lang.String key, java.lang.Class<T> defaultValueClass)
          Registers component for settings auto-save.
static
<T extends DefaultValue>
void
registerComponent(java.awt.Component component, java.lang.String key, java.lang.Class<T> defaultValueClass, boolean loadInitialSettings, boolean applySettingsChanges)
          Registers component for settings auto-save.
static void registerComponent(java.awt.Component component, java.lang.String key, java.lang.Object defaultValue)
          Registers component for settings auto-save.
static void registerComponent(java.awt.Component component, java.lang.String key, java.lang.Object defaultValue, boolean loadInitialSettings, boolean applySettingsChanges)
          Registers component for settings auto-save.
static void registerComponent(java.awt.Component component, java.lang.String group, java.lang.String key)
          Registers component for settings auto-save.
static
<T extends DefaultValue>
void
registerComponent(java.awt.Component component, java.lang.String group, java.lang.String key, java.lang.Class<T> defaultValueClass)
          Registers component for settings auto-save.
static
<T extends DefaultValue>
void
registerComponent(java.awt.Component component, java.lang.String group, java.lang.String key, java.lang.Class<T> defaultValueClass, boolean loadInitialSettings, boolean applySettingsChanges)
          Registers component for settings auto-save.
static void registerComponent(java.awt.Component component, java.lang.String group, java.lang.String key, java.lang.Object defaultValue)
          Registers component for settings auto-save.
static void registerComponent(java.awt.Component component, java.lang.String group, java.lang.String key, java.lang.Object defaultValue, boolean loadInitialSettings, boolean applySettingsChanges)
          Registers component for settings auto-save.
static
<T extends SettingsProcessor>
void
registerSettingsProcessor(java.lang.Class componentType, java.lang.Class<T> settingsProcessor)
          Registers specified settings processor class for the specified component type.
static void removeSettingsListener(java.lang.String key, SettingsListener listener)
          Removes settings listener.
static void removeSettingsListener(java.lang.String group, java.lang.String key, SettingsListener listener)
          Removes settings listener.
static void saveComponentSettings(java.awt.Component component)
          Saves component settings.
static void saveSettings()
          Saves all settings groups and files.
static void saveSettingsGroup(SettingsGroup settingsGroup)
          Saves specified settings group.
static void saveSettingsGroup(java.lang.String group)
          Saves settings group with the specified name.
static
<T> T
set(java.lang.String group, java.lang.String key, T object)
          Sets value for the specified settings group and key.
static
<T> T
set(java.lang.String key, T object)
          Sets value for the specified settings key.
static void setAllowSave(boolean allowSave)
          Sets whether should allow saving settings into files or not.
static void setBackupFilesExtension(java.lang.String backupFilesExtension)
          Sets backup files extension
static void setDefaultSettingsDir(java.lang.String defaultSettingsDir)
          Sets default settings directory.
static void setDefaultSettingsDirName(java.lang.String defaultSettingsDir)
          Sets default settings directory name.
static void setDefaultSettingsGroup(java.lang.String defaultSettingsGroup)
          Sets default settings group name.
static void setDisplayExceptions(boolean displayExceptions)
          Sets whether should display settings load and save error messages or not.
static void setGroupFileLocation(java.lang.String group, java.lang.String dir)
          Sets custom directory where settings group file will be saved.
static void setSaveDefaultValues(boolean saveDefaultValues)
          Sets whether should save provided default value in "get" calls or not.
static void setSaveOnChange(boolean saveOnChange)
          Sets whether should save settings right after any changes made or not.
static void setSaveOnChangeDelay(long saveOnChangeDelay)
          Sets save-on-change delay in milliseconds.
static void setSettings(java.lang.String fileName, java.lang.Object settings)
          Sets and saves value into settings file with the specified name.
static void setSettingsFilesExtension(java.lang.String settingsFilesExtension)
          Sets settings files extension
static boolean settingsExists(java.lang.String fileName)
          Returns whether settings file with the specified name exists or not.
static void unregisterComponent(java.awt.Component component)
          Unregisters component from settings auto-save.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SettingsManager

public SettingsManager()
Method Detail

initialize

public static void initialize()
Initializes SettingsManager.


getLoadedGroups

public static java.util.List<SettingsGroup> getLoadedGroups()
Returns list of all loaded settings groups.

Returns:
list of all loaded settings groups

getLoadedGroupsMap

public static java.util.Map<java.lang.String,SettingsGroup> getLoadedGroupsMap()
Returns map of all loaded settings groups.

Returns:
map of all loaded settings groups

registerComponent

public static void registerComponent(java.awt.Component component,
                                     java.lang.String key)
Registers component for settings auto-save.

Also registered component will be: - listened for settings changes to save them when requested - automatically updated with any loaded settings for that key if requested - automatically updated with any changes made in its settings if requested

Parameters:
component - component to register
key - component settings key

registerComponent

public static <T extends DefaultValue> void registerComponent(java.awt.Component component,
                                                              java.lang.String key,
                                                              java.lang.Class<T> defaultValueClass)
Registers component for settings auto-save.

Also registered component will be: - listened for settings changes to save them when requested - automatically updated with any loaded settings for that key if requested - automatically updated with any changes made in its settings if requested

Type Parameters:
T - default value type
Parameters:
component - component to register
key - component settings key
defaultValueClass - component default value class
See Also:
DefaultValue

registerComponent

public static void registerComponent(java.awt.Component component,
                                     java.lang.String key,
                                     java.lang.Object defaultValue)
Registers component for settings auto-save.

Also registered component will be: - listened for settings changes to save them when requested - automatically updated with any loaded settings for that key if requested - automatically updated with any changes made in its settings if requested

Parameters:
component - component to register
key - component settings key
defaultValue - component default value

registerComponent

public static void registerComponent(java.awt.Component component,
                                     java.lang.String group,
                                     java.lang.String key)
Registers component for settings auto-save.

Also registered component will be: - listened for settings changes to save them when requested - automatically updated with any loaded settings for that key if requested - automatically updated with any changes made in its settings if requested

Parameters:
component - component to register
group - component settings group
key - component settings key

registerComponent

public static <T extends DefaultValue> void registerComponent(java.awt.Component component,
                                                              java.lang.String group,
                                                              java.lang.String key,
                                                              java.lang.Class<T> defaultValueClass)
Registers component for settings auto-save.

Also registered component will be: - listened for settings changes to save them when requested - automatically updated with any loaded settings for that key if requested - automatically updated with any changes made in its settings if requested

Type Parameters:
T - default value type
Parameters:
component - component to register
group - component settings group
key - component settings key
defaultValueClass - component default value class
See Also:
DefaultValue

registerComponent

public static void registerComponent(java.awt.Component component,
                                     java.lang.String group,
                                     java.lang.String key,
                                     java.lang.Object defaultValue)
Registers component for settings auto-save.

Also registered component will be: - listened for settings changes to save them when requested - automatically updated with any loaded settings for that key if requested - automatically updated with any changes made in its settings if requested

Parameters:
component - component to register
group - component settings group
key - component settings key
defaultValue - component default value

registerComponent

public static void registerComponent(java.awt.Component component,
                                     java.lang.String key,
                                     boolean loadInitialSettings,
                                     boolean applySettingsChanges)
Registers component for settings auto-save.

Also registered component will be: - listened for settings changes to save them when requested - automatically updated with any loaded settings for that key if requested - automatically updated with any changes made in its settings if requested

Parameters:
component - component to register
key - component settings key
loadInitialSettings - whether to load initial available settings into the component or not
applySettingsChanges - whether to apply settings changes to the component or not

registerComponent

public static <T extends DefaultValue> void registerComponent(java.awt.Component component,
                                                              java.lang.String key,
                                                              java.lang.Class<T> defaultValueClass,
                                                              boolean loadInitialSettings,
                                                              boolean applySettingsChanges)
Registers component for settings auto-save.

Also registered component will be: - listened for settings changes to save them when requested - automatically updated with any loaded settings for that key if requested - automatically updated with any changes made in its settings if requested

Type Parameters:
T - default value type
Parameters:
component - component to register
key - component settings key
defaultValueClass - component default value class
loadInitialSettings - whether to load initial available settings into the component or not
applySettingsChanges - whether to apply settings changes to the component or not
See Also:
DefaultValue

registerComponent

public static void registerComponent(java.awt.Component component,
                                     java.lang.String key,
                                     java.lang.Object defaultValue,
                                     boolean loadInitialSettings,
                                     boolean applySettingsChanges)
Registers component for settings auto-save.

Also registered component will be: - listened for settings changes to save them when requested - automatically updated with any loaded settings for that key if requested - automatically updated with any changes made in its settings if requested

Parameters:
component - component to register
key - component settings key
defaultValue - component default value
loadInitialSettings - whether to load initial available settings into the component or not
applySettingsChanges - whether to apply settings changes to the component or not

registerComponent

public static <T extends DefaultValue> void registerComponent(java.awt.Component component,
                                                              java.lang.String group,
                                                              java.lang.String key,
                                                              java.lang.Class<T> defaultValueClass,
                                                              boolean loadInitialSettings,
                                                              boolean applySettingsChanges)
Registers component for settings auto-save.

Also registered component will be: - listened for settings changes to save them when requested - automatically updated with any loaded settings for that key if requested - automatically updated with any changes made in its settings if requested

Type Parameters:
T - default value type
Parameters:
component - component to register
group - component settings group
key - component settings key
defaultValueClass - component default value class
loadInitialSettings - whether to load initial available settings into the component or not
applySettingsChanges - whether to apply settings changes to the component or not
See Also:
DefaultValue

registerComponent

public static void registerComponent(java.awt.Component component,
                                     java.lang.String group,
                                     java.lang.String key,
                                     java.lang.Object defaultValue,
                                     boolean loadInitialSettings,
                                     boolean applySettingsChanges)
Registers component for settings auto-save.

Also registered component will be: - listened for settings changes to save them when requested - automatically updated with any loaded settings for that key if requested - automatically updated with any changes made in its settings if requested

Parameters:
component - component to register
group - component settings group
key - component settings key
defaultValue - component default value
loadInitialSettings - whether to load initial available settings into the component or not
applySettingsChanges - whether to apply settings changes to the component or not

registerComponent

public static void registerComponent(java.awt.Component component,
                                     SettingsProcessor settingsProcessor)
Registers component for settings auto-save.

Also registered component will be: - listened for settings changes to save them when requested - automatically updated with any loaded settings for that key if requested - automatically updated with any changes made in its settings if requested

Parameters:
component - component to register
settingsProcessor - component settings processor

unregisterComponent

public static void unregisterComponent(java.awt.Component component)
Unregisters component from settings auto-save.

Parameters:
component - component to unregister

loadComponentSettings

public static void loadComponentSettings(java.awt.Component component)
Loads saved settings into the component if it is registered.

Parameters:
component - component registered for settings auto-save

saveComponentSettings

public static void saveComponentSettings(java.awt.Component component)
Saves component settings.

Parameters:
component - component registered for settings auto-save

registerSettingsProcessor

public static <T extends SettingsProcessor> void registerSettingsProcessor(java.lang.Class componentType,
                                                                           java.lang.Class<T> settingsProcessor)
Registers specified settings processor class for the specified component type.

Type Parameters:
T - settings processor type
Parameters:
componentType - component type
settingsProcessor - settings processor class

getBoolean

public static java.lang.Boolean getBoolean(java.lang.String key)
Returns Boolean value.

Parameters:
key - settings key
Returns:
Boolean value

getBoolean

public static java.lang.Boolean getBoolean(java.lang.String group,
                                           java.lang.String key)
Returns Boolean value.

Parameters:
group - settings group
key - settings key
Returns:
Boolean value

getString

public static java.lang.String getString(java.lang.String key)
Returns String value.

Parameters:
key - settings key
Returns:
String value

getString

public static java.lang.String getString(java.lang.String group,
                                         java.lang.String key)
Returns String value.

Parameters:
group - settings group
key - settings key
Returns:
String value

getInteger

public static java.lang.Integer getInteger(java.lang.String key)
Returns Integer value.

Parameters:
key - settings key
Returns:
Integer value

getInteger

public static java.lang.Integer getInteger(java.lang.String group,
                                           java.lang.String key)
Returns Integer value.

Parameters:
group - settings group
key - settings key
Returns:
Integer value

getLong

public static java.lang.Long getLong(java.lang.String key)
Returns Long value.

Parameters:
key - settings key
Returns:
Long value

getLong

public static java.lang.Long getLong(java.lang.String group,
                                     java.lang.String key)
Returns Long value.

Parameters:
group - settings group
key - settings key
Returns:
Long value

getFloat

public static java.lang.Float getFloat(java.lang.String key)
Returns Float value.

Parameters:
key - settings key
Returns:
Float value

getFloat

public static java.lang.Float getFloat(java.lang.String group,
                                       java.lang.String key)
Returns Float value.

Parameters:
group - settings group
key - settings key
Returns:
Float value

getDouble

public static java.lang.Double getDouble(java.lang.String key)
Returns Double value.

Parameters:
key - settings key
Returns:
Double value

getDouble

public static java.lang.Double getDouble(java.lang.String group,
                                         java.lang.String key)
Returns Double value.

Parameters:
group - settings group
key - settings key
Returns:
Double value

getDimension

public static java.awt.Dimension getDimension(java.lang.String key)
Returns Dimension value.

Parameters:
key - settings key
Returns:
Dimension value

getDimension

public static java.awt.Dimension getDimension(java.lang.String group,
                                              java.lang.String key)
Returns Dimension value.

Parameters:
group - settings group
key - settings key
Returns:
Dimension value

getPoint

public static java.awt.Point getPoint(java.lang.String key)
Returns Point value.

Parameters:
key - settings key
Returns:
Point value

getPoint

public static java.awt.Point getPoint(java.lang.String group,
                                      java.lang.String key)
Returns Point value.

Parameters:
group - settings group
key - settings key
Returns:
Point value

getColor

public static java.awt.Color getColor(java.lang.String key)
Returns Color value.

Parameters:
key - settings key
Returns:
Color value

getColor

public static java.awt.Color getColor(java.lang.String group,
                                      java.lang.String key)
Returns Color value.

Parameters:
group - settings group
key - settings key
Returns:
Color value

getRectangle

public static java.awt.Rectangle getRectangle(java.lang.String key)
Returns Rectangle value.

Parameters:
key - settings key
Returns:
Rectangle value

getRectangle

public static java.awt.Rectangle getRectangle(java.lang.String group,
                                              java.lang.String key)
Returns Rectangle value.

Parameters:
group - settings group
key - settings key
Returns:
Rectangle value

getInsets

public static java.awt.Insets getInsets(java.lang.String key)
Returns Insets value.

Parameters:
key - settings key
Returns:
Insets value

getInsets

public static java.awt.Insets getInsets(java.lang.String group,
                                        java.lang.String key)
Returns Insets value.

Parameters:
group - settings group
key - settings key
Returns:
Insets value

get

public static <T> T get(java.lang.String key)
Returns Object value.

Parameters:
key - settings key
Returns:
Object value

get

public static <T extends DefaultValue> T get(java.lang.String key,
                                             java.lang.Class<T> defaultValueClass)
Returns typed value.

Type Parameters:
T - default value type
Parameters:
key - settings key
defaultValueClass - default value class
Returns:
typed value

get

public static <T> T get(java.lang.String key,
                        T defaultValue)
Returns typed value.

Type Parameters:
T - default value type
Parameters:
key - settings key
defaultValue - default value
Returns:
typed value

get

public static <T extends DefaultValue> T get(java.lang.String group,
                                             java.lang.String key,
                                             java.lang.Class<T> defaultValueClass)
Returns typed value.

Type Parameters:
T - default value type
Parameters:
group - settings group
key - settings key
defaultValueClass - default value class
Returns:
typed value

get

public static <T> T get(java.lang.String group,
                        java.lang.String key,
                        T defaultValue)
Returns typed value.

Type Parameters:
T - default value type
Parameters:
group - settings group
key - settings key
defaultValue - default value
Returns:
typed value

getDefaultValue

public static <T extends DefaultValue> T getDefaultValue(java.lang.Class<T> defaultValueClass)
Returns default value for the specified class.

Type Parameters:
T - default value type
Parameters:
defaultValueClass - default value class
Returns:
default value for the specified class

set

public static <T> T set(java.lang.String key,
                        T object)
Sets value for the specified settings key.

Type Parameters:
T - new value type
Parameters:
key - settings key
object - new value
Returns:
old value for the specified settings key

set

public static <T> T set(java.lang.String group,
                        java.lang.String key,
                        T object)
Sets value for the specified settings group and key.

Type Parameters:
T - new value type
Parameters:
group - settings group
key - settings key
object - new value
Returns:
old value for the specified settings key

getSettingsGroup

public static SettingsGroup getSettingsGroup(java.lang.String group)
Returns settings group for the specified name.

Parameters:
group - settings group name
Returns:
settings group for the specified name

saveSettings

public static void saveSettings()
Saves all settings groups and files.


saveSettingsGroup

public static void saveSettingsGroup(java.lang.String group)
Saves settings group with the specified name.

Parameters:
group - name of the settings group to save

saveSettingsGroup

public static void saveSettingsGroup(SettingsGroup settingsGroup)
Saves specified settings group.

Parameters:
settingsGroup - settings group to save

getSettingsGroupState

public SettingsGroupState getSettingsGroupState(java.lang.String group)
Returns settings group state.

Parameters:
group - settings group name
Returns:
settings group state

getSettings

public static java.lang.Object getSettings(java.lang.String fileName)
Returns value read from the settings file.

Parameters:
fileName - settings file name
Returns:
value read from the settings file

getSettings

public static <T> T getSettings(java.lang.String fileName,
                                T defaultValue)
Returns value read from the settings file.

Type Parameters:
T - default value type
Parameters:
fileName - settings file name
defaultValue - default value class
Returns:
value read from the settings file

setSettings

public static void setSettings(java.lang.String fileName,
                               java.lang.Object settings)
Sets and saves value into settings file with the specified name.

Parameters:
fileName - settings file name
settings - value

settingsExists

public static boolean settingsExists(java.lang.String fileName)
Returns whether settings file with the specified name exists or not.

Parameters:
fileName - settings file name
Returns:
true if settings file with the specified name exists, false otherwise

getSettingsFilesExtension

public static java.lang.String getSettingsFilesExtension()
Returns settings files extension.

Returns:
settings files extension

setSettingsFilesExtension

public static void setSettingsFilesExtension(java.lang.String settingsFilesExtension)
Sets settings files extension

Parameters:
settingsFilesExtension - new settings files extension

getBackupFilesExtension

public static java.lang.String getBackupFilesExtension()
Returns backup files extension.

Returns:
backup files extension

setBackupFilesExtension

public static void setBackupFilesExtension(java.lang.String backupFilesExtension)
Sets backup files extension

Parameters:
backupFilesExtension - new backup files extension

getDefaultSettingsDir

public static java.lang.String getDefaultSettingsDir()
Returns default settings directory.

Returns:
default settings directory

setDefaultSettingsDir

public static void setDefaultSettingsDir(java.lang.String defaultSettingsDir)
Sets default settings directory.

Parameters:
defaultSettingsDir - new default settings directory

getDefaultSettingsDirName

public static java.lang.String getDefaultSettingsDirName()
Returns default settings directory name.

Returns:
default settings directory name

setDefaultSettingsDirName

public static void setDefaultSettingsDirName(java.lang.String defaultSettingsDir)
Sets default settings directory name.

Parameters:
defaultSettingsDir - new default settings directory name

getDefaultSettingsGroup

public static java.lang.String getDefaultSettingsGroup()
Returns default settings group name.

Returns:
default settings group name

setDefaultSettingsGroup

public static void setDefaultSettingsGroup(java.lang.String defaultSettingsGroup)
Sets default settings group name.

Parameters:
defaultSettingsGroup - new default settings group name

setGroupFileLocation

public static void setGroupFileLocation(java.lang.String group,
                                        java.lang.String dir)
Sets custom directory where settings group file will be saved. Location that was used for this group before will be simply ignored.

Parameters:
group - settings group name
dir - settings group file directory

getGroupFileLocation

public static java.lang.String getGroupFileLocation(java.lang.String group)
Returns directory where settings group file is saved.

Parameters:
group - settings group name
Returns:
directory where settings group file is saved

isSaveOnChange

public static boolean isSaveOnChange()
Returns whether should save settings right after any changes made or not.

Returns:
true if should save settings right after any changes made, false otherwise

setSaveOnChange

public static void setSaveOnChange(boolean saveOnChange)
Sets whether should save settings right after any changes made or not.

Parameters:
saveOnChange - whether should save settings right after any changes made or not

isSaveDefaultValues

public static boolean isSaveDefaultValues()
Sets whether should save provided default value in "get" calls or not.

Returns:
true if should save provided default value in "get" calls, false otherwise

setSaveDefaultValues

public static void setSaveDefaultValues(boolean saveDefaultValues)
Sets whether should save provided default value in "get" calls or not.

Parameters:
saveDefaultValues - whether should save provided default value in "get" calls or not

getSaveOnChangeDelay

public static long getSaveOnChangeDelay()
Returns save-on-change delay in milliseconds.

Returns:
save-on-change delay in milliseconds.

setSaveOnChangeDelay

public static void setSaveOnChangeDelay(long saveOnChangeDelay)
Sets save-on-change delay in milliseconds. If larger than 0 then settings will be accumulated and saved all at once as soon as no new changes came within the delay time.

Parameters:
saveOnChangeDelay - new save-on-change delay in milliseconds

isDisplayExceptions

public static boolean isDisplayExceptions()
Returns whether should display settings load and save error messages or not.

Returns:
true if should display settings load and save error messages, false otherwise

setDisplayExceptions

public static void setDisplayExceptions(boolean displayExceptions)
Sets whether should display settings load and save error messages or not.

Parameters:
displayExceptions - whether should display settings load and save error messages or not

isAllowSave

public static boolean isAllowSave()
Returns whether should allow saving settings into files or not.

Returns:
true if should allow saving settings into files, false otherwise

setAllowSave

public static void setAllowSave(boolean allowSave)
Sets whether should allow saving settings into files or not.

Parameters:
allowSave - whether should allow saving settings into files or not

disableSave

public static void disableSave()
Disables saving settings into files.


enableSave

public static void enableSave()
Enables saving settings into files.


addSettingsListener

public static void addSettingsListener(java.lang.String key,
                                       SettingsListener listener)
Adds setting listener.

Parameters:
key - settings key to listen to
listener - settings listener to add

addSettingsListener

public static void addSettingsListener(java.lang.String group,
                                       java.lang.String key,
                                       SettingsListener listener)
Adds setting listener.

Parameters:
group - settings group to listen to
key - settings key to listen to
listener - settings listener to add

removeSettingsListener

public static void removeSettingsListener(java.lang.String key,
                                          SettingsListener listener)
Removes settings listener.

Parameters:
key - listened settings key
listener - settings listener to remove

removeSettingsListener

public static void removeSettingsListener(java.lang.String group,
                                          java.lang.String key,
                                          SettingsListener listener)
Removes settings listener.

Parameters:
group - listened settings group
key - listened settings key
listener - settings listener to remove