T
- the specific base XML object type being managed@NotThreadSafe public class MapLoadSaveManager<T extends XMLObject> extends Object implements XMLObjectLoadSaveManager<T>
XMLObjectLoadSaveManager
which uses an in-memory map.Modifier and Type | Field and Description |
---|---|
private Map<String,T> |
backingMap
The backing map.
|
Constructor and Description |
---|
MapLoadSaveManager()
Constructor.
|
MapLoadSaveManager(Map<String,T> map)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
exists(String key)
Evaluate whether an object already exists indexed by the supplied key.
|
Iterable<Pair<String,T>> |
listAll()
Return an iterable of all objects under management, along with their associated index key.
|
Set<String> |
listKeys()
Return a set of the index keys of all objects under management.
|
T |
load(String key)
Load a particular object based on the supplied key.
|
boolean |
remove(String key)
Remove the object indexed by the specified key.
|
void |
save(String key,
T xmlObject)
Save a particular object, indexed by the supplied key.
|
void |
save(String key,
T xmlObject,
boolean overwrite)
Save a particular object, indexed by the supplied key.
|
boolean |
updateKey(String currentKey,
String newKey)
Update the key under which a particular object is stored.
|
public Set<String> listKeys() throws IOException
listKeys
in interface XMLObjectLoadSaveManager<T extends XMLObject>
IOException
- if there is a fatal error obtaining the keyspublic Iterable<Pair<String,T>> listAll() throws IOException
listAll
in interface XMLObjectLoadSaveManager<T extends XMLObject>
IOException
- if there is a fatal error loading the managed objectspublic boolean exists(String key) throws IOException
exists
in interface XMLObjectLoadSaveManager<T extends XMLObject>
key
- the key of the desired objectIOException
- if there is a fatal error evaluating object existencepublic T load(String key) throws IOException
load
in interface XMLObjectLoadSaveManager<T extends XMLObject>
key
- the key of the desired objectIOException
- if there is a fatal error loading the objectpublic void save(String key, T xmlObject) throws IOException
An existing object indexed by the supplied key will not be overwritten.
Instead an IOException
will be thrown.
For saving with the overwrite option, see XMLObjectLoadSaveManager.save(String, XMLObject, boolean)
.
save
in interface XMLObjectLoadSaveManager<T extends XMLObject>
key
- the key under which to index the objectxmlObject
- the object to saveIOException
- if there is a fatal error saving the object, or if an object already exists
indexed by the supplied keypublic void save(String key, T xmlObject, boolean overwrite) throws IOException
save
in interface XMLObjectLoadSaveManager<T extends XMLObject>
key
- the key under which to index the objectxmlObject
- the object to saveoverwrite
- whether or not to overwrite any existing object indexed by the supplied keyIOException
- if there is a fatal error saving the object, or if overwrite=false,
if an object already exists indexed by the supplied keypublic boolean remove(String key) throws IOException
remove
in interface XMLObjectLoadSaveManager<T extends XMLObject>
key
- the key of the object to removeIOException
- if there was a fatal error removing the objectpublic boolean updateKey(String currentKey, String newKey) throws IOException
updateKey
in interface XMLObjectLoadSaveManager<T extends XMLObject>
currentKey
- the current key under which the object is storednewKey
- the new key under which the object should be storedIOException
- if there was a fatal error updating the keyCopyright © 1999–2018 Shibboleth Consortium. All rights reserved.