public abstract class PersistedStore<V> extends AbstractMap<String,V>
Map<String,V> (for arbitrary V) for configuration data.
The contents is persisted as a directory where the key name is the file name and V as the content of the file.
This format allows users to add/remove these things easily from shell. It also simplifies the 3rd party to instruct
users to tweak the configuration, as well as making it easy to programmatically modify them without losing comments.
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
PersistedStore() |
| Modifier and Type | Method and Description |
|---|---|
protected V |
_write(File f,
V value) |
void |
clear() |
boolean |
containsKey(Object key) |
Set<Map.Entry<String,V>> |
entrySet() |
V |
get(Object key) |
V |
get(String key) |
protected abstract File |
getStorageDirectory()
Returns the directory that serves as the persistent storage.
|
Set<String> |
keySet() |
V |
put(String key,
V value) |
protected abstract V |
read(File f)
Reads a data file 'f' into the value.
|
V |
remove(Object key) |
V |
remove(String key) |
protected abstract void |
write(File f,
V data)
Writes the given value to the file
|
clone, containsValue, equals, hashCode, isEmpty, putAll, size, toString, valuesprotected abstract File getStorageDirectory()
protected abstract V read(File f) throws IllegalArgumentException
IllegalArgumentException - if you fail to read it because the content is invalidprotected abstract void write(File f, V data)
data - Never null.public boolean containsKey(Object key)
containsKey in interface Map<String,V>containsKey in class AbstractMap<String,V>public void clear()
Copyright © 2011-2013. All Rights Reserved.