| java.lang.Object java.util.prefs.Preferences java.util.prefs.AbstractPreferences
All known Subclasses: java.util.prefs.RegistryPreferencesImpl, java.util.prefs.FilePreferencesImpl,
AbstractPreferences | abstract public class AbstractPreferences extends Preferences (Code) | | This class is partly implementation of Preferences , which can be
used to simplify Preferences provider's implementation.
This class define nine abstract SPI methods, which must be implemented by
preference provider. And provider can also override other methods of this
class. Some SPI methods will throw BackingStoreException ,
including childrenNamesSpi() , flushSpi() ,
keysSpi() , removeNodeSpi() ,
syncSpi() ; getSpi(String, String) never throws any
exceptions; the last SPI methods, putSpi(String) ,
removeSpi(String) and childSpi(String) won't throw
BackingStoreException , but in some implementations, they may
throw SecurityException due to lacking the permission to access
backing end storage.
since: 1.4 See Also: Preferences |
Field Summary | |
final protected Object | lock The object used to lock this node. | protected boolean | newNode This field is true if this node is created while it doesn't exist in the
backing store. | boolean | userNode |
Method Summary | |
public String | absolutePath() | public void | addNodeChangeListener(NodeChangeListener ncl) | public void | addPreferenceChangeListener(PreferenceChangeListener pcl) | final protected AbstractPreferences[] | cachedChildren() Return arrays of all cached children node. | abstract protected AbstractPreferences | childSpi(String name) Return the child preference node with the given name, and create new one if
it does not exist. | public String[] | childrenNames() | abstract protected String[] | childrenNamesSpi() Return names of this node's all children , or empty array if this node has
no child. | public void | clear() | public void | exportNode(OutputStream ostream) | public void | exportSubtree(OutputStream ostream) | public void | flush() | abstract protected void | flushSpi() Flush changes of this node to the backing store. | public String | get(String key, String deflt) | public boolean | getBoolean(String key, boolean deflt) | public byte[] | getByteArray(String key, byte[] deflt) | protected AbstractPreferences | getChild(String name) Return the child node with given name, or null if it doesn't exist. | public double | getDouble(String key, double deflt) | public float | getFloat(String key, float deflt) | public int | getInt(String key, int deflt) | public long | getLong(String key, long deflt) | abstract protected String | getSpi(String key) Get the preference value mapped to the given key. | protected boolean | isRemoved() Return true if and only if this node has been removed by invoking
AbstractPreferences.removeNode() removeNode . | public boolean | isUserNode() | public String[] | keys() | abstract protected String[] | keysSpi() Return all keys of this node's preferences, or empty array if no preference
found on this node. | public String | name() | public Preferences | node(String name) | public boolean | nodeExists(String name) | public Preferences | parent() | public void | put(String key, String value) | public void | putBoolean(String key, boolean value) | public void | putByteArray(String key, byte[] value) | public void | putDouble(String key, double value) | public void | putFloat(String key, float value) | public void | putInt(String key, int value) | public void | putLong(String key, long value) | abstract protected void | putSpi(String name, String value) Put the given key-value pair into this node. | public void | remove(String key) | public void | removeNode() | public void | removeNodeChangeListener(NodeChangeListener ncl) | abstract protected void | removeNodeSpi() Remove this node from the preference hierarchy tree. | public void | removePreferenceChangeListener(PreferenceChangeListener pcl) | abstract protected void | removeSpi(String key) Remove the preference with the given key. | public void | sync() | abstract protected void | syncSpi() Synchronize this node with the backing store. | public String | toString() |
lock | final protected Object lock(Code) | | The object used to lock this node.
|
newNode | protected boolean newNode(Code) | | This field is true if this node is created while it doesn't exist in the
backing store. This field's default value is false, and it is checked when
the node creation is completed, and if it is true, the node change event
will be fired for this node's parent.
|
userNode | boolean userNode(Code) | | true if this node is in user preference hierarchy
|
AbstractPreferences | protected AbstractPreferences(AbstractPreferences parent, String name)(Code) | | Construct a new AbstractPreferences instance using given
parent node and node name.
Parameters: parent - the parent node of this node, can be null, which means this node is root Parameters: name - the name of this node, can be empty(""), which means this node is root throws: IllegalArgumentException - if name contains slash, or be empty if parent is not null |
cachedChildren | final protected AbstractPreferences[] cachedChildren()(Code) | | Return arrays of all cached children node.
arrays of all cached children node. |
childSpi | abstract protected AbstractPreferences childSpi(String name)(Code) | | Return the child preference node with the given name, and create new one if
it does not exist. Invoker of this method should assure that the given name
are valid as well as this node is not removed. Invocation of this method
implies that the node with given name is not cached(or, has been removed.)
If the named node has just been removed, implementation of this method must
create a new one instead of reactivated the removed one.
The new creation is not required to be persisted immediately until the flush
method is invoked.
Parameters: name - AbstractPreferences |
childrenNamesSpi | abstract protected String[] childrenNamesSpi() throws BackingStoreException(Code) | | Return names of this node's all children , or empty array if this node has
no child. Cached children name is not required to be returned.
names of this node's all children throws: BackingStoreException - if backing store is unavailable or causes operation failure |
flushSpi | abstract protected void flushSpi() throws BackingStoreException(Code) | | Flush changes of this node to the backing store. This method should only
flush this node, and should not include the descendant nodes. The
implementation which want to flush all nodes at once should override
AbstractPreferences.flush() flush() method.
throws: BackingStoreException - if backing store is unavailable or causes operation failure |
getBoolean | public boolean getBoolean(String key, boolean deflt)(Code) | | |
getByteArray | public byte[] getByteArray(String key, byte[] deflt)(Code) | | |
getChild | protected AbstractPreferences getChild(String name) throws BackingStoreException(Code) | | Return the child node with given name, or null if it doesn't exist. The
given name must be valid and this node cannot be removed. Invocation of
this method implies that the node with given name is not cached(or, has
been removed.)
Parameters: name - the given child name to be got the child node with given name, or null if it doesn't exist throws: BackingStoreException - if backing store is unavailable or causes operation failure |
getDouble | public double getDouble(String key, double deflt)(Code) | | |
getFloat | public float getFloat(String key, float deflt)(Code) | | |
getSpi | abstract protected String getSpi(String key)(Code) | | Get the preference value mapped to the given key. Invoker of this method
should assure that given key are valid as well as this node is not removed.
This method should not throw exceptions, but if it does, the invoker should
catch it and deal with it as null return value.
Parameters: key - the given key to be searched for the preference value mapped to the given key |
isUserNode | public boolean isUserNode()(Code) | | |
keysSpi | abstract protected String[] keysSpi() throws BackingStoreException(Code) | | Return all keys of this node's preferences, or empty array if no preference
found on this node. Invoker of this method should assure that this node is
not removed.
all keys of this node's preferences throws: BackingStoreException - if backing store is unavailable or causes operation failure |
putBoolean | public void putBoolean(String key, boolean value)(Code) | | |
putByteArray | public void putByteArray(String key, byte[] value)(Code) | | |
putDouble | public void putDouble(String key, double value)(Code) | | |
putSpi | abstract protected void putSpi(String name, String value)(Code) | | Put the given key-value pair into this node. Invoker of this method should
assure that both the given values are valid as well as this node
is not removed.
Parameters: name - the given preference key Parameters: value - the given preference value |
removeNodeSpi | abstract protected void removeNodeSpi() throws BackingStoreException(Code) | | Remove this node from the preference hierarchy tree. The invoker of this
method should assure that this node has no child node, which means the
Preferences.removeNode Preferences.removeNode() should invoke
this method multi-times in bottom-up pattern. The removal is not required
to be persisted at once until the it is flushed.
throws: BackingStoreException - if backing store is unavailable or causes operation failure |
removeSpi | abstract protected void removeSpi(String key)(Code) | | Remove the preference with the given key. Invoker of this method
should assure that given key are valid as well as this node is not removed.
Parameters: key - the given key to removed |
syncSpi | abstract protected void syncSpi() throws BackingStoreException(Code) | | Synchronize this node with the backing store. This method should only
synchronize this node, and should not include the descendant nodes. The
implementation which want to synchronize all nodes at once should override
AbstractPreferences.sync() sync() method.
throws: BackingStoreException - if backing store is unavailable or causes operation failure |
Methods inherited from java.util.prefs.Preferences | abstract public String absolutePath()(Code)(Java Doc) abstract public void addNodeChangeListener(NodeChangeListener ncl)(Code)(Java Doc) abstract public void addPreferenceChangeListener(PreferenceChangeListener pcl)(Code)(Java Doc) abstract public String[] childrenNames() throws BackingStoreException(Code)(Java Doc) abstract public void clear() throws BackingStoreException(Code)(Java Doc) abstract public void exportNode(OutputStream ostream) throws IOException, BackingStoreException(Code)(Java Doc) abstract public void exportSubtree(OutputStream ostream) throws IOException, BackingStoreException(Code)(Java Doc) abstract public void flush() throws BackingStoreException(Code)(Java Doc) abstract public String get(String key, String deflt)(Code)(Java Doc) abstract public boolean getBoolean(String key, boolean deflt)(Code)(Java Doc) abstract public byte[] getByteArray(String key, byte[] deflt)(Code)(Java Doc) abstract public double getDouble(String key, double deflt)(Code)(Java Doc) abstract public float getFloat(String key, float deflt)(Code)(Java Doc) abstract public int getInt(String key, int deflt)(Code)(Java Doc) abstract public long getLong(String key, long deflt)(Code)(Java Doc) public static void importPreferences(InputStream istream) throws InvalidPreferencesFormatException, IOException(Code)(Java Doc) abstract public boolean isUserNode()(Code)(Java Doc) abstract public String[] keys() throws BackingStoreException(Code)(Java Doc) abstract public String name()(Code)(Java Doc) abstract public Preferences node(String path)(Code)(Java Doc) abstract public boolean nodeExists(String path) throws BackingStoreException(Code)(Java Doc) abstract public Preferences parent()(Code)(Java Doc) abstract public void put(String key, String value)(Code)(Java Doc) abstract public void putBoolean(String key, boolean value)(Code)(Java Doc) abstract public void putByteArray(String key, byte[] value)(Code)(Java Doc) abstract public void putDouble(String key, double value)(Code)(Java Doc) abstract public void putFloat(String key, float value)(Code)(Java Doc) abstract public void putInt(String key, int value)(Code)(Java Doc) abstract public void putLong(String key, long value)(Code)(Java Doc) abstract public void remove(String key)(Code)(Java Doc) abstract public void removeNode() throws BackingStoreException(Code)(Java Doc) abstract public void removeNodeChangeListener(NodeChangeListener ncl)(Code)(Java Doc) abstract public void removePreferenceChangeListener(PreferenceChangeListener pcl)(Code)(Java Doc) abstract public void sync() throws BackingStoreException(Code)(Java Doc) public static Preferences systemNodeForPackage(Class> c)(Code)(Java Doc) public static Preferences systemRoot()(Code)(Java Doc) abstract public String toString()(Code)(Java Doc) public static Preferences userNodeForPackage(Class> c)(Code)(Java Doc) public static Preferences userRoot()(Code)(Java Doc)
|
|
|