Package org.hyperonline.hyperlib.pref
Class StringPreference
- java.lang.Object
-
- org.hyperonline.hyperlib.pref.Preference
-
- org.hyperonline.hyperlib.pref.StringPreference
-
public class StringPreference extends Preference
A class which represents a string-valued preference
-
-
Constructor Summary
Constructors Constructor Description StringPreference(java.lang.String name, java.lang.String value)
Create aStringPreference
object tracking the preference with the given name and default value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
get()
Get the current value of the preferences file entry, or the default if no entry exists.boolean
hasChanged()
Check if the value has changed since last being checked, or if this is the first time this method was called and the value has changed from the default.void
putDefaultValue()
Put an entry with the default value.-
Methods inherited from class org.hyperonline.hyperlib.pref.Preference
getName, putDefaultIfEmpty
-
-
-
-
Constructor Detail
-
StringPreference
public StringPreference(java.lang.String name, java.lang.String value)
Create aStringPreference
object tracking the preference with the given name and default value. Calling this function does not yet modify the preferences file.- Parameters:
name
- The string id of the preferencevalue
- The default value
-
-
Method Detail
-
hasChanged
public boolean hasChanged()
Check if the value has changed since last being checked, or if this is the first time this method was called and the value has changed from the default.- Specified by:
hasChanged
in classPreference
- Returns:
- true if the value has changed, false otherwise
-
putDefaultValue
public void putDefaultValue()
Put an entry with the default value.- Specified by:
putDefaultValue
in classPreference
-
get
public java.lang.String get()
Get the current value of the preferences file entry, or the default if no entry exists.- Returns:
- The value of the preference
- See Also:
Preferences.getString(String, String)
-
-