Gridarta Editor
|
Public Member Functions | |
String[] | childrenNames (@NotNull final String path) |
String[] | getKeys (@NotNull final String path) |
String | getValue (@NotNull final String path, @NotNull final String key) |
void | newNode (@NotNull final String path) |
void | putValue (@NotNull final String path, @NotNull final String key, @NotNull final String value) |
void | removeNode (@NotNull final String path) |
void | removeValue (@NotNull final String path, @NotNull final String key) |
Storage (@NotNull final String defaultPath, @Nullable final File file) | |
void | sync (final boolean sync) throws BackingStoreException |
Private Member Functions | |
void | loadValues () |
void | loadValues (@NotNull final LineNumberReader lnr) throws IOException |
void | saveValues () throws IOException |
void | setChanged () |
Static Private Member Functions | |
static void | saveNode (@NotNull final BufferedWriter writer, @Nullable final String path, @NotNull final Map< String, String > node) throws IOException |
Private Attributes | |
final String | defaultPath |
final File | file |
boolean | noSave = true |
final Map< String, Map< String, String > > | values = new TreeMap<>() |
Static Private Attributes | |
static final Category | LOG = Logger.getLogger(Storage.class) |
static final Pattern | PATTERN_EQUAL = Pattern.compile("=") |
static final Pattern | PATTERN_IGNORE = Pattern.compile("[\\[].*") |
Maintains a set of preference values. The values are stored in a flat file.
Definition at line 50 of file Storage.java.
net.sf.gridarta.preferences.Storage.Storage | ( | @NotNull final String | defaultPath, |
@Nullable final File | file | ||
) |
Creates a new instance.
defaultPath | the default key name for loading/saving values |
file | the file for loading/saving values or null
|
Definition at line 99 of file Storage.java.
References net.sf.gridarta.preferences.Storage.defaultPath, net.sf.gridarta.preferences.Storage.file, net.sf.gridarta.preferences.Storage.loadValues(), net.sf.gridarta.preferences.Storage.LOG, and net.sf.gridarta.preferences.Storage.noSave.
String [] net.sf.gridarta.preferences.Storage.childrenNames | ( | @NotNull final String | path | ) |
Returns the names of the children of a node. The returned array will be of size zero if the node has no children.
path | the node path name |
Definition at line 132 of file Storage.java.
References net.sf.gridarta.preferences.Storage.LOG, and net.sf.gridarta.preferences.Storage.values.
Referenced by net.sf.gridarta.preferences.FilePreferences.childrenNamesSpi().
String [] net.sf.gridarta.preferences.Storage.getKeys | ( | @NotNull final String | path | ) |
Returns all of the keys that have an associated value in a node. The returned array will be of size zero if the node has no preferences.
path | the node path name |
Definition at line 172 of file Storage.java.
References net.sf.gridarta.preferences.Storage.LOG, and net.sf.gridarta.preferences.Storage.values.
Referenced by net.sf.gridarta.preferences.FilePreferences.keysSpi().
String net.sf.gridarta.preferences.Storage.getValue | ( | @NotNull final String | path, |
@NotNull final String | key | ||
) |
Returns the value associated with the specified key at a node, or
if there is no association for this key.
path | the node path name |
key | the key to get value for |
Definition at line 155 of file Storage.java.
References net.sf.gridarta.preferences.Storage.LOG, and net.sf.gridarta.preferences.Storage.values.
Referenced by net.sf.gridarta.preferences.FilePreferences.getSpi().
|
private |
Loads the values from the backing file.
Definition at line 270 of file Storage.java.
References net.sf.gridarta.preferences.Storage.file, net.sf.gridarta.preferences.Storage.LOG, and net.sf.gridarta.preferences.Storage.values.
Referenced by net.sf.gridarta.preferences.Storage.Storage().
|
private |
Loads the values from a LineNumberReader.
lnr | the line number reader |
IOException | if an I/O error occurs |
Definition at line 301 of file Storage.java.
References net.sf.gridarta.preferences.Codec.decode(), net.sf.gridarta.preferences.Storage.defaultPath, net.sf.gridarta.preferences.Storage.file, net.sf.gridarta.preferences.Storage.LOG, net.sf.gridarta.preferences.Storage.newNode(), net.sf.gridarta.preferences.Storage.PATTERN_EQUAL, and net.sf.gridarta.preferences.Storage.putValue().
void net.sf.gridarta.preferences.Storage.newNode | ( | @NotNull final String | path | ) |
Makes sure a node exists.
path | the node path name |
Definition at line 115 of file Storage.java.
References net.sf.gridarta.preferences.Storage.LOG, and net.sf.gridarta.preferences.Storage.values.
Referenced by net.sf.gridarta.preferences.FilePreferences.FilePreferences(), and net.sf.gridarta.preferences.Storage.loadValues().
void net.sf.gridarta.preferences.Storage.putValue | ( | @NotNull final String | path, |
@NotNull final String | key, | ||
@NotNull final String | value | ||
) |
Puts the given key-value association into a node.
path | the node path name |
key | the key to store |
value | the value to store |
Definition at line 189 of file Storage.java.
References net.sf.gridarta.preferences.Storage.LOG, net.sf.gridarta.preferences.Storage.setChanged(), and net.sf.gridarta.preferences.Storage.values.
Referenced by net.sf.gridarta.preferences.Storage.loadValues(), and net.sf.gridarta.preferences.FilePreferences.putSpi().
void net.sf.gridarta.preferences.Storage.removeNode | ( | @NotNull final String | path | ) |
Removes a preference node including all preferences that it contains.
path | the node path name |
Definition at line 206 of file Storage.java.
References net.sf.gridarta.preferences.Storage.LOG, net.sf.gridarta.preferences.Storage.setChanged(), and net.sf.gridarta.preferences.Storage.values.
Referenced by net.sf.gridarta.preferences.FilePreferences.removeNodeSpi().
void net.sf.gridarta.preferences.Storage.removeValue | ( | @NotNull final String | path, |
@NotNull final String | key | ||
) |
Removes the association (if any) for the specified key at a node.
path | the node path name to remove from |
key | the key to remove |
Definition at line 221 of file Storage.java.
References net.sf.gridarta.preferences.Storage.LOG, net.sf.gridarta.preferences.Storage.setChanged(), and net.sf.gridarta.preferences.Storage.values.
Referenced by net.sf.gridarta.preferences.FilePreferences.removeSpi().
|
staticprivate |
Saves one node.
writer | the Writer
|
path | the node path name |
node | the node to save |
IOException | if the node cannot be saved |
Definition at line 376 of file Storage.java.
References net.sf.gridarta.preferences.Codec.encode(), and net.sf.gridarta.preferences.Storage.PATTERN_IGNORE.
Referenced by net.sf.gridarta.preferences.Storage.saveValues().
|
private |
Saves the values to the backing file.
IOException | if the values cannot be saved |
Definition at line 335 of file Storage.java.
References net.sf.gridarta.preferences.Storage.defaultPath, net.sf.gridarta.preferences.Storage.file, net.sf.gridarta.preferences.Storage.LOG, net.sf.gridarta.preferences.Storage.saveNode(), and net.sf.gridarta.preferences.Storage.values.
Referenced by net.sf.gridarta.preferences.Storage.setChanged(), and net.sf.gridarta.preferences.Storage.sync().
|
private |
This function is called whenever the contents of values has changed.
Definition at line 255 of file Storage.java.
References net.sf.gridarta.preferences.Storage.file, net.sf.gridarta.preferences.Storage.LOG, net.sf.gridarta.preferences.Storage.noSave, and net.sf.gridarta.preferences.Storage.saveValues().
Referenced by net.sf.gridarta.preferences.Storage.putValue(), net.sf.gridarta.preferences.Storage.removeNode(), and net.sf.gridarta.preferences.Storage.removeValue().
void net.sf.gridarta.preferences.Storage.sync | ( | final boolean | sync | ) | throws BackingStoreException |
Saves changes to the underlying file.
sync | not currently used |
BackingStoreException | in case sync was not possible, i.e. due to I/O problems |
Definition at line 239 of file Storage.java.
References net.sf.gridarta.preferences.Storage.LOG, and net.sf.gridarta.preferences.Storage.saveValues().
Referenced by net.sf.gridarta.preferences.FilePreferences.flush(), and net.sf.gridarta.preferences.FilePreferences.sync().
|
private |
The default key name for loading/saving values.
Definition at line 68 of file Storage.java.
Referenced by net.sf.gridarta.preferences.Storage.loadValues(), net.sf.gridarta.preferences.Storage.saveValues(), and net.sf.gridarta.preferences.Storage.Storage().
|
private |
The file for loading/saving values.
Definition at line 74 of file Storage.java.
Referenced by net.sf.gridarta.preferences.Storage.loadValues(), net.sf.gridarta.preferences.Storage.saveValues(), net.sf.gridarta.preferences.Storage.setChanged(), and net.sf.gridarta.preferences.Storage.Storage().
|
staticprivate |
The Logger for printing log messages.
Definition at line 62 of file Storage.java.
Referenced by net.sf.gridarta.preferences.Storage.childrenNames(), net.sf.gridarta.preferences.Storage.getKeys(), net.sf.gridarta.preferences.Storage.getValue(), net.sf.gridarta.preferences.Storage.loadValues(), net.sf.gridarta.preferences.Storage.newNode(), net.sf.gridarta.preferences.Storage.putValue(), net.sf.gridarta.preferences.Storage.removeNode(), net.sf.gridarta.preferences.Storage.removeValue(), net.sf.gridarta.preferences.Storage.saveValues(), net.sf.gridarta.preferences.Storage.setChanged(), net.sf.gridarta.preferences.Storage.Storage(), and net.sf.gridarta.preferences.Storage.sync().
|
private |
If set, do not save changes into file.
Definition at line 79 of file Storage.java.
Referenced by net.sf.gridarta.preferences.Storage.setChanged(), and net.sf.gridarta.preferences.Storage.Storage().
|
staticprivate |
The pattern that matches a single equal sign ("=").
Definition at line 56 of file Storage.java.
Referenced by net.sf.gridarta.preferences.Storage.loadValues().
|
staticprivate |
Pattern to ignore in path names.
Definition at line 85 of file Storage.java.
Referenced by net.sf.gridarta.preferences.Storage.saveNode().
|
private |
The stored values. Maps path name to key name to value.
Definition at line 91 of file Storage.java.
Referenced by net.sf.gridarta.preferences.Storage.childrenNames(), net.sf.gridarta.preferences.Storage.getKeys(), net.sf.gridarta.preferences.Storage.getValue(), net.sf.gridarta.preferences.Storage.loadValues(), net.sf.gridarta.preferences.Storage.newNode(), net.sf.gridarta.preferences.Storage.putValue(), net.sf.gridarta.preferences.Storage.removeNode(), net.sf.gridarta.preferences.Storage.removeValue(), and net.sf.gridarta.preferences.Storage.saveValues().