|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwt.prefs.Preferences
Abstract implementation of the javax.prefs.Preferences
class. This is an approved javax standard with no concrete implementations
available as of our implementation. Once the official implementation
is available, it will likely replace this implementation. See http://java.sun.com/aboutJava/communityprocess/jsr/jsr_010_prefs.html
for more information.
The implementation class returned by the static factory methods in this
class may be specified usin gthe system property "javax.Preferences.implementation".
This defaults to wt.prefs.WTPreferences.
Supported API: true
Extendable: false
Field Summary | |
private static String |
CLASSNAME
|
private static Class |
impl
|
private String |
nodeName
|
private String |
path
|
private static String |
RESOURCE
|
Constructor Summary | |
protected |
Preferences()
Creates a new uninitialized Preferences object. |
protected |
Preferences(Preferences parent,
String name)
Creates a new preference node with the specified parent and the specified name relative to its parent. |
Method Summary | |
protected abstract Preferences |
child(String name)
Returns the named child of this preference node, creating it if it does not already exist. |
abstract Preferences[] |
children()
Returns the children of this preference node. |
void |
clear()
Removes all of the preferences (key-value associations) in this preference node. |
abstract void |
flush()
Forces any changes in the contents of this preference node and its descendants to the persistent store. |
static Preferences |
forClass(Object o)
Returns the preference node associated (by convention) with the specified object's class. |
static Preferences |
forPackage(Object o)
Returns the preference node associated (by convention) with the specified object's package. |
String |
fullName()
Returns this preference node's absolute path name. |
abstract String |
get(String key,
String def)
Returns the value associated with the specified key in this preference node. |
boolean |
getBoolean(String key,
boolean def)
Returns the boolean value represented by the string associated with the specified key in this preference node. |
int |
getInt(String key,
int def)
Returns the int value represented by the string associated with the specified key in this preference node. |
protected void |
init(Preferences parent,
String name)
Initializes this Preferences object, which must be uninitialized prior to this call. |
abstract String[] |
keys()
Returns all of the keys that have an associated value in this preference node. |
String |
name()
Returns this preference node's name, relative to its parent. |
Preferences |
node(String pathName)
Returns the named preference node, creating it and any of its ancestors if they do not already exist. |
boolean |
nodeExists(String pathName)
Returns true if the named preference node exists. |
Preferences |
parent()
Returns the parent of this preference node, or null if this is the root. |
abstract String |
put(String key,
String value)
Associated the specified value with the specified key in this preference node. |
void |
putBoolean(String key,
boolean value)
Associates a string representing the specified boolean value with the specified key in this preference node. |
void |
putInt(String key,
int value)
Associates a string representing the specified int value with the specified key in this preference node. |
abstract void |
refresh()
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). |
abstract String |
remove(String key)
Removes the value associated with the specified key in this preference node, if any. |
protected abstract boolean |
removeChild(String name)
Removes the named child of this preference node and all of its descendants, invalidating any preferences contained in the removed nodes. |
abstract boolean |
removeNode(String pathName)
Removes the named preference node and all of its descendants, invalidating any preferences contained in the removed nodes. |
static Preferences |
root()
Returns the root preference node for the calling user. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final String RESOURCE
private static final String CLASSNAME
private String path
private String nodeName
private static Class impl
Constructor Detail |
protected Preferences()
init(Preferences,String)
protected Preferences(Preferences parent, String name)
parent
- the parent of this preference node, or null if this is the root.name
- the name of this preference node, relative to its parent, or "" if this is the root.
IllegalArgumentException
- if name
contains
a slash ('/'), or parent
is null
and name
isn't "".Method Detail |
protected abstract Preferences child(String name)
If this call causes a node to be created, this node is not guaranteed
to be persistent until the flush
method is called on
this node or one of its ancestors (or descendants).
Supported API: true
name
- the name of the child node to return, relative to this preference node
IllegalArgumentException
- if child's name is invalid.public abstract Preferences[] children()
public void clear() throws WTException
WTException
public abstract void flush() throws WTException
flush
, 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.
WTException
public static Preferences forClass(Object o)
java.lang.System
is java/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
o
-
public static Preferences forPackage(Object o)
java.lang.System
is /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
o
-
public String fullName()
public abstract String get(String key, String def)
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
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
.
key
, or def
if no value is associated with key
.public boolean getBoolean(String key, boolean def)
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 with key
or the associated value cannot be interpreted as a boolean.
key
in this preference node, or null if the associated
value does not exist or cannot be interpreted as a boolean.get(String,String)
,
putBoolean(String,boolean)
public int getInt(String key, int def)
Integer.parseInt(String)
. returns the
specified default if there is no value associated with the key, the
backing store is inaccessible, or if Integer.parseInt
would throw a NumberFormatException if the associated value were passed.
This convenience method is intended to be used in conjunction with
putInt
.
Supported API: true
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 with key
or the associated value cannot be interpreted as an int.
key
in this preference node, or null if the associated value does not
exist or cannot be interpreted as an int.get(String,String)
,
putInt(String,int)
protected void init(Preferences parent, String name)
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.
IllegalArgumentException
- if name
contains
a slash ('/"), or parent
is null and name
isn't "".
IllegalStateException
- if object is already initialized.public abstract String[] keys()
public String name()
public Preferences node(String pathName)
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 flush
method is called
on the returned node (or one of its descendants).
Supported API: true
pathName
- the path name of the preference node to return.
IllegalArgumentException
- if the path name is invalidflush()
public boolean nodeExists(String pathName)
pathName
- the path name of the node whose existence is to be checked.
public Preferences parent()
public abstract String put(String key, String value) throws WTException
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.
null
if there was no mapping for the key.
WTException
public void putBoolean(String key, boolean value) throws WTException
This convenience method is inteded to be used in conjunction with
getBoolean
.
Supported API: true
key
- key with which the string form of value is to be associated.value
- value whose string form is to be associated with key.
NullPointerException
- if key is null
WTException
getBoolean(String,boolean)
,
get(String,String)
public void putInt(String key, int value) throws WTException
Integer.toString(int)
.
this convenience method is intended to be used in conjunction with
getInt
.
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.
WTException
getInt(String, int)
,
get(String, String)
public abstract void refresh()
flush()
public abstract String remove(String key) throws WTException
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
key
- key whose mapping is to be removed from the preference node.
WTException
get(String, String)
protected abstract boolean removeChild(String name) throws WTException
The removal of the specified node is not guaranteed to be persistent
until the flush
method is called on an ancestor of the
specified node.
Supported API: true
name
- the name of the child node to remove, relative to this preference node.
WTException
public abstract boolean removeNode(String pathName) throws WTException
flush
method 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.
pathName
- the path name of the preference node to remove.
WTException
flush()
public static Preferences root()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |