public abstract class AbstractPreferences extends java.lang.Object implements IPreferences
IPreferences
interface.Constructor and Description |
---|
AbstractPreferences() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
get(java.lang.String key,
java.lang.String def)
Get settings value for a certain key and provide a default value.
|
boolean |
getBoolean(java.lang.String key,
boolean def)
Gets a boolean preference
|
double |
getDouble(java.lang.String key,
double def)
Gets a double preference
|
int |
getInt(java.lang.String key,
int def)
Gets an integer preference
|
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
|
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
|
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.
|
long |
getLong(java.lang.String key,
long def)
Gets a long preference
|
abstract <T extends Setting<?>> |
getSetting(java.lang.String key,
T def,
java.lang.Class<T> klass)
Get settings value for a certain key and provide default a value.
|
boolean |
put(java.lang.String key,
java.lang.String value)
Set a value for a certain setting.
|
boolean |
putBoolean(java.lang.String key,
boolean value)
Set a boolean value for a certain setting.
|
boolean |
putDouble(java.lang.String key,
double value)
Set a boolean value for a certain setting.
|
boolean |
putInt(java.lang.String key,
int value)
Set an integer value for a certain setting.
|
boolean |
putList(java.lang.String key,
java.util.List<java.lang.String> value)
Set a list of values for a certain key.
|
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.
|
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.
|
boolean |
putLong(java.lang.String key,
long value)
Set a long value for a certain setting.
|
abstract boolean |
putSetting(java.lang.String key,
Setting<?> setting)
Set a value for a certain setting.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addKeyPreferenceChangeListener, addPreferenceChangeListener, get, getBoolean, getKeySet, getList, getListOfLists, getListOfMaps, removeKeyPreferenceChangeListener, removePreferenceChangeListener
public AbstractPreferences()
public java.lang.String get(java.lang.String key, java.lang.String def)
IPreferences
get
in interface IPreferences
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. def
may be null.def
otherwisepublic boolean put(java.lang.String key, java.lang.String value)
IPreferences
put
in interface IPreferences
key
- the unique identifier for the settingvalue
- the value of the setting. Can be null or "" which both removes the key-value entry.true
, if something has changed (i.e. value is different than before)public boolean getBoolean(java.lang.String key, boolean def)
IPreferences
getBoolean
in interface IPreferences
key
- The preference keydef
- The default value to usefalse
if it could not be parsed, the default value if it is unsetpublic boolean putBoolean(java.lang.String key, boolean value)
IPreferences
putBoolean
in interface IPreferences
key
- the unique identifier for the settingvalue
- The new valuetrue
, if something has changed (i.e. value is different than before)public int getInt(java.lang.String key, int def)
IPreferences
getInt
in interface IPreferences
key
- The preference keydef
- The default value to usepublic boolean putInt(java.lang.String key, int value)
IPreferences
putInt
in interface IPreferences
key
- the unique identifier for the settingvalue
- The new valuetrue
, if something has changed (i.e. value is different than before)public long getLong(java.lang.String key, long def)
IPreferences
getLong
in interface IPreferences
key
- The preference keydef
- The default value to usepublic boolean putLong(java.lang.String key, long value)
IPreferences
putLong
in interface IPreferences
key
- the unique identifier for the settingvalue
- The new valuetrue
, if something has changed (i.e. value is different than before)public double getDouble(java.lang.String key, double def)
IPreferences
getDouble
in interface IPreferences
key
- The preference keydef
- The default value to usepublic boolean putDouble(java.lang.String key, double value)
IPreferences
putDouble
in interface IPreferences
key
- the unique identifier for the settingvalue
- The new valuetrue
, if something has changed (i.e. value is different than before)public java.util.List<java.lang.String> getList(java.lang.String key, java.util.List<java.lang.String> def)
IPreferences
getList
in interface IPreferences
key
- the identifier for the settingdef
- the default value.def
otherwisepublic boolean putList(java.lang.String key, java.util.List<java.lang.String> value)
IPreferences
putList
in interface IPreferences
key
- the identifier for the settingvalue
- The new valuetrue
, if something has changed (i.e. value is different than before)public java.util.List<java.util.List<java.lang.String>> getListOfLists(java.lang.String key, java.util.List<java.util.List<java.lang.String>> def)
IPreferences
getListOfLists
in interface IPreferences
key
- the identifier for the settingdef
- the default value.def
otherwisepublic boolean putListOfLists(java.lang.String key, java.util.List<java.util.List<java.lang.String>> value)
IPreferences
putListOfLists
in interface IPreferences
key
- the identifier for the settingvalue
- the new valuetrue
, if something has changed (i.e. value is different than before)public 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)
IPreferences
getListOfMaps
in interface IPreferences
key
- the key to search atdef
- the default value to usedef
otherwisepublic boolean putListOfMaps(java.lang.String key, java.util.List<java.util.Map<java.lang.String,java.lang.String>> value)
IPreferences
putListOfMaps
in interface IPreferences
key
- the key to store the list invalue
- a list of key/value mapstrue
if the value was changedpublic abstract boolean putSetting(java.lang.String key, Setting<?> setting)
key
- the unique identifier for the settingsetting
- the value of the setting. In case it is null, the key-value entry will be removed.true
, if something has changed (i.e. value is different than before)public abstract <T extends Setting<?>> T getSetting(java.lang.String key, T def, java.lang.Class<T> klass)
T
- the setting typekey
- the identifier for the settingdef
- the default value. For each call of getSetting() with a given key, the default value must be the same.
def
must not be null, but the value of def
can be null.klass
- the setting type (same as T)def
otherwise