| com.jgoodies.binding.value.AbstractValueModel com.jgoodies.binding.adapter.PreferencesAdapter
PreferencesAdapter | final public class PreferencesAdapter extends AbstractValueModel (Code) | | A ValueModel implementation that reads and writes values from/to a key
of a given Preferences node under a specified key.
Write changes fire value changes.
Example:
String prefsKey = "isShowing";
Boolean defaultValue = Boolean.TRUE;
Preferences prefs = Workbench.userPreferences();
ValueModel model = new PreferencesAdapter(prefs, prefsKey, defaultValue);
JCheckBox showingBox = new JCheckBox("Show tips");
showingBox.setModel(new ToggleButtonAdapter(model));
author: Karsten Lentzsch version: $Revision: 1.6 $ See Also: java.util.prefs.Preferences |
Constructor Summary | |
public | PreferencesAdapter(Preferences prefs, String key, Object defaultValue) Constructs a PreferencesAdapter on the given Preferences
using the specified key and default value, all which must be
non-null . |
Method Summary | |
public boolean | getBoolean() Looks up, converts and returns the stored value from the preferences. | public double | getDouble() Looks up, converts and returns the stored value from the preferences. | public float | getFloat() Looks up, converts and returns the stored value from the preferences. | public int | getInt() Looks up, converts and returns the stored value from the preferences. | public long | getLong() Looks up, converts and returns the stored value from the preferences. | public String | getString() Looks up, converts and returns the stored value from the preferences. | public Object | getValue() Looks up and returns the value from the preferences. | public void | setBoolean(boolean newValue) Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key. | public void | setDouble(double newValue) Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key. | public void | setFloat(float newValue) Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key. | public void | setInt(int newValue) Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key. | public void | setLong(long newValue) Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key. | public void | setString(String newValue) Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key. | public void | setValue(Object newValue) Converts the given value to a string and puts it into the preferences. |
PreferencesAdapter | public PreferencesAdapter(Preferences prefs, String key, Object defaultValue)(Code) | | Constructs a PreferencesAdapter on the given Preferences
using the specified key and default value, all which must be
non-null .
Parameters: prefs - the Preferences used to store and retrieve Parameters: key - the key used to get and set values in the Preferences Parameters: defaultValue - the default value throws: NullPointerException - if the Preferences, key, or default valueis null throws: IllegalArgumentException - if the default value is of a type otherthan Boolean, Double, Float, Integer, Long, or String. |
getBoolean | public boolean getBoolean()(Code) | | Looks up, converts and returns the stored value from the preferences.
Returns the default value if no value has been stored before.
the stored value or the default |
getDouble | public double getDouble()(Code) | | Looks up, converts and returns the stored value from the preferences.
Returns the default value if no value has been stored before.
the stored value or the default |
getFloat | public float getFloat()(Code) | | Looks up, converts and returns the stored value from the preferences.
Returns the default value if no value has been stored before.
the stored value or the default |
getInt | public int getInt()(Code) | | Looks up, converts and returns the stored value from the preferences.
Returns the default value if no value has been stored before.
the stored value or the default |
getLong | public long getLong()(Code) | | Looks up, converts and returns the stored value from the preferences.
Returns the default value if no value has been stored before.
the stored value or the default |
getString | public String getString()(Code) | | Looks up, converts and returns the stored value from the preferences.
Returns the default value if no value has been stored before.
the stored value or the default |
getValue | public Object getValue()(Code) | | Looks up and returns the value from the preferences. The value is
look up under this adapter's key. It will be converted before it is
returned.
the retrieved and converted value throws: ClassCastException - if the type of the default valuecannot be read from the preferences |
setBoolean | public void setBoolean(boolean newValue)(Code) | | Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key.
Parameters: newValue - the value to put into the Preferences throws: ClassCastException - if the default value is not a Boolean |
setDouble | public void setDouble(double newValue)(Code) | | Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key.
Parameters: newValue - the value to put into the Preferences throws: ClassCastException - if the default value is not a Double |
setFloat | public void setFloat(float newValue)(Code) | | Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key.
Parameters: newValue - the value to put into the Preferences throws: ClassCastException - if the default value is not a Float |
setInt | public void setInt(int newValue)(Code) | | Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key.
Parameters: newValue - the value to put into the Preferences throws: ClassCastException - if the default value is not an Integer |
setLong | public void setLong(long newValue)(Code) | | Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key.
Parameters: newValue - the value to put into the Preferences throws: ClassCastException - if the default value is not a Long |
setString | public void setString(String newValue)(Code) | | Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key.
Parameters: newValue - the value to put into the Preferences throws: ClassCastException - if the default value is not a String |
setValue | public void setValue(Object newValue)(Code) | | Converts the given value to a string and puts it into the preferences.
Parameters: newValue - the object to be stored throws: IllegalArgumentException - if the new value cannot be storedin the preferences due to an illegal type |
Fields inherited from com.jgoodies.binding.value.AbstractValueModel | final public static String PROPERTYNAME_VALUE(Code)(Java Doc)
|
|
|