Methods Summary |
---|
public abstract java.lang.String | absolutePath()Gets the absolute path string of this preference node.
|
public abstract void | addNodeChangeListener(java.util.prefs.NodeChangeListener ncl)Registers a {@code NodeChangeListener} instance for this node, which will handle
{@code NodeChangeEvent}s. {@code NodeChangeEvent}s will be fired when a child node has
been added to or removed from this node.
|
public abstract void | addPreferenceChangeListener(java.util.prefs.PreferenceChangeListener pcl)Registers a {@code PreferenceChangeListener} instance for this node, which will
handle {@code PreferenceChangeEvent}s. {@code PreferenceChangeEvent}s will be fired when
a preference has been added to, removed from, or updated for this node.
|
private static void | checkSecurity()
SecurityManager manager = System.getSecurityManager();
if(null != manager){
manager.checkPermission(PREFS_PERM);
}
|
public abstract java.lang.String[] | childrenNames()Returns the names of all children of this node or an empty string if this
node has no children.
|
public abstract void | clear()Removes all preferences of this node.
|
public abstract void | exportNode(java.io.OutputStream ostream)Exports all of the preferences of this node to a XML document using the given
output stream.
This XML document uses the UTF-8 encoding and is written according to the
DTD in its DOCTYPE declaration, which is the following:
<!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd">
Please note that (unlike the methods of this class that don't concern serialization), this call is not thread-safe.
|
public abstract void | exportSubtree(java.io.OutputStream ostream)Exports all of the preferences of this node and all its descendants to a XML
document using the given output stream.
This XML document uses the UTF-8 encoding and is written according to the
DTD in its DOCTYPE declaration, which is the following:
<!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd">
Please note that (unlike the methods of this class that don't concern serialization), this call is not thread-safe.
|
public abstract void | flush()Forces all pending updates to this node and its descendants to be
persisted in the backing store.
If this node has been removed, the invocation of this method only flushes
this node, not its descendants.
|
public abstract java.lang.String | get(java.lang.String key, java.lang.String deflt)Gets the {@code String} value mapped to the given key or its default value if no
value is mapped or no backing store is available.
Some implementations may store default values in backing stores. In this
case, if there is no value mapped to the given key, the stored default
value is returned.
|
public abstract boolean | getBoolean(java.lang.String key, boolean deflt)Gets the {@code boolean} value mapped to the given key or its default value if no
value is mapped, if the backing store is unavailable, or if the value is invalid.
The only valid values are the {@code String} "true", which represents {@code true} and
"false", which represents {@code false}, ignoring case.
Some implementations may store default values in backing stores. In this
case, if there is no value mapped to the given key, the stored default
value is returned.
|
public abstract byte[] | getByteArray(java.lang.String key, byte[] deflt)Gets the {@code byte} array value mapped to the given key or its default value if
no value is mapped, if the backing store is unavailable, or if the value is an
invalid string.
To be valid, the value string must be Base64-encoded binary data. The Base64 encoding
is as defined in RFC
2045, section 6.8.
Some implementations may store default values in backing stores. In this
case, if there is no value mapped to the given key, the stored default
value is returned.
|
public abstract double | getDouble(java.lang.String key, double deflt)Gets the {@code double} value mapped to the given key or its default value if no
value is mapped, if the backing store is unavailable, or if the value is an invalid
string.
To be valid, the value string must be a string that can be converted to a {@code double} by
{@link Double#parseDouble(String) Double.parseDouble(String)}.
Some implementations may store default values in backing stores. In this
case, if there is no value mapped to the given key, the stored default
value is returned.
|
public abstract float | getFloat(java.lang.String key, float deflt)Gets the {@code float} value mapped to the given key or its default value if no
value is mapped, if the backing store is unavailable, or if the value is an invalid
string.
To be valid, the value string must be a string that can be converted to a {@code float} by
{@link Float#parseFloat(String) Float.parseFloat(String)}.
Some implementations may store default values in backing stores. In this
case, if there is no value mapped to the given key, the stored default
value is returned.
|
public abstract int | getInt(java.lang.String key, int deflt)Gets the {@code int} value mapped to the given key or its default value if no
value is mapped, if the backing store is unavailable, or if the value is an invalid
string.
To be valid, the value string must be a string that can be converted to an {@code int} by
{@link Integer#parseInt(String) Integer.parseInt(String)}.
Some implementations may store default values in backing stores. In this
case, if there is no value mapped to the given key, the stored default
value is returned.
|
public abstract long | getLong(java.lang.String key, long deflt)Gets the {@code long} value mapped to the given key or its default value if no
value is mapped, if the backing store is unavailable, or if the value is an invalid
string.
To be valid, the value string must be a string that can be converted to a {@code long} by
{@link Long#parseLong(String) Long.parseLong(String)}.
Some implementations may store default values in backing stores. In this
case, if there is no value mapped to the given key, the stored default
value is returned.
|
private static java.lang.String | getNodeName(java.lang.Class c)
// ??? PREFS TODO change back to harmony code once getPackage
// delivers the correct results
// Package p = c.getPackage();
// if(null == p){
// return "/<unnamed>"; //$NON-NLS-1$
// }
// return "/"+p.getName().replace('.', '/'); //$NON-NLS-1$
int dotIndex = c.getName().lastIndexOf(".");
return "/" + c.getName().substring(0, dotIndex).replace(".", "/");
|
public static void | importPreferences(java.io.InputStream istream)Imports all the preferences from an XML document using the given input
stream.
This XML document uses the UTF-8 encoding and must be written according to the
DTD in its DOCTYPE declaration, which must be the following:
<!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd">
Please note that (unlike the methods of this class that don't concern serialization), this call is not thread-safe.
checkSecurity();
if(null == istream){
// prefs.0=Inputstream cannot be null\!
throw new MalformedURLException(Messages.getString("prefs.0")); //$NON-NLS-1$
}
XMLParser.importPrefs(istream);
|
public abstract boolean | isUserNode()Returns whether this is a user preference node.
|
public abstract java.lang.String[] | keys()Returns all preference keys stored in this node or an empty array if no
key was found.
|
public abstract java.lang.String | name()Returns the name of this node.
|
public abstract java.util.prefs.Preferences | node(java.lang.String path)Returns the preference node with the given path name. The path name can
be relative or absolute. The requested node and its ancestors will
be created if they do not exist.
The path is treated as relative to this node if it doesn't start with a
slash, otherwise it will be treated as an absolute path.
|
public abstract boolean | nodeExists(java.lang.String path)Returns whether the preference node with the given path name exists. The
path is treated as relative to this node if it doesn't start with a slash,
otherwise it is treated as an absolute path.
Please note that if this node has been removed, an invocation of this
node will throw an {@code IllegalStateException} unless the given path is
an empty string, which will return {@code false}.
|
public abstract java.util.prefs.Preferences | parent()Returns the parent preference node of this node or {@code null} if this
node is the root node.
|
public abstract void | put(java.lang.String key, java.lang.String value)Adds a new preference to this node using the given key and value or
updates the value if a preference with the given key already exists.
|
public abstract void | putBoolean(java.lang.String key, boolean value)Adds a new preference with a {@code boolean} value to this node using the given
key and value or updates the value if a preference with the given key
already exists.
|
public abstract void | putByteArray(java.lang.String key, byte[] value)Adds a new preference to this node using the given key and the string
form of the given value or updates the value if a preference with the
given key already exists.
The string form of the value is the Base64-encoded binary data of the
given byte array. The Base64 encoding is as defined in RFC 2045, section 6.8.
|
public abstract void | putDouble(java.lang.String key, double value)Adds a new preference to this node using the given key and {@code double}
value or updates the value if a preference with the
given key already exists.
The value is stored in its string form, which is the result of invoking
{@link Double#toString(double) Double.toString(double)}.
|
public abstract void | putFloat(java.lang.String key, float value)Adds a new preference to this node using the given key and {@code float}
value or updates the value if a preference with the
given key already exists.
The value is stored in its string form, which is the result of invoking
{@link Float#toString(float) Float.toString(float)}.
|
public abstract void | putInt(java.lang.String key, int value)Adds a new preference to this node using the given key and {@code int}
value or updates the value if a preference with the
given key already exists.
The value is stored in its string form, which is the result of invoking
{@link Integer#toString(int) Integer.toString(int)}.
|
public abstract void | putLong(java.lang.String key, long value)Adds a new preference to this node using the given key and {@code long}
value or updates the value if a preference with the
given key already exists.
The value is stored in its string form, which is the result of invoking
{@link Long#toString(long) Long.toString(long)}.
|
public abstract void | remove(java.lang.String key)Removes the preference mapped to the given key from this node.
|
public abstract void | removeNode()Removes this preference node with all its descendants. The removal
won't necessarily be persisted until the method {@code flush()} is invoked.
|
public abstract void | removeNodeChangeListener(java.util.prefs.NodeChangeListener ncl)Removes the given {@code NodeChangeListener} instance from this node.
|
public abstract void | removePreferenceChangeListener(java.util.prefs.PreferenceChangeListener pcl)Removes the given {@code PreferenceChangeListener} instance from this node.
|
public abstract void | sync()Synchronizes the data of this preference node and its descendants with
the back-end preference store. Any changes found in the back-end data should be reflected
in this node and its descendants, and at the same time any local changes to this node and
descendants should be persisted.
|
public static java.util.prefs.Preferences | systemNodeForPackage(java.lang.Class c)Returns the system preference node for the package of the given class.
The absolute path of the returned node is one slash followed by the given
class's full package name, replacing each period character ('.') with
a slash. For example, the absolute path of the preference associated with
the class Object would be "/java/lang". As a special case, the unnamed
package is associated with a preference node "/<unnamed>". This
method will create the node and its ancestors as needed. Any nodes created
by this method won't necessarily be persisted until the method {@code flush()} is
invoked.
checkSecurity();
return factory.systemRoot().node(getNodeName(c));
|
public static java.util.prefs.Preferences | systemRoot()Returns the root node of the system preference hierarchy.
checkSecurity();
return factory.systemRoot();
|
public abstract java.lang.String | toString()Returns a string representation of this node. The format is "User/System
Preference Node: " followed by this node's absolute path.
|
public static java.util.prefs.Preferences | userNodeForPackage(java.lang.Class c)Returns the user preference node for the package of the given class.
The absolute path of the returned node is one slash followed by the given
class's full package name, replacing each period character ('.') with
a slash. For example, the absolute path of the preference associated with
the class Object would be "/java/lang". As a special case, the unnamed
package is associated with a preference node "/<unnamed>". This
method will create the node and its ancestors as needed. Any nodes created
by this method won't necessarily be persisted until the method {@code flush()} is
invoked.
checkSecurity();
return factory.userRoot().node(getNodeName(c));
|
public static java.util.prefs.Preferences | userRoot()Returns the root node of the user preference hierarchy.
checkSecurity();
return factory.userRoot();
|