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
All Methods Instance Methods Abstract Methods Default 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.voidaddSensitive(CredentialsAgent caller, java.lang.String key)Add sensitive keysdefault java.lang.Stringget(java.lang.String key)Get settings value for a certain key.java.lang.Stringget(java.lang.String key, java.lang.String def)Get settings value for a certain key and provide a default value.default booleangetBoolean(java.lang.String key)Gets a boolean preferencebooleangetBoolean(java.lang.String key, boolean def)Gets a boolean preferencedoublegetDouble(java.lang.String key, double def)Gets a double preferenceintgetInt(java.lang.String key, int def)Gets an integer preferencejava.util.Set<java.lang.String>getKeySet()Get the set of all keys that are mapped to a value in this preferences.default java.util.List<java.lang.String>getList(java.lang.String key)Get a list of values for a certain keyjava.util.List<java.lang.String>getList(java.lang.String key, java.util.List<java.lang.String> def)Get a list of values for a certain keydefault java.util.List<java.util.List<java.lang.String>>getListOfLists(java.lang.String key)Get an array of values (list of lists) for a certain keyjava.util.List<java.util.List<java.lang.String>>getListOfLists(java.lang.String key, java.util.List<java.util.List<java.lang.String>> def)Get an array of values (list of lists) for a certain keydefault java.util.List<java.util.Map<java.lang.String,java.lang.String>>getListOfMaps(java.lang.String key)Gets a list of key/value maps.java.util.List<java.util.Map<java.lang.String,java.lang.String>>getListOfMaps(java.lang.String key, java.util.List<java.util.Map<java.lang.String,java.lang.String>> def)Gets a list of key/value maps.longgetLong(java.lang.String key, long def)Gets a long preferencejava.util.Collection<java.lang.String>getSensitive()Get sensitive keysbooleanput(java.lang.String key, java.lang.String value)Set a value for a certain setting.booleanputBoolean(java.lang.String key, boolean value)Set a boolean value for a certain setting.booleanputDouble(java.lang.String key, double value)Set a boolean value for a certain setting.booleanputInt(java.lang.String key, int value)Set an integer value for a certain setting.booleanputList(java.lang.String key, java.util.List<java.lang.String> value)Set a list of values for a certain key.booleanputListOfLists(java.lang.String key, java.util.List<java.util.List<java.lang.String>> value)Set an array of values (list of lists) for a certain key.booleanputListOfMaps(java.lang.String key, java.util.List<java.util.Map<java.lang.String,java.lang.String>> value)Set an a list of key/value maps.booleanputLong(java.lang.String key, long value)Set a long 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.voidremoveSensitive(java.lang.String key)Remove sensitive keys.
-
-
-
Method Detail
-
addPreferenceChangeListener
void addPreferenceChangeListener(PreferenceChangedListener listener)
Adds a new preferences listener.- Parameters:
listener- The listener to add
-
removePreferenceChangeListener
void removePreferenceChangeListener(PreferenceChangedListener listener)
Removes a preferences listener.- Parameters:
listener- The listener to remove
-
addKeyPreferenceChangeListener
void addKeyPreferenceChangeListener(java.lang.String key, PreferenceChangedListener listener)
Adds a listener that only listens to changes in one preference- Parameters:
key- The preference key to listen tolistener- The listener to add.
-
removeKeyPreferenceChangeListener
void removeKeyPreferenceChangeListener(java.lang.String key, PreferenceChangedListener listener)
Removes a listener that only listens to changes in one preference- Parameters:
key- The preference key to listen tolistener- The listener to add.
-
get
java.lang.String get(java.lang.String key, java.lang.String def)
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
default java.lang.String get(java.lang.String key)
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
boolean put(java.lang.String key, java.lang.String value)
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
boolean getBoolean(java.lang.String key, boolean def)
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
default boolean getBoolean(java.lang.String key)
Gets a boolean preference- Parameters:
key- The preference key- Returns:
- The boolean or
falseif it could not be parsed
-
putBoolean
boolean putBoolean(java.lang.String key, boolean value)
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
int getInt(java.lang.String key, int def)
Gets an integer preference- Parameters:
key- The preference keydef- The default value to use- Returns:
- The integer
- Since:
- 12840
-
putInt
boolean putInt(java.lang.String key, int value)
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
long getLong(java.lang.String key, long def)
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
boolean putLong(java.lang.String key, long value)
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
double getDouble(java.lang.String key, double def)
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
boolean putDouble(java.lang.String key, double value)
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
java.util.List<java.lang.String> getList(java.lang.String key, java.util.List<java.lang.String> def)
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
default java.util.List<java.lang.String> getList(java.lang.String key)
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
boolean putList(java.lang.String key, java.util.List<java.lang.String> value)
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
java.util.List<java.util.List<java.lang.String>> getListOfLists(java.lang.String key, java.util.List<java.util.List<java.lang.String>> def)
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
default java.util.List<java.util.List<java.lang.String>> getListOfLists(java.lang.String key)
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
boolean putListOfLists(java.lang.String key, java.util.List<java.util.List<java.lang.String>> value)
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
java.util.List<java.util.Map<java.lang.String,java.lang.String>> getListOfMaps(java.lang.String key, java.util.List<java.util.Map<java.lang.String,java.lang.String>> def)
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
default java.util.List<java.util.Map<java.lang.String,java.lang.String>> getListOfMaps(java.lang.String key)
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
boolean putListOfMaps(java.lang.String key, java.util.List<java.util.Map<java.lang.String,java.lang.String>> value)
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
java.util.Set<java.lang.String> getKeySet()
Get the set of all keys that are mapped to a value in this preferences.- Returns:
- the set of all keys
-
addSensitive
void addSensitive(CredentialsAgent caller, java.lang.String key)
Add sensitive keys- Parameters:
caller- The calling agentkey- The key that may contain sensitive information- Since:
- 18650
-
getSensitive
java.util.Collection<java.lang.String> getSensitive()
Get sensitive keys- Returns:
- The sensitive keys
- Since:
- 18650
-
removeSensitive
void removeSensitive(java.lang.String key)
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
-
-