com.cloudbees.sdk.utils
Class PersistedStore<V>
java.lang.Object
java.util.AbstractMap<String,V>
com.cloudbees.sdk.utils.PersistedStore<V>
- All Implemented Interfaces:
- Map<String,V>
- Direct Known Subclasses:
- PersistedGAVStore
public abstract class PersistedStore<V>
- extends AbstractMap<String,V>
Persisted configuration store of 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.
- Author:
- Kohsuke Kawaguchi
| Nested classes/interfaces inherited from interface java.util.Map |
Map.Entry<K,V> |
PersistedStore
public PersistedStore()
getStorageDirectory
protected abstract File getStorageDirectory()
- Returns the directory that serves as the persistent storage.
read
protected abstract V read(File f)
throws IllegalArgumentException
- Reads a data file 'f' into the value.
- Returns:
- null if the file doesn't exist or the content is empty.
- Throws:
IllegalArgumentException - if you fail to read it because the content is invalid
write
protected abstract void write(File f,
V data)
- Writes the given value to the file
- Parameters:
data - Never null.
get
public V get(Object key)
- Specified by:
get in interface Map<String,V>- Overrides:
get in class AbstractMap<String,V>
get
public V get(String key)
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey in interface Map<String,V>- Overrides:
containsKey in class AbstractMap<String,V>
put
public V put(String key,
V value)
- Specified by:
put in interface Map<String,V>- Overrides:
put in class AbstractMap<String,V>
remove
public V remove(Object key)
- Specified by:
remove in interface Map<String,V>- Overrides:
remove in class AbstractMap<String,V>
remove
public V remove(String key)
clear
public void clear()
- Specified by:
clear in interface Map<String,V>- Overrides:
clear in class AbstractMap<String,V>
_write
protected V _write(File f,
V value)
entrySet
public Set<Map.Entry<String,V>> entrySet()
- Specified by:
entrySet in interface Map<String,V>- Specified by:
entrySet in class AbstractMap<String,V>
keySet
public Set<String> keySet()
- Specified by:
keySet in interface Map<String,V>- Overrides:
keySet in class AbstractMap<String,V>
Copyright © 2011-2013. All Rights Reserved.