Interface IPreferences
- All Known Implementing Classes:
AbstractPreferences,MemoryPreferences,Preferences
public interface IPreferences
Interface for preference handling.
Allows to save and retrieve user defined settings. The backend storage depends
on the implementation.
- Since:
- 12847
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddKeyPreferenceChangeListener(String key, PreferenceChangedListener listener) Adds a listener that only listens to changes in one preferencevoidAdds a new preferences listener.voidaddSensitive(CredentialsAgent caller, String key) Add sensitive keysdefault StringGet settings value for a certain key.Get settings value for a certain key and provide a default value.default booleangetBoolean(String key) Gets a boolean preferencebooleangetBoolean(String key, boolean def) Gets a boolean preferencedoubleGets a double preferenceintGets an integer preferenceGet the set of all keys that are mapped to a value in this preferences.Get a list of values for a certain keyGet a list of values for a certain keygetListOfLists(String key) Get an array of values (list of lists) for a certain keygetListOfLists(String key, List<List<String>> def) Get an array of values (list of lists) for a certain keygetListOfMaps(String key) Gets a list of key/value maps.Gets a list of key/value maps.longGets a long preferenceGet sensitive keysbooleanSet 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.voidremoveKeyPreferenceChangeListener(String key, PreferenceChangedListener listener) Removes a listener that only listens to changes in one preferencevoidRemoves a preferences listener.voidremoveSensitive(String key) Remove sensitive keys.
-
Method Details
-
addPreferenceChangeListener
Adds a new preferences listener.- Parameters:
listener- The listener to add
-
removePreferenceChangeListener
Removes a preferences listener.- Parameters:
listener- The listener to remove
-
addKeyPreferenceChangeListener
Adds a listener that only listens to changes in one preference- Parameters:
key- The preference key to listen tolistener- The listener to add.
-
removeKeyPreferenceChangeListener
Removes a listener that only listens to changes in one preference- Parameters:
key- The preference key to listen tolistener- The listener to add.
-
get
Get settings value for a certain key and provide a default value.- 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
-
get
Get settings value for a certain key.- Parameters:
key- the identifier for the setting- Returns:
- "" if there is nothing set for the preference key, the corresponding value otherwise. The result is not null.
-
put
Set a value for a certain setting.- 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
Gets a boolean preference- 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
-
getBoolean
Gets a boolean preference- Parameters:
key- The preference key- Returns:
- The boolean or
falseif it could not be parsed
-
putBoolean
Set a boolean value for a certain setting.- Parameters:
key- the unique identifier for the settingvalue- The new value- Returns:
true, if something has changed (i.e. value is different than before)- Since:
- 12840
-
getInt
Gets an integer preference- Parameters:
key- The preference keydef- The default value to use- Returns:
- The integer
- Since:
- 12840
-
putInt
Set an integer value for a certain setting.- Parameters:
key- the unique identifier for the settingvalue- The new value- Returns:
true, if something has changed (i.e. value is different than before)- Since:
- 12840
-
getLong
Gets a long preference- 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
Set a long value for a certain setting.- 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
Gets a double preference- 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
Set a boolean value for a certain setting.- Parameters:
key- the unique identifier for the settingvalue- The new value- Returns:
true, if something has changed (i.e. value is different than before)- Since:
- 12840
-
getList
Get a list of values for a certain key- Parameters:
key- the identifier for the settingdef- the default value.- Returns:
- the corresponding value if the property has been set before,
defotherwise - Since:
- 12840
-
getList
Get a list of values for a certain key- Parameters:
key- the identifier for the setting- Returns:
- the corresponding value if the property has been set before, an empty list otherwise.
- Since:
- 12840
-
putList
Set a list of values for a certain key.- Parameters:
key- the identifier for the settingvalue- The new value- Returns:
true, if something has changed (i.e. value is different than before)- Since:
- 12840
-
getListOfLists
Get an array of values (list of lists) for a certain key- Parameters:
key- the identifier for the settingdef- the default value.- Returns:
- the corresponding value if the property has been set before,
defotherwise - Since:
- 12840
-
getListOfLists
Get an array of values (list of lists) for a certain key- Parameters:
key- the identifier for the setting- Returns:
- the corresponding value if the property has been set before, an empty list otherwise
- Since:
- 12840
-
putListOfLists
Set an array of values (list of lists) for a certain key.- Parameters:
key- the identifier for the settingvalue- the new value- Returns:
true, if something has changed (i.e. value is different than before)- Since:
- 12840
-
getListOfMaps
Gets a list of key/value maps.- Parameters:
key- the key to search atdef- the default value to use- Returns:
- the corresponding value if the property has been set before,
defotherwise - Since:
- 12840
-
getListOfMaps
Gets a list of key/value maps.- Parameters:
key- the key to search at- Returns:
- the corresponding value if the property has been set before, an empty list otherwise
- Since:
- 12840
-
putListOfMaps
Set an a list of key/value maps.- Parameters:
key- the key to store the list invalue- a list of key/value maps- Returns:
trueif the value was changed- Since:
- 12840
-
getKeySet
Get the set of all keys that are mapped to a value in this preferences.- Returns:
- the set of all keys
-
addSensitive
Add sensitive keys- Parameters:
caller- The calling agentkey- The key that may contain sensitive information- Since:
- 18650
-
getSensitive
Get sensitive keys- Returns:
- The sensitive keys
- Since:
- 18650
-
removeSensitive
Remove sensitive keys. This removes the key from the sensitive list and removes the stored preference value.- Parameters:
key- The key to remove- Since:
- 18650
-