Class AbstractPreferences
java.lang.Object
org.openstreetmap.josm.spi.preferences.AbstractPreferences
- All Implemented Interfaces:
IPreferences
- Direct Known Subclasses:
MemoryPreferences,Preferences
Abstract implementation of the
IPreferences interface.- Since:
- 12847
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringThe preference key for sensitive keysA set of sensitive keys that should not be seen/distributed outside of specific callers (like aCredentialsAgent) -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSensitive(CredentialsAgent caller, String key) Add sensitive keysGet settings value for a certain key and provide a default value.getAllPrefix(String prefix) Gets all normal (string) settings that have a key starting with the prefixgetAllPrefixCollectionKeys(String prefix) Gets all list settings that have a key starting with the prefixGets a map of all settings that are currently storedbooleangetBoolean(String key, boolean def) Gets a boolean preferencedoubleGets a double preferenceintGets an integer preferenceGet a list of values for a certain keygetListOfLists(String key, List<List<String>> def) Get an array of values (list of lists) for a certain keyGets a list of key/value maps.longGets a long preferenceGet sensitive keysabstract <T extends Setting<?>>
TgetSetting(String key, T def, Class<T> klass) Get settings value for a certain key and provide default a value.private voidPopulate the sensitive key set from preferencesbooleanSet a value for a certain setting.booleanputBoolean(String key, boolean value) Set a boolean value for a certain setting.booleanSet a boolean value for a certain setting.booleanSet an integer value for a certain setting.booleanSet a list of values for a certain key.booleanputListOfLists(String key, List<List<String>> value) Set an array of values (list of lists) for a certain key.booleanSet an a list of key/value maps.booleanSet a long value for a certain setting.abstract booleanputSetting(String key, Setting<?> setting) Set a value for a certain setting.voidremoveSensitive(String key) Remove sensitive keys.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.openstreetmap.josm.spi.preferences.IPreferences
addKeyPreferenceChangeListener, addPreferenceChangeListener, get, getBoolean, getKeySet, getList, getListOfLists, getListOfMaps, removeKeyPreferenceChangeListener, removePreferenceChangeListener
-
Field Details
-
KEY_SENSITIVE_KEYS
The preference key for sensitive keys- See Also:
-
SENSITIVE_KEYS
A set of sensitive keys that should not be seen/distributed outside of specific callers (like aCredentialsAgent)
-
-
Constructor Details
-
AbstractPreferences
public AbstractPreferences()
-
-
Method Details
-
get
Description copied from interface:IPreferencesGet settings value for a certain key and provide a default value.- Specified by:
getin interfaceIPreferences- Parameters:
key- the identifier for the settingdef- the default value. For each call of get() with a given key, the default value must be the same.defmay be null.- Returns:
- the corresponding value if the property has been set before,
defotherwise
-
put
Description copied from interface:IPreferencesSet a value for a certain setting.- Specified by:
putin interfaceIPreferences- Parameters:
key- the unique identifier for the settingvalue- the value of the setting. Can be null or "" which both removes the key-value entry.- Returns:
true, if something has changed (i.e. value is different than before)
-
getBoolean
Description copied from interface:IPreferencesGets a boolean preference- Specified by:
getBooleanin interfaceIPreferences- Parameters:
key- The preference keydef- The default value to use- Returns:
- The boolean,
falseif it could not be parsed, the default value if it is unset
-
putBoolean
Description copied from interface:IPreferencesSet a boolean value for a certain setting.- Specified by:
putBooleanin interfaceIPreferences- Parameters:
key- the unique identifier for the settingvalue- The new value- Returns:
true, if something has changed (i.e. value is different than before)
-
getInt
Description copied from interface:IPreferencesGets an integer preference- Specified by:
getIntin interfaceIPreferences- Parameters:
key- The preference keydef- The default value to use- Returns:
- The integer
-
putInt
Description copied from interface:IPreferencesSet an integer value for a certain setting.- Specified by:
putIntin interfaceIPreferences- Parameters:
key- the unique identifier for the settingvalue- The new value- Returns:
true, if something has changed (i.e. value is different than before)
-
getLong
Description copied from interface:IPreferencesGets a long preference- Specified by:
getLongin interfaceIPreferences- Parameters:
key- The preference keydef- The default value to use- Returns:
- The long value or the default value if it could not be parsed
-
putLong
Description copied from interface:IPreferencesSet a long value for a certain setting.- Specified by:
putLongin interfaceIPreferences- Parameters:
key- the unique identifier for the settingvalue- The new value- Returns:
true, if something has changed (i.e. value is different than before)
-
getDouble
Description copied from interface:IPreferencesGets a double preference- Specified by:
getDoublein interfaceIPreferences- Parameters:
key- The preference keydef- The default value to use- Returns:
- The double value or the default value if it could not be parsed
-
putDouble
Description copied from interface:IPreferencesSet a boolean value for a certain setting.- Specified by:
putDoublein interfaceIPreferences- Parameters:
key- the unique identifier for the settingvalue- The new value- Returns:
true, if something has changed (i.e. value is different than before)
-
getList
Description copied from interface:IPreferencesGet a list of values for a certain key- Specified by:
getListin interfaceIPreferences- Parameters:
key- the identifier for the settingdef- the default value.- Returns:
- the corresponding value if the property has been set before,
defotherwise
-
putList
Description copied from interface:IPreferencesSet a list of values for a certain key.- Specified by:
putListin interfaceIPreferences- Parameters:
key- the identifier for the settingvalue- The new value- Returns:
true, if something has changed (i.e. value is different than before)
-
getListOfLists
Description copied from interface:IPreferencesGet an array of values (list of lists) for a certain key- Specified by:
getListOfListsin interfaceIPreferences- Parameters:
key- the identifier for the settingdef- the default value.- Returns:
- the corresponding value if the property has been set before,
defotherwise
-
putListOfLists
Description copied from interface:IPreferencesSet an array of values (list of lists) for a certain key.- Specified by:
putListOfListsin interfaceIPreferences- Parameters:
key- the identifier for the settingvalue- the new value- Returns:
true, if something has changed (i.e. value is different than before)
-
getListOfMaps
Description copied from interface:IPreferencesGets a list of key/value maps.- Specified by:
getListOfMapsin interfaceIPreferences- Parameters:
key- the key to search atdef- the default value to use- Returns:
- the corresponding value if the property has been set before,
defotherwise
-
putListOfMaps
Description copied from interface:IPreferencesSet an a list of key/value maps.- Specified by:
putListOfMapsin interfaceIPreferences- Parameters:
key- the key to store the list invalue- a list of key/value maps- Returns:
trueif the value was changed
-
getAllSettings
Gets a map of all settings that are currently stored- Returns:
- The settings
-
putSetting
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.- 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
Get settings value for a certain key and provide default a value.- 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
-
getAllPrefix
Gets all normal (string) settings that have a key starting with the prefix- Parameters:
prefix- The start of the key- Returns:
- The key names of the settings
-
getAllPrefixCollectionKeys
Gets all list settings that have a key starting with the prefix- Parameters:
prefix- The start of the key- Returns:
- The key names of the list settings
-
addSensitive
Description copied from interface:IPreferencesAdd sensitive keys- Specified by:
addSensitivein interfaceIPreferences- Parameters:
caller- The calling agentkey- The key that may contain sensitive information
-
getSensitive
Description copied from interface:IPreferencesGet sensitive keys- Specified by:
getSensitivein interfaceIPreferences- Returns:
- The sensitive keys
-
removeSensitive
Description copied from interface:IPreferencesRemove sensitive keys. This removes the key from the sensitive list and removes the stored preference value.- Specified by:
removeSensitivein interfaceIPreferences- Parameters:
key- The key to remove
-
populateSensitiveKeys
Populate the sensitive key set from preferences
-