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 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 to
      listener - The listener to add.
    • removeKeyPreferenceChangeListener

      Removes a listener that only listens to changes in one preference
      Parameters:
      key - The preference key to listen to
      listener - The listener to add.
    • get

      String get(String key, String def)
      Get settings value for a certain key and provide a default value.
      Parameters:
      key - the identifier for the setting
      def - the default value. For each call of get() with a given key, the default value must be the same. def may be null.
      Returns:
      the corresponding value if the property has been set before, def otherwise
    • get

      default String get(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(String key, String value)
      Set a value for a certain setting.
      Parameters:
      key - the unique identifier for the setting
      value - 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(String key, boolean def)
      Gets a boolean preference
      Parameters:
      key - The preference key
      def - The default value to use
      Returns:
      The boolean, false if it could not be parsed, the default value if it is unset
    • getBoolean

      default boolean getBoolean(String key)
      Gets a boolean preference
      Parameters:
      key - The preference key
      Returns:
      The boolean or false if it could not be parsed
    • putBoolean

      boolean putBoolean(String key, boolean value)
      Set a boolean value for a certain setting.
      Parameters:
      key - the unique identifier for the setting
      value - The new value
      Returns:
      true, if something has changed (i.e. value is different than before)
      Since:
      12840
    • getInt

      int getInt(String key, int def)
      Gets an integer preference
      Parameters:
      key - The preference key
      def - The default value to use
      Returns:
      The integer
      Since:
      12840
    • putInt

      boolean putInt(String key, int value)
      Set an integer value for a certain setting.
      Parameters:
      key - the unique identifier for the setting
      value - The new value
      Returns:
      true, if something has changed (i.e. value is different than before)
      Since:
      12840
    • getLong

      long getLong(String key, long def)
      Gets a long preference
      Parameters:
      key - The preference key
      def - The default value to use
      Returns:
      The long value or the default value if it could not be parsed
    • putLong

      boolean putLong(String key, long value)
      Set a long value for a certain setting.
      Parameters:
      key - the unique identifier for the setting
      value - The new value
      Returns:
      true, if something has changed (i.e. value is different than before)
    • getDouble

      double getDouble(String key, double def)
      Gets a double preference
      Parameters:
      key - The preference key
      def - The default value to use
      Returns:
      The double value or the default value if it could not be parsed
    • putDouble

      boolean putDouble(String key, double value)
      Set a boolean value for a certain setting.
      Parameters:
      key - the unique identifier for the setting
      value - 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 setting
      def - the default value.
      Returns:
      the corresponding value if the property has been set before, def otherwise
      Since:
      12840
    • getList

      default List<String> getList(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(String key, List<String> value)
      Set a list of values for a certain key.
      Parameters:
      key - the identifier for the setting
      value - 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 setting
      def - the default value.
      Returns:
      the corresponding value if the property has been set before, def otherwise
      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

      boolean putListOfLists(String key, List<List<String>> value)
      Set an array of values (list of lists) for a certain key.
      Parameters:
      key - the identifier for the setting
      value - 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 at
      def - the default value to use
      Returns:
      the corresponding value if the property has been set before, def otherwise
      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

      boolean putListOfMaps(String key, List<Map<String,String>> value)
      Set an a list of key/value maps.
      Parameters:
      key - the key to store the list in
      value - a list of key/value maps
      Returns:
      true if 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

      void addSensitive(CredentialsAgent caller, String key)
      Add sensitive keys
      Parameters:
      caller - The calling agent
      key - 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