bookExamples.ch15Streams
Class CustomPreferences
java.lang.Object
bookExamples.ch15Streams.CustomPreferences
public final class CustomPreferences
- extends java.lang.Object
User: lyon
Date: Oct 8, 2007
Time: 10:13:03 AM
Copyright DocJava, Inc. 2005.
Method Summary |
java.lang.String |
absolutePath()
|
java.lang.String |
get(java.lang.String key,
java.lang.String def)
Returns the value associated with the specified key in this preference
node. |
void |
put(java.lang.String key,
java.lang.String value)
Associates the specified value with the specified key in this
preference node. |
static CustomPreferences |
userRoot()
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CustomPreferences
public CustomPreferences(java.io.File fileName)
absolutePath
public java.lang.String absolutePath()
userRoot
public static CustomPreferences userRoot()
put
public void put(java.lang.String key,
java.lang.String value)
- Associates the specified value with the specified key in this
preference node.
- Parameters:
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.
- Throws:
java.lang.NullPointerException
- if key or value is null.
java.lang.IllegalArgumentException
- if key.length() exceeds
MAX_KEY_LENGTH or if value.length exceeds
MAX_VALUE_LENGTH.
java.lang.IllegalStateException
- if this node (or an ancestor) has been
removed with the #removeNode()
method.
get
public java.lang.String get(java.lang.String key,
java.lang.String def)
- 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 stored default, it is returned in
preference to the specified default.
- 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 with key.
- Returns:
- the value associated with key, or def
if no value is associated with key, or the backing
store is inaccessible.
- Throws:
java.lang.IllegalStateException
- if this node (or an ancestor) has been
removed with the #removeNode()
method.
java.lang.NullPointerException
- if key is null. (A
null value for def is permitted.)