|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openbandy.pref.Preferences
public final class Preferences
The Preferences class provides a simple way to persistently store key
(String) value (String, int, boolean) pairs. For this purpose, it uses the
RMS in which it creates a record store named 'Preferences'.
Note that the whole class is forbidden to use the logger as the log itself
uses Preferences!
(c) Copyright P. Bolliger 2007, ALL RIGHTS RESERVED.
Constructor Summary | |
---|---|
Preferences()
|
Method Summary | |
---|---|
static void |
add(java.lang.String name,
boolean screenModifiable)
Add a preference to the RMS. |
static boolean |
getBooleanValue(java.lang.String name)
Reads the boolean preference with the given name from the persistent store. |
static int |
getIntValue(java.lang.String name)
Reads the int preference with the given name from the persistent store. |
static java.lang.String |
getValue(java.lang.String name)
Reads the string preference with the given name from the persistent store. |
static java.util.Enumeration |
preferences()
Returns an enumeration of all preferences currently stored. |
static void |
remove(java.lang.String name)
Remove the preference with the given name from the persistent store. |
static void |
setBooleanValue(java.lang.String name,
boolean value)
Set the value of the preference that is identified with the given name string to the given value. |
static void |
setIntValue(java.lang.String name,
int value)
Set the value of the preference that is identified with the given name string to the given value. |
static void |
setValue(java.lang.String name,
java.lang.String value)
Set the value of the preference that is identified with the given name string to the given value. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Preferences()
Method Detail |
---|
public static void add(java.lang.String name, boolean screenModifiable) throws javax.microedition.rms.RecordStoreNotOpenException, javax.microedition.rms.RecordStoreFullException, javax.microedition.rms.RecordStoreException
name
- The unique identifier of the preference (make sure it is
unique yourself)screenModifiable
- if true, the preference will appear in the PreferencesForm
screen (@see PreferencesForm)
javax.microedition.rms.RecordStoreNotOpenException
javax.microedition.rms.RecordStoreFullException
javax.microedition.rms.RecordStoreException
public static void remove(java.lang.String name) throws UnknownPreferenceException, javax.microedition.rms.RecordStoreException, javax.microedition.rms.InvalidRecordIDException, javax.microedition.rms.RecordStoreNotOpenException
name
- The (unique) string used to identify the preference.
UnknownPreferenceException
- If the preference is not known in the store
javax.microedition.rms.RecordStoreException
javax.microedition.rms.InvalidRecordIDException
javax.microedition.rms.RecordStoreNotOpenException
public static java.lang.String getValue(java.lang.String name) throws UnknownPreferenceException
name
- The (unique) name description of the preference
InvalidValueException
- Thrown if the preference associated with the given name is
not a string value
UnknownPreferenceException
- Thrown if no preference value is stored with the given namepublic static int getIntValue(java.lang.String name) throws InvalidValueException, UnknownPreferenceException
name
- The (unique) name description of the preference
InvalidValueException
- Thrown if the preference associated with the given name is
not a int value
UnknownPreferenceException
- Thrown if no preference value is stored with the given namepublic static boolean getBooleanValue(java.lang.String name) throws InvalidValueException, UnknownPreferenceException
name
- The (unique) name description of the preference
InvalidValueException
- Thrown if the preference associated with the given name is
not a boolean value
UnknownPreferenceException
- Thrown if no preference value is stored with the given namepublic static void setValue(java.lang.String name, java.lang.String value) throws InvalidValueException, javax.microedition.rms.RecordStoreFullException, javax.microedition.rms.RecordStoreNotOpenException, javax.microedition.rms.RecordStoreException
name
- The (unique) name description of the stored preference valuevalue
- The string value to be set
InvalidValueException
- Thrown if the preference associated with the given name is
not a string value
javax.microedition.rms.RecordStoreFullException
javax.microedition.rms.RecordStoreNotOpenException
javax.microedition.rms.RecordStoreException
public static void setIntValue(java.lang.String name, int value) throws InvalidValueException, javax.microedition.rms.RecordStoreFullException, javax.microedition.rms.RecordStoreNotOpenException, javax.microedition.rms.RecordStoreException
name
- The (unique) name description of the stored preference valuevalue
- The int value to be set
InvalidValueException
- Thrown if the preference associated with the given name is
not an int value
javax.microedition.rms.RecordStoreFullException
javax.microedition.rms.RecordStoreNotOpenException
javax.microedition.rms.RecordStoreException
public static void setBooleanValue(java.lang.String name, boolean value) throws InvalidValueException, javax.microedition.rms.RecordStoreFullException, javax.microedition.rms.RecordStoreNotOpenException, javax.microedition.rms.RecordStoreException
name
- The (unique) name description of the stored preference valuevalue
- The boolean value to be set
InvalidValueException
- Thrown if the preference associated with the given name is
not a boolean value
javax.microedition.rms.RecordStoreFullException
javax.microedition.rms.RecordStoreNotOpenException
javax.microedition.rms.RecordStoreException
public static java.util.Enumeration preferences()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |