Class MemoryPreferences
- java.lang.Object
-
- org.openstreetmap.josm.spi.preferences.AbstractPreferences
-
- org.openstreetmap.josm.spi.preferences.MemoryPreferences
-
- All Implemented Interfaces:
IPreferences
public class MemoryPreferences extends AbstractPreferences
Preferences implementation that keeps all settings in memory. Holds saved preferences for the current session, but does not retain any data when the program terminates.- Since:
- 12906
-
-
Constructor Summary
Constructors Constructor Description MemoryPreferences()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addKeyPreferenceChangeListener(java.lang.String key, PreferenceChangedListener listener)
Adds a listener that only listens to changes in one preferencevoid
addPreferenceChangeListener(PreferenceChangedListener listener)
Adds a new preferences listener.java.util.Map<java.lang.String,Setting<?>>
getAllSettings()
Gets a map of all settings that are currently storedjava.util.Set<java.lang.String>
getKeySet()
Get the set of all keys that are mapped to a value in this preferences.<T extends Setting<?>>
TgetSetting(java.lang.String key, T def, java.lang.Class<T> klass)
Get settings value for a certain key and provide default a value.boolean
putSetting(java.lang.String key, Setting<?> setting)
Set a value for a certain setting.void
removeKeyPreferenceChangeListener(java.lang.String key, PreferenceChangedListener listener)
Removes a listener that only listens to changes in one preferencevoid
removePreferenceChangeListener(PreferenceChangedListener listener)
Removes a preferences listener.-
Methods inherited from class org.openstreetmap.josm.spi.preferences.AbstractPreferences
addSensitive, get, getAllPrefix, getAllPrefixCollectionKeys, getBoolean, getDouble, getInt, getList, getListOfLists, getListOfMaps, getLong, getSensitive, put, putBoolean, putDouble, putInt, putList, putListOfLists, putListOfMaps, putLong, removeSensitive
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.josm.spi.preferences.IPreferences
get, getBoolean, getList, getListOfLists, getListOfMaps
-
-
-
-
Constructor Detail
-
MemoryPreferences
public MemoryPreferences()
-
-
Method Detail
-
putSetting
public boolean putSetting(java.lang.String key, Setting<?> setting)
Description copied from class:AbstractPreferences
Set a value for a certain setting. The changed setting is saved to the preference file immediately. Due to caching mechanisms on modern operating systems and hardware, this shouldn't be a performance problem.- Specified by:
putSetting
in classAbstractPreferences
- Parameters:
key
- the unique identifier for the settingsetting
- the value of the setting. In case it is null, the key-value entry will be removed.- Returns:
true
, if something has changed (i.e. value is different than before)
-
getSetting
public <T extends Setting<?>> T getSetting(java.lang.String key, T def, java.lang.Class<T> klass)
Description copied from class:AbstractPreferences
Get settings value for a certain key and provide default a value.- Specified by:
getSetting
in classAbstractPreferences
- Type Parameters:
T
- the setting type- Parameters:
key
- the identifier for the settingdef
- the default value. For each call of getSetting() with a given key, the default value must be the same.def
must not be null, but the value ofdef
can be null.klass
- the setting type (same as T)- Returns:
- the corresponding value if the property has been set before,
def
otherwise
-
getKeySet
public java.util.Set<java.lang.String> getKeySet()
Description copied from interface:IPreferences
Get the set of all keys that are mapped to a value in this preferences.- Returns:
- the set of all keys
-
getAllSettings
public java.util.Map<java.lang.String,Setting<?>> getAllSettings()
Description copied from class:AbstractPreferences
Gets a map of all settings that are currently stored- Specified by:
getAllSettings
in classAbstractPreferences
- Returns:
- The settings
-
addPreferenceChangeListener
public void addPreferenceChangeListener(PreferenceChangedListener listener)
Description copied from interface:IPreferences
Adds a new preferences listener.- Parameters:
listener
- The listener to add
-
removePreferenceChangeListener
public void removePreferenceChangeListener(PreferenceChangedListener listener)
Description copied from interface:IPreferences
Removes a preferences listener.- Parameters:
listener
- The listener to remove
-
addKeyPreferenceChangeListener
public void addKeyPreferenceChangeListener(java.lang.String key, PreferenceChangedListener listener)
Description copied from interface:IPreferences
Adds a listener that only listens to changes in one preference- Parameters:
key
- The preference key to listen tolistener
- The listener to add.
-
removeKeyPreferenceChangeListener
public void removeKeyPreferenceChangeListener(java.lang.String key, PreferenceChangedListener listener)
Description copied from interface:IPreferences
Removes a listener that only listens to changes in one preference- Parameters:
key
- The preference key to listen tolistener
- The listener to add.
-
-