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 voidaddKeyPreferenceChangeListener(java.lang.String key, PreferenceChangedListener listener)Adds a listener that only listens to changes in one preferencevoidaddPreferenceChangeListener(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.booleanputSetting(java.lang.String key, Setting<?> setting)Set a value for a certain setting.voidremoveKeyPreferenceChangeListener(java.lang.String key, PreferenceChangedListener listener)Removes a listener that only listens to changes in one preferencevoidremovePreferenceChangeListener(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:AbstractPreferencesSet 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:
putSettingin 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:AbstractPreferencesGet settings value for a certain key and provide default a value.- Specified by:
getSettingin 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.defmust not be null, but the value ofdefcan be null.klass- the setting type (same as T)- Returns:
- the corresponding value if the property has been set before,
defotherwise
-
getKeySet
public java.util.Set<java.lang.String> getKeySet()
Description copied from interface:IPreferencesGet 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:AbstractPreferencesGets a map of all settings that are currently stored- Specified by:
getAllSettingsin classAbstractPreferences- Returns:
- The settings
-
addPreferenceChangeListener
public void addPreferenceChangeListener(PreferenceChangedListener listener)
Description copied from interface:IPreferencesAdds a new preferences listener.- Parameters:
listener- The listener to add
-
removePreferenceChangeListener
public void removePreferenceChangeListener(PreferenceChangedListener listener)
Description copied from interface:IPreferencesRemoves a preferences listener.- Parameters:
listener- The listener to remove
-
addKeyPreferenceChangeListener
public void addKeyPreferenceChangeListener(java.lang.String key, PreferenceChangedListener listener)
Description copied from interface:IPreferencesAdds 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:IPreferencesRemoves a listener that only listens to changes in one preference- Parameters:
key- The preference key to listen tolistener- The listener to add.
-
-