Class Preferences
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
WTPreferences
Supported API: true
Extendable: false
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract PreferencesDeprecated.abstract Preferences[]children()Deprecated.voidclear()Deprecated.abstract voidflush()Deprecated.static PreferencesDeprecated.static PreferencesforPackage(Object o) Deprecated.fullName()Deprecated.abstract StringDeprecated.booleangetBoolean(String key, boolean def) Deprecated.intDeprecated.protected voidinit(Preferences parent, String name) Deprecated.abstract String[]keys()Deprecated.name()Deprecated.Deprecated.booleannodeExists(String pathName) Deprecated.parent()Deprecated.abstract StringDeprecated.voidputBoolean(String key, boolean value) Deprecated.voidDeprecated.abstract voidrefresh()Deprecated.abstract StringDeprecated.protected abstract booleanremoveChild(String name) Deprecated.abstract booleanremoveNode(String pathName) Deprecated.static Preferencesroot()Deprecated.
-
Method Details
-
child
Deprecated.Returns the named child of this preference node, creating it if it does not already exist. The name must be a string consisting of one or more characters. Names must not contain the slash character ('/').If this call causes a node to be created, this node is not guaranteed to be persistent until the
flushmethod is called on this node or one of its ancestors (or descendants).
Supported API: true- Parameters:
name- the name of the child node to return, relative to this preference node- Returns:
- the named child node.
- Throws:
IllegalArgumentException- if child's name is invalid.
-
children
Deprecated.Returns the children of this preference node. (The returned array will be of size zero if this node has no children.)
Supported API: true- Returns:
- the children of this preference node.
-
clear
Deprecated.Removes all of the preferences (key-value associations) in this preference node. This call has no effect on any descendants of this node.
Supported API: true- Throws:
WTException
-
flush
Deprecated.Forces any changes in the contents of this preference node and its descendants to the persistent store. If this preference node has been created since the last call toflush, it and all its ancestors and descendants are made permanent by this operation. Note that this call is not guaranteed to flush any preference values in ancestor nodes; merely the nodes' existence.Once this method returns successfully, it is safe to assume that all changes made prior to the call have become permanent.
- Throws:
WTException
-
forClass
Deprecated.Returns the preference node associated (by convention) with the specified object's class. the convention is as follows: the absolute pathname of the node is the fully qualified class name, preceded by a slash ('/'), and with each period ('.') replaced by a slash. For example, the absolute pathname of the node associated with the classjava.lang.Systemisjava/lang/System.An object wishing to access preferences pertaining to its class can obtain a preference node as follows:
Preferences prefs = Preferences.forClass(this);
Supported API: true- Parameters:
o-- Returns:
- The preference node associated with o's class.
-
forPackage
Deprecated.Returns the preference node associated (by convention) with the specified object's package. The convention is as follows: the absolute pathname of the node is the fully qualified package name, preceded by a slash ('/'), and with each period ('.') replaced by a slash. For example, the absolute pathname of the node associated with the classjava.lang.Systemis/java/lang.An object wishing to access preference pertaining to its package can obtain a preference node as follows:
Preferences prefs = Preferences.forPackage(this);
Supported API: true- Parameters:
o-- Returns:
- the preference node associated with o's package.
-
fullName
Deprecated.Returns this preference node's absolute path name.
Supported API: true- Returns:
- this preference node's absolute path name.
-
get
Deprecated.Returns the value associated with the specified key in this preference node. Returns the specified default if there is no value associated with the key, or the backing store is inaccessible.Some implementations may store default values in their backing stores. If there is no value associated with the specified key, but there is such a persistent default, it is returned in preference to the specified default.
Supported API: true- Parameters:
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 withkey.- Returns:
- the value associated with
key, ordefif no value is associated withkey.
-
getBoolean
Deprecated.Returns the boolean value represented by the string associated with the specified key in this preference node. The only valid strings are "true", which represents true, and "false", which represents false. Returns the specified default if there is no value associated with the key, the backing store is inaccessible, or if the associated value is something other than "true" or "false".
Supported API: true- Parameters:
key- key whose associated value is to be converted to be returned as a boolean.def- the value to be returned in the event that this preference node has no value associated withkeyor the associated value cannot be interpreted as a boolean.- Returns:
- the boolean value represented by the string associated with
keyin this preference node, or null if the associated value does not exist or cannot be interpreted as a boolean. - See Also:
-
getInt
Deprecated.Returns the int value represented by the string associated with the specified key in this preference node. the string is converted to an integer as byInteger.parseInt(String). returns the specified default if there is no value associated with the key, the backing store is inaccessible, or ifInteger.parseIntwould throw a NumberFormatException if the associated value were passed.This convenience method is intended to be used in conjunction with
putInt.
Supported API: true- Parameters:
key- key whose associated value is to be converted to be returned as an int.def- the value to be returned in the event that this preference node has no value associated withkeyor the associated value cannot be interpreted as an int.- Returns:
- the int value represented by the string associated with
keyin this preference node, or null if the associated value does not exist or cannot be interpreted as an int. - See Also:
-
init
Deprecated.Initializes this Preferences object, which must be uninitialized prior to this call. this protected method is provided (in conjunction with the no-args constructor) solely to permit serializable subclasses of this non-serializable class.
Supported API: true- Parameters:
parent- the parent of this preference node, or null if this is the rootname- the name of this preference node, relative to its parent, or "" if this is the root.- Throws:
IllegalArgumentException- ifnamecontains a slash ('/"), orparentis null andnameisn't "".IllegalStateException- if object is already initialized.
-
keys
Deprecated.Returns all of the keys that have an associated value in this preference node.
Supported API: true- Returns:
- an array of the keys that have an associated value in this preference node.
-
name
Deprecated.Returns this preference node's name, relative to its parent.
Supported API: true- Returns:
- this preference node's name, relative to its parent.
-
node
Deprecated.Returns the named preference node, creating it and any of its ancestors if they do not already exist. Accepts a relative or absolute pathname. Absolute pathnames (which begin with '/') are interpreted relative to the root of this preference node. Relative pathnames (which begin with any character other than slash) are interpreted relative to this Preferences itself. The pathname "" is valid, and refers to this preference node itself.If the returned node did not exist prior to this call, this node and any ancestors that were created by this call are not guaranteed to become persistent until the
flushmethod is called on the returned node (or one of its descendants).
Supported API: true- Parameters:
pathName- the path name of the preference node to return.- Returns:
- the specified preference node.
- Throws:
IllegalArgumentException- if the path name is invalid- See Also:
-
nodeExists
Deprecated.Returns true if the named preference node exists. Accepts a relative or absolute pathname. Absolute pathnames (which begin with '/') are interpreted relative to the root of this preference node. Relative pathnames (which begin with any character other than slash) are interpreted relative to this Preferences itself. The pathname "" is valid, and refers to this preference node itself.
Supported API: true- Parameters:
pathName- the path name of the node whose existence is to be checked.- Returns:
- true if the specified node exists.
-
parent
Deprecated.Returns the parent of this preference node, or null if this is the root.
Supported API: true- Returns:
- the parent of this preference node.
-
put
Deprecated.Associated the specified value with the specified key in this preference node.
Supported API: true- Parameters:
key- key with which the specified value is to be associated.value- value to be associated with the specified key.- Returns:
- previous value associated with specified key, or
nullif there was no mapping for the key. - Throws:
WTException
-
putBoolean
Deprecated.Associates a string representing the specified boolean value with the specified key in this preference node. The associated string is "true" if the value is true, and "false" if it is false.This convenience method is inteded to be used in conjunction with
getBoolean.
Supported API: true- Parameters:
key- key with which the string form of value is to be associated.value- value whose string form is to be associated with key.- Throws:
NullPointerException- if key is nullWTException- See Also:
-
putInt
Deprecated.Associates a string representing the specified int value with the specified key in this preference node. The associated string is the on ethat would be returned if the int value were passed toInteger.toString(int).this convenience method is intended to be used in conjunction with
getInt.- Parameters:
key- key with which the string form of value is to be associated.value- value whos e string form is to be associated with key.- Throws:
WTException- See Also:
-
refresh
public abstract void refresh()Deprecated.Ensures that future reads from this preference node and its descendants reflect any changes that have been committed to the persistent store (from any VM).- See Also:
-
remove
Deprecated.Removes the value associated with the specified key in this preference node, if any. returns the value previously associated with the key, or null if there was no value associated with the key.If this implementation supports stored defaults, and there is such a default for the specified property, the stored default will be "exposed" by this call, in the sense that it will be returned by a succeeding call to
get.
Supported API: true- Parameters:
key- key whose mapping is to be removed from the preference node.- Throws:
WTException- See Also:
-
removeChild
Deprecated.Removes the named child of this preference node and all of its descendants, invalidating any preferences contained in the removed nodes. Once a node has been removed, attempting any operation on the corresponding Preferences object may fail with an IllegalStateException.The removal of the specified node is not guaranteed to be persistent until the
flushmethod is called on an ancestor of the specified node.
Supported API: true- Parameters:
name- the name of the child node to remove, relative to this preference node.- Throws:
WTException
-
removeNode
Deprecated.Removes the named preference node and all of its descendants, invalidating any preferences contained in the removed nodes. Accepts a relative or absolute pathname. Absolute pathnames (which begin with '/') are interpreted relative to the root of this preference node. Relative pathnames (which begin with any character other than slash) are interpreted relative to this Preferences itself. The pathname "" is valid, and refers to this preference node itself. Once a node has been removed, attempting any operation on the corresponding Preferences object may fail with an IllegalStateOperation. The removal of the specified node is not guaranteed to be persistent until theflushmethod is called on an ancestor of the specified node. (It is illegal to remove the root node.) The context of the node which is being removed will be the same edit and search context defined for the current node. Thus a context can delete a node and all of their subnodes, but not another context's nodes.
Supported API: true- Parameters:
pathName- the path name of the preference node to remove.- Returns:
- true if the specified preference node existed prior to the call
- Throws:
WTException- See Also:
-
root
Deprecated.Returns the root preference node for the calling user.
Supported API: true- Returns:
- the root preference node for the calling user.
-