public class NetworkPreferences extends AbstractPreferences
This ensures that the preferences will follow the "nomad" user.
NetworkPreferencesFactory
Modifier and Type | Field and Description |
---|---|
protected NetworkPreferences |
myparent |
protected Map<String,Preferences> |
nodes |
protected File |
prefImpl |
static int |
SYSTEM_NODE
The system node type.
|
static int |
USER_NODE
The user node type.
|
lock, newNode
MAX_KEY_LENGTH, MAX_NAME_LENGTH, MAX_VALUE_LENGTH
Modifier | Constructor and Description |
---|---|
protected |
NetworkPreferences(File root)
Create a new user Node NetworkPreferences, using a File as root.
|
protected |
NetworkPreferences(File root,
String appli)
Create a new NetworkPreferences, using a File as root.
|
protected |
NetworkPreferences(int handle,
File file)
Create a new NetworkPreferences.
|
protected |
NetworkPreferences(int handle,
File rootDir,
String appli)
Create a new NetworkPreferences.
|
protected |
NetworkPreferences(NetworkPreferences parent,
String name)
Creates a preference node with the specified parent and the specified name relative to its parent.
|
Modifier and Type | Method and Description |
---|---|
protected String[] |
childrenNamesSpi()
Returns the names of the children of this preference node.
|
protected AbstractPreferences |
childSpi(String name)
Returns the named child of this preference node, creating it if it does
not already exist.
|
void |
exportNode(OutputStream os)
Implements the exportNode method as per the specification in
Preferences.exportNode(OutputStream) . |
void |
exportSubtree(OutputStream os)
Implements the exportSubtree method as per the specification in
Preferences.exportSubtree(OutputStream) . |
boolean |
fileExists()
Return true if the backing store file exists.
|
void |
flush() |
protected void |
flushSpi()
Empty, never used implementation of AbstractPreferences.flushSpi().
|
File |
getImpl()
Return the backing store file for this preference.
|
Object |
getLock() |
protected Map<String,Object> |
getMapImpl()
Return the backstore Hashtable implementation for the (key, value) map.
|
protected Map<String,Preferences> |
getNodeImpl()
Return the backstore Hashtable implementation for the nodes.
|
protected String |
getSpi(String key)
Return the value associated with the specified key at this preference
node, or null if there is no association for this key, or the
association cannot be determined at this time.
|
static void |
importPreferences(File file)
Imports all of the preferences represented by the XML document on the
specified File.
|
static void |
importPreferences(InputStream is)
Imports all of the preferences represented by the XML document on the
specified input stream.
|
boolean |
isInRemoveLock() |
boolean |
isUserNode() |
protected String[] |
keysSpi()
Returns all of the keys that have an associated value in this
preference node.
|
Preferences |
node(String name) |
void |
put(String key,
String value) |
protected void |
putSpi(String key,
String value)
Put the given key-value association into this preference node.
|
protected void |
removeNodeSpi()
Removes this preference node, invalidating it and any preferences that
it contains.
|
protected void |
removeSpi(String key)
Remove the association (if any) for the specified key at this preference node.
|
void |
sync()
Identical to flush().
|
protected void |
syncSpi()
Empty, never used implementation of AbstractPreferences.syncSpi().
|
static Preferences |
systemNodeForPackage(Class c) |
static Preferences |
userNodeForPackage(Class c) |
absolutePath, addNodeChangeListener, addPreferenceChangeListener, cachedChildren, childrenNames, clear, get, getBoolean, getByteArray, getChild, getDouble, getFloat, getInt, getLong, isRemoved, keys, name, nodeExists, parent, putBoolean, putByteArray, putDouble, putFloat, putInt, putLong, remove, removeNode, removeNodeChangeListener, removePreferenceChangeListener, toString
systemNodeForPackage, systemRoot, userNodeForPackage, userRoot
public static final int USER_NODE
public static final int SYSTEM_NODE
protected File prefImpl
protected NetworkPreferences myparent
protected Map<String,Preferences> nodes
protected NetworkPreferences(File root)
root
- the File rootprotected NetworkPreferences(File root, String appli)
root
- the File rootappli
- the Application tagprotected NetworkPreferences(int handle, File file)
handle
- the handlefile
- the backing store fileprotected NetworkPreferences(int handle, File rootDir, String appli)
handle
- the handlerootDir
- the backing store root directoryappli
- the Application tagprotected NetworkPreferences(NetworkPreferences 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 "".public boolean fileExists()
protected void putSpi(String key, String value)
putSpi
in class AbstractPreferences
public void put(String key, String value)
put
in class AbstractPreferences
protected String getSpi(String key)
getSpi
in class AbstractPreferences
protected void removeSpi(String key)
removeSpi
in class AbstractPreferences
protected void removeNodeSpi() throws BackingStoreException
Preferences.removeNode()
method
invokes this method repeatedly in a bottom-up fashion, removing each of
a node's descendants before removing the node itself).
The removal of a node will not become persistent until the flush method is invoked on this node (or an ancestor).
removeNodeSpi
in class AbstractPreferences
BackingStoreException
- if this operation cannot be completed
due to a failure in the backing store, or inability to
communicate with it.protected String[] keysSpi() throws BackingStoreException
If this node throws a BackingStoreException, the exception
will propagate out beyond the enclosing AbstractPreferences.keys()
invocation.
keysSpi
in class AbstractPreferences
BackingStoreException
- if this operation cannot be completed
due to a failure in the backing store, or inability to
communicate with it.protected String[] childrenNamesSpi() throws BackingStoreException
If this node throws a BackingStoreException, the exception
will propagate out beyond the enclosing AbstractPreferences.childrenNames()
invocation.
childrenNamesSpi
in class AbstractPreferences
BackingStoreException
- if this operation cannot be completed
due to a failure in the backing store, or inability to
communicate with it.protected AbstractPreferences childSpi(String name)
childSpi
in class AbstractPreferences
name
- The name of the child node to return, relative to
this preference node.protected void syncSpi() throws BackingStoreException
syncSpi
in class AbstractPreferences
BackingStoreException
public void sync() throws BackingStoreException
sync
in class AbstractPreferences
BackingStoreException
protected void flushSpi() throws BackingStoreException
flushSpi
in class AbstractPreferences
BackingStoreException
public void flush() throws BackingStoreException
flush
in class AbstractPreferences
BackingStoreException
public boolean isUserNode()
isUserNode
in class AbstractPreferences
public Object getLock()
public boolean isInRemoveLock()
public void exportNode(OutputStream os) throws IOException, BackingStoreException
Preferences.exportNode(OutputStream)
.exportNode
in class AbstractPreferences
os
- the output stream on which to emit the XML document.IOException
- if writing to the specified output stream
results in an IOException.BackingStoreException
- if preference data cannot be read from
backing store.public void exportSubtree(OutputStream os) throws IOException, BackingStoreException
Preferences.exportSubtree(OutputStream)
.exportSubtree
in class AbstractPreferences
os
- the output stream on which to emit the XML document.IOException
- if writing to the specified output stream
results in an IOException.BackingStoreException
- if preference data cannot be read from
backing store.public static void importPreferences(File file) throws IOException, InvalidPreferencesFormatException
file
- the File from which to read the XML document.IOException
- if reading from the specified output stream
results in an IOException.InvalidPreferencesFormatException
- Data on input stream does not
constitute a valid XML document with the mandated document type.public static void importPreferences(InputStream is) throws IOException, InvalidPreferencesFormatException
is
- the input stream from which to read the XML document.IOException
- if reading from the specified output stream
results in an IOException.InvalidPreferencesFormatException
- Data on input stream does not
constitute a valid XML document with the mandated document type.public static Preferences userNodeForPackage(Class c)
public static Preferences systemNodeForPackage(Class c)
protected Map<String,Preferences> getNodeImpl()
protected Map<String,Object> getMapImpl()
public File getImpl()
public Preferences node(String name)
node
in class AbstractPreferences