textbender.g.util.prefs
Class Preference

java.lang.Object
  extended by Preference
Direct Known Subclasses:
BooleanPreference, FloatPreference, IntegerPreference, StringPreference

public abstract class Preference
extends Object

Convenience wrapper for preference nodes. Allows you to write code such as preference.get(), instead of preferences.getX('preference',default).


Field Summary
protected  String key
           
protected  Preferences preferences
           
 
Constructor Summary
Preference(Preferences preferences, String key)
          Creates a Preference.
 
Method Summary
 String key()
          Returns the unique key under which the preference value is stored, per Preferences.put() and get().
 Preferences preferences()
          Returns the preference node used for storage.
 void remove()
          Removes this preference.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

key

protected final String key

preferences

protected final Preferences preferences
Constructor Detail

Preference

public Preference(Preferences preferences,
                  String key)
Creates a Preference.

Parameters:
preferences - per preferences()
key - per key()
Method Detail

key

public String key()
Returns the unique key under which the preference value is stored, per Preferences.put() and get().

It may help to choose keys that are typographically distinct from ordinary names to guard against inadvertent changes. So perhaps "USERnAME" instead of "userName".


preferences

public Preferences preferences()
Returns the preference node used for storage.


remove

public void remove()
Removes this preference. Equivalent to preferences.remove(key)