Package java.util.prefs
Class FilePreferencesImpl
- java.lang.Object
-
- java.util.prefs.Preferences
-
- java.util.prefs.AbstractPreferences
-
- java.util.prefs.FilePreferencesImpl
-
public class FilePreferencesImpl extends AbstractPreferences
The default implementation ofAbstractPreferencesfor the Linux platform, using the file system as its back end. TODO some sync mechanism with backend, Performance - check file edit date- Since:
- 1.4
-
-
Field Summary
-
Fields inherited from class java.util.prefs.AbstractPreferences
lock, newNode
-
Fields inherited from class java.util.prefs.Preferences
MAX_KEY_LENGTH, MAX_NAME_LENGTH, MAX_VALUE_LENGTH
-
-
Constructor Summary
Constructors Constructor Description FilePreferencesImpl(String path, boolean isUserNode)Construct rootFilePreferencesImplinstance rooted at the given path.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String[]childrenNamesSpi()Returns the names of all of the child nodes of this node or an empty array if this node has no children.protected AbstractPreferenceschildSpi(String name)Returns the child preference node with the given name, creating it if it does not exist.protected voidflushSpi()Flushes changes of this node to the backing store.protected StringgetSpi(String key)Gets the preference value mapped to the given key.protected String[]keysSpi()Returns an array of all preference keys of this node or an empty array if no preferences have been found.protected voidputSpi(String name, String value)Puts the given key-value pair into this node.protected voidremoveNodeSpi()Removes this node from the preference hierarchy tree.protected voidremoveSpi(String key)Removes the preference with the specified key.protected voidsyncSpi()Synchronizes this node with the backing store.-
Methods inherited from class java.util.prefs.AbstractPreferences
absolutePath, addNodeChangeListener, addPreferenceChangeListener, cachedChildren, childrenNames, clear, exportNode, exportSubtree, flush, get, getBoolean, getByteArray, getChild, getDouble, getFloat, getInt, getLong, isRemoved, isUserNode, keys, name, node, nodeExists, parent, put, putBoolean, putByteArray, putDouble, putFloat, putInt, putLong, remove, removeNode, removeNodeChangeListener, removePreferenceChangeListener, sync, toString
-
Methods inherited from class java.util.prefs.Preferences
importPreferences, setPreferencesFactory, systemNodeForPackage, systemRoot, userNodeForPackage, userRoot
-
-
-
-
Constructor Detail
-
FilePreferencesImpl
public FilePreferencesImpl(String path, boolean isUserNode)
Construct rootFilePreferencesImplinstance rooted at the given path.
-
-
Method Detail
-
childrenNamesSpi
protected String[] childrenNamesSpi() throws BackingStoreException
Description copied from class:AbstractPreferencesReturns the names of all of the child nodes of this node or an empty array if this node has no children. The names of cached children are not required to be returned.- Specified by:
childrenNamesSpiin classAbstractPreferences- Returns:
- the names of this node's children.
- Throws:
BackingStoreException- if the backing store is unavailable or causes an operation failure.
-
childSpi
protected AbstractPreferences childSpi(String name)
Description copied from class:AbstractPreferencesReturns the child preference node with the given name, creating it if it does not exist. The caller of this method should ensure that the given name is valid and that this node has not been removed or cached. If the named node has just been removed, the implementation of this method must create a new one instead of reactivating the removed one.The new creation is not required to be persisted immediately until the flush method will be invoked.
- Specified by:
childSpiin classAbstractPreferences- Parameters:
name- the name of the child preference to be returned.- Returns:
- the child preference node.
-
flushSpi
protected void flushSpi() throws BackingStoreExceptionDescription copied from class:AbstractPreferencesFlushes changes of this node to the backing store. This method should only flush this node and should not include the descendant nodes. Any implementation that wants to provide functionality to flush all nodes at once should override the methodflush().- Specified by:
flushSpiin classAbstractPreferences- Throws:
BackingStoreException- if the backing store is unavailable or causes an operation failure.
-
getSpi
protected String getSpi(String key)
Description copied from class:AbstractPreferencesGets the preference value mapped to the given key. The caller of this method should ensure that the given key is valid and that this node has not been removed. This method should not throw any exceptions but if it does, the caller will ignore the exception, regarding it as anullreturn value.- Specified by:
getSpiin classAbstractPreferences- Parameters:
key- the given key to be searched for.- Returns:
- the preference value mapped to the given key.
-
keysSpi
protected String[] keysSpi() throws BackingStoreException
Description copied from class:AbstractPreferencesReturns an array of all preference keys of this node or an empty array if no preferences have been found. The caller of this method should ensure that this node has not been removed.- Specified by:
keysSpiin classAbstractPreferences- Returns:
- the array of all preference keys.
- Throws:
BackingStoreException- if the backing store is unavailable or causes an operation failure.
-
putSpi
protected void putSpi(String name, String value)
Description copied from class:AbstractPreferencesPuts the given key-value pair into this node. Caller of this method should ensure that both of the given values are valid and that this node has not been removed.- Specified by:
putSpiin classAbstractPreferences- Parameters:
name- the given preference key.value- the given preference value.
-
removeNodeSpi
protected void removeNodeSpi() throws BackingStoreExceptionDescription copied from class:AbstractPreferencesRemoves this node from the preference hierarchy tree. The caller of this method should ensure that this node has no child nodes, which means the methodPreferences.removeNode()should invoke this method multiple-times in bottom-up pattern. The removal is not required to be persisted until after it is flushed.- Specified by:
removeNodeSpiin classAbstractPreferences- Throws:
BackingStoreException- if the backing store is unavailable or causes an operation failure.
-
removeSpi
protected void removeSpi(String key)
Description copied from class:AbstractPreferencesRemoves the preference with the specified key. The caller of this method should ensure that the given key is valid and that this node has not been removed.- Specified by:
removeSpiin classAbstractPreferences- Parameters:
key- the key of the preference that is to be removed.
-
syncSpi
protected void syncSpi() throws BackingStoreExceptionDescription copied from class:AbstractPreferencesSynchronizes this node with the backing store. This method should only synchronize this node and should not include the descendant nodes. An implementation that wants to provide functionality to synchronize all nodes at once should override the methodsync().- Specified by:
syncSpiin classAbstractPreferences- Throws:
BackingStoreException- if the backing store is unavailable or causes an operation failure.
-
-