|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tentackle.util.CompositePreferences
public abstract class CompositePreferences
User- and System-Preferences combined.
Implements Preferences in such a way that
user-space overwrites system-space which is the default
for most applications.
Furthermore, some helper methods allow exporting and importing
with file-dialogs, etc...
This class is abstract because it should be extended by the application to get its own namespace (by classname).
| Constructor Summary | |
|---|---|
CompositePreferences(boolean systemOnly)
Creates composite preferences. |
|
| Method Summary | |
|---|---|
static void |
exportPreferences(boolean system)
Exports the preferences (user or system) to XML and prompts the user in a dialog for the file. |
static void |
exportPreferences(String pathname,
boolean system)
Exports the preferences (user or system) to XML. |
void |
flush()
Flushes the preferences (system and user). |
Boolean |
getABoolean(String key)
Gets a Boolean. |
Double |
getADouble(String key)
Gets a Double. |
Float |
getAFloat(String key)
Gets a Float. |
Long |
getALong(String key)
Gets a Long. |
boolean |
getBoolean(String key,
boolean def)
Gets a boolean value. |
byte[] |
getByteArray(String key)
Gets a bytearray from the preferences. |
byte[] |
getByteArray(String key,
byte[] def)
Gets a bytearray from the preferences. |
Color |
getColor(String key)
Gets a color value from preferences. |
Color |
getColor(String key,
Color def)
Gets a color value from preferences. |
double |
getDouble(String key,
double def)
Gets a double value. |
float |
getFloat(String key,
float def)
Gets a float value. |
int |
getInt(String key,
int def)
Gets an int value. |
Integer |
getInteger(String key)
Gets an Integer. |
long |
getLong(String key,
long def)
Gets a long value. |
String |
getString(String key)
Gets the value for a key. |
String |
getString(String key,
String def)
Gets the value for a key. |
Preferences |
getSystemPrefs()
Gets the system preferences. |
Preferences |
getUserPrefs()
Gets the user peferences. |
static void |
importPreferences(boolean system)
Imports the preferences (user or system) from XML and prompts the user for a file. |
static void |
importPreferences(String pathname,
boolean system)
Imports the preferences (user or system) from XML. |
void |
setBoolean(String key,
Boolean val)
Sets a Boolean. If the value is the same as in systemspace, the user value is removed. |
void |
setByteArray(String key,
byte[] val)
Sets a bytearray. If the value is the same as in systemspace, the user value is removed. |
void |
setColor(String key,
Color color)
Sets a preferences color. If the value is the same as in systemspace, the user value is removed. |
void |
setDouble(String key,
Double val)
Sets a Double. If the value is the same as in systemspace, the user value is removed. |
void |
setFloat(String key,
Float val)
Sets a Float. If the value is the same as in systemspace, the user value is removed. |
void |
setInteger(String key,
Integer val)
Sets an integer. If the value is the same as in systemspace, the user value is removed. |
void |
setLong(String key,
Long val)
Sets a Long. If the value is the same as in systemspace, the user value is removed. |
void |
setString(String key,
String val)
Sets the value for a key. If the value is the same as in systemspace, the user value is removed. |
void |
sync()
Syncs the preferences (system and user). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CompositePreferences(boolean systemOnly)
systemOnly - true if refer to system-preferences only, false = user space overwrites system space| Method Detail |
|---|
public static void exportPreferences(String pathname,
boolean system)
throws BackingStoreException,
FileNotFoundException,
IOException
pathname - the filnamesystem - true if system-prefs, else userprefs
BackingStoreException
FileNotFoundException
IOExceptionpublic static void exportPreferences(boolean system)
system - true if system-prefs, else userprefs
public static void importPreferences(String pathname,
boolean system)
throws FileNotFoundException,
IOException,
InvalidPreferencesFormatException,
BackingStoreException
pathname - is the filnamesystem - true if system-prefs, else userprefs
FileNotFoundException
IOException
InvalidPreferencesFormatException
BackingStoreExceptionpublic static void importPreferences(boolean system)
system - true if system-prefs, else userprefspublic Preferences getUserPrefs()
public Preferences getSystemPrefs()
public void flush()
throws BackingStoreException
BackingStoreException
public void sync()
throws BackingStoreException
BackingStoreExceptionpublic String getString(String key)
key - the preferences key
public String getString(String key,
String def)
key - the preferences keydef - the default value
public void setString(String key,
String val)
key - the preferences keyval - the valuepublic Integer getInteger(String key)
key - the preferences key
public int getInt(String key,
int def)
key - the preferences keydef - the default value
public void setInteger(String key,
Integer val)
key - the preferences keyval - the valuepublic Long getALong(String key)
key - the preferences key
public long getLong(String key,
long def)
key - the preferences keydef - the default value
public void setLong(String key,
Long val)
key - the preferences keyval - the valuepublic Float getAFloat(String key)
key - the preferences key
public float getFloat(String key,
float def)
key - the preferences keydef - the default value
public void setFloat(String key,
Float val)
key - the preferences keyval - the valuepublic Double getADouble(String key)
key - the preferences key
public double getDouble(String key,
double def)
key - the preferences keydef - the default value
public void setDouble(String key,
Double val)
key - the preferences keyval - the valuepublic Boolean getABoolean(String key)
key - the preferences key
public boolean getBoolean(String key,
boolean def)
key - the preferences keydef - the default value
public void setBoolean(String key,
Boolean val)
key - the preferences keyval - the valuepublic Color getColor(String key)
key - the preferences key
public Color getColor(String key,
Color def)
key - the preferences keydef - the default color
public void setColor(String key,
Color color)
"red green blue".
key - the preferences keycolor - the colorpublic byte[] getByteArray(String key)
key - the preferences key
public byte[] getByteArray(String key,
byte[] def)
key - the preferences keydef - the default values
public void setByteArray(String key,
byte[] val)
key - the preferences keyval - the values
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||