public class Storage
extends java.lang.Object
Constructor and Description |
---|
Storage(java.lang.String defaultPath,
java.io.File file)
Create a new instance.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String[] |
childrenNames(java.lang.String path)
Return the names of the children of a node.
|
java.lang.String[] |
getKeys(java.lang.String path)
Return all of the keys that have an associated value in a node.
|
java.lang.String |
getValue(java.lang.String path,
java.lang.String key)
Return the value associated with the specified key at a node, or
null if there is no association for this key. |
void |
newNode(java.lang.String path)
Make sure a node exists.
|
void |
putValue(java.lang.String path,
java.lang.String key,
java.lang.String value)
Put the given key-value association into a node.
|
void |
removeNode(java.lang.String path)
Remove a preference node including all preferences that it contains.
|
void |
removeValue(java.lang.String path,
java.lang.String key)
Remove the association (if any) for the specified key at a node.
|
void |
sync(boolean sync)
Save changes to the underlying file.
|
public Storage(@NotNull java.lang.String defaultPath, @Nullable java.io.File file)
defaultPath
- the default key name for loading/saving valuesfile
- the file for loading/saving values or null
to not use
a backing filepublic void newNode(@NotNull java.lang.String path)
path
- the node path name@NotNull public java.lang.String[] childrenNames(@NotNull java.lang.String path)
path
- the node path name@Nullable public java.lang.String getValue(@NotNull java.lang.String path, @NotNull java.lang.String key)
null
if there is no association for this key.path
- the node path namekey
- the key to get value for@NotNull public java.lang.String[] getKeys(@NotNull java.lang.String path)
path
- the node path namepublic void putValue(@NotNull java.lang.String path, @NotNull java.lang.String key, @NotNull java.lang.String value)
path
- the node path namekey
- the key to storevalue
- the value to storepublic void removeNode(@NotNull java.lang.String path)
path
- the node path namepublic void removeValue(@NotNull java.lang.String path, @NotNull java.lang.String key)
path
- the node path name to remove fromkey
- the key to removepublic void sync(boolean sync) throws java.util.prefs.BackingStoreException
sync
- not currently usedjava.util.prefs.BackingStoreException
- in case sync was not possible, i.e. due to
I/O problems