public class PreferencesExt extends java.util.prefs.AbstractPreferences implements PersistenceManager
To save Java beans, use putBean() and putBeanCollection(). This uses reflection to get/set properties that have simple single-valued accessor methods of primitive and String type.
For arbitrary objects, use putBeanObject(), which uses the XMLEncode/XMLDecode API (jdk 1.4). To obtain a PreferencesExt object, instantiate an XMLStore object and call XMLStore.getPreferences().
XMLStore
,
Preferences
Constructor and Description |
---|
PreferencesExt(PreferencesExt parent,
java.lang.String name)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.String[] |
childrenNamesSpi()
Implements AbstractPreferences childrenNamesSpi() method.
|
protected java.util.Collection |
childrenNamesSpi(java.lang.String nodePath) |
protected java.util.prefs.AbstractPreferences |
childSpi(java.lang.String name) |
protected void |
flushSpi()
Empty, never used implementation of AbstractPreferences.flushSpi().
|
java.lang.Object |
getBean(java.lang.String key,
java.lang.Object def)
Get the object that has the specified key.
|
java.util.List |
getList(java.lang.String key,
java.util.List def)
Get an arrayList.
|
java.lang.Object |
getObject(java.lang.String key) |
protected java.lang.String |
getSpi(java.lang.String keyName) |
boolean |
isUserNode()
return true unless this is the systemRoot node
|
protected java.lang.String[] |
keysSpi() |
protected java.util.Collection |
keysSpi(java.lang.String nodePath) |
void |
putBean(java.lang.String key,
java.lang.Object newValue)
Stores an object using simple bean properties.
|
void |
putBeanCollection(java.lang.String key,
java.util.Collection newValue)
Stores a Collection of beans.
|
void |
putBeanObject(java.lang.String key,
java.lang.Object newValue)
Stores an object using XMLEncoder/XMLDecoder.
|
void |
putList(java.lang.String key,
java.util.List newValue)
Stores the value with this key, if the exact key and value are not already in
the storedDefaults (using equals() to test for equality).
|
void |
putObject(java.lang.String keyName,
java.lang.Object value) |
protected void |
putSpi(java.lang.String key,
java.lang.String newValue) |
protected void |
removeNodeSpi() |
protected void |
removeSpi(java.lang.String key)
removes key/value if exists, no effect on storedDefaults
Remove the association (if any) for the specified key at this preference node.
|
static void |
setSystemRoot(PreferencesExt prefs)
Set the system root you get when you call Preferences.systemRoot().
|
static void |
setUserRoot(PreferencesExt prefs)
Set the user root you get when you call Preferences.userRoot().
|
protected void |
syncSpi() |
absolutePath, addNodeChangeListener, addPreferenceChangeListener, cachedChildren, childrenNames, clear, exportNode, exportSubtree, flush, get, getBoolean, getByteArray, getChild, getDouble, getFloat, getInt, getLong, isRemoved, keys, name, node, nodeExists, parent, put, putBoolean, putByteArray, putDouble, putFloat, putInt, putLong, remove, removeNode, removeNodeChangeListener, removePreferenceChangeListener, sync, toString
importPreferences, systemNodeForPackage, systemRoot, userNodeForPackage, userRoot
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addPreferenceChangeListener, get, getBoolean, getDouble, getInt, getLong, put, putBoolean, putDouble, putInt, putLong
public PreferencesExt(PreferencesExt parent, java.lang.String name)
public static void setUserRoot(PreferencesExt prefs)
public static void setSystemRoot(PreferencesExt prefs)
public boolean isUserNode()
isUserNode
in class java.util.prefs.AbstractPreferences
public java.lang.Object getBean(java.lang.String key, java.lang.Object def)
key
- get the object with this key.def
- the default value to be returned in the event that this
preference node has no value associated with key.java.lang.IllegalStateException
- if this node (or an ancestor) has been
removed with the AbstractPreferences.removeNode()
method.java.lang.NullPointerException
- if key is null. (A
null default is permitted.)public void putBean(java.lang.String key, java.lang.Object newValue)
key
- key with which the specified value is to be associated.newValue
- store this bean.java.lang.NullPointerException
- if key or value is null.java.lang.IllegalStateException
- if this node (or an ancestor) has been
removed with the AbstractPreferences.removeNode()
method.public void putBeanCollection(java.lang.String key, java.util.Collection newValue)
key
- key with which the specified collection is to be associated.newValue
- store this collection of beans.java.lang.NullPointerException
- if key or value is null.java.lang.IllegalStateException
- if this node (or an ancestor) has been
removed with the AbstractPreferences.removeNode()
method.public void putBeanObject(java.lang.String key, java.lang.Object newValue)
key
- key with which the specified value is to be associated.newValue
- store this bean object.java.lang.NullPointerException
- if key or value is null.java.lang.IllegalStateException
- if this node (or an ancestor) has been
removed with the AbstractPreferences.removeNode()
method.public java.util.List getList(java.lang.String key, java.util.List def)
getList
in interface PersistenceManager
key
- key whose associated value is to be returned.def
- the value to be returned in the event that this
preference node has no value associated with key.public void putList(java.lang.String key, java.util.List newValue)
putList
in interface PersistenceManager
key
- key with which the specified value is to be associated.newValue
- value to be associated with the specified key.protected java.lang.String[] childrenNamesSpi()
childrenNamesSpi
in class java.util.prefs.AbstractPreferences
protected java.util.Collection childrenNamesSpi(java.lang.String nodePath)
protected java.lang.String[] keysSpi() throws java.util.prefs.BackingStoreException
keysSpi
in class java.util.prefs.AbstractPreferences
java.util.prefs.BackingStoreException
protected java.util.Collection keysSpi(java.lang.String nodePath)
protected java.util.prefs.AbstractPreferences childSpi(java.lang.String name)
childSpi
in class java.util.prefs.AbstractPreferences
protected void flushSpi() throws java.util.prefs.BackingStoreException
flushSpi
in class java.util.prefs.AbstractPreferences
java.util.prefs.BackingStoreException
protected java.lang.String getSpi(java.lang.String keyName)
getSpi
in class java.util.prefs.AbstractPreferences
protected void putSpi(java.lang.String key, java.lang.String newValue)
putSpi
in class java.util.prefs.AbstractPreferences
protected void removeNodeSpi() throws java.util.prefs.BackingStoreException
removeNodeSpi
in class java.util.prefs.AbstractPreferences
java.util.prefs.BackingStoreException
protected void removeSpi(java.lang.String key)
removeSpi
in class java.util.prefs.AbstractPreferences
protected void syncSpi() throws java.util.prefs.BackingStoreException
syncSpi
in class java.util.prefs.AbstractPreferences
java.util.prefs.BackingStoreException
public void putObject(java.lang.String keyName, java.lang.Object value)
putObject
in interface PersistenceManager
public java.lang.Object getObject(java.lang.String key)
getObject
in interface PersistenceManager