Package edu.uiuc.ncsa.security.storage
Class MemoryStore<V extends Identifiable>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<Identifier,V>
-
- edu.uiuc.ncsa.security.storage.MemoryStore<V>
-
- All Implemented Interfaces:
Store<V>
,Serializable
,Cloneable
,Map<Identifier,V>
- Direct Known Subclasses:
ClientMemoryStore
,MonitoredMemoryStore
public abstract class MemoryStore<V extends Identifiable> extends HashMap<Identifier,V> implements Store<V>
An in-memory store. This is useful in several different ways and is in effect just a map that implementsStore
. To use this practically, you must implement the following method:- create - returns the correct actual object.
Created by Jeff Gaynor
on 11/3/11 at 1:14 PM- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MemoryStore.MSInitializer
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description protected IdentifiableProvider<V>
identifiableProvider
-
Fields inherited from interface edu.uiuc.ncsa.security.core.Store
VERSION_TAG
-
-
Constructor Summary
Constructors Constructor Description MemoryStore(IdentifiableProvider<V> identifiableProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description V
create()
Create a new object of the given type.List<V>
getAll()
Method to get every element in the store.Initializable
getInitializer()
MapConverter<V>
getMapConverter()
protected void
realSave(V value)
void
register(V value)
Almost Identical to put(K,V) but since the object should have an identifier, passing along the key is redundant.boolean
remove(List<Identifiable> objects)
Removes a list of identifiable object from the store by ID.void
save(V value)
Saves an object.List<V>
search(String key, String condition, boolean isRegEx)
Allows for searching via a reg ex.List<V>
search(String key, String condition, boolean isRegEx, List<String> attr)
Return a subset of all the attributes.List<V>
search(String key, String condition, boolean isRegEx, List<String> attr, String dateField, Date before, Date after)
int
size(boolean includeVersions)
void
update(V value)
Update an existing object.-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Methods inherited from interface edu.uiuc.ncsa.security.core.Store
getMostRecent, getXMLConverter
-
-
-
-
Field Detail
-
identifiableProvider
protected IdentifiableProvider<V extends Identifiable> identifiableProvider
-
-
Constructor Detail
-
MemoryStore
public MemoryStore(IdentifiableProvider<V> identifiableProvider)
-
-
Method Detail
-
getInitializer
public Initializable getInitializer()
-
create
public V create()
Description copied from interface:Store
Create a new object of the given type. This is not in the store until it is registered. Attempts to update the object should throw an exception. Note that this allows for a separation of creation semantics. Some objects require specific initialization before saving- Specified by:
create
in interfaceStore<V extends Identifiable>
- Returns:
-
update
public void update(V value)
Description copied from interface:Store
Update an existing object. AnUnregisteredObjectException
is thrown if the object has not been saved first.- Specified by:
update
in interfaceStore<V extends Identifiable>
-
realSave
protected void realSave(V value)
-
register
public void register(V value)
Description copied from interface:Store
Almost Identical to put(K,V) but since the object should have an identifier, passing along the key is redundant. This persists the object in the store. Note that this returns void since the contract assumes that this is not registered. If the object is registered an exception should be thrown. Generally use save(V).- Specified by:
register
in interfaceStore<V extends Identifiable>
-
save
public void save(V value)
Description copied from interface:Store
Saves an object. This bridges the gap between SQL stores update and insert commands. Implementations should check if the object already exists in the store and issue an appropriate call.- Specified by:
save
in interfaceStore<V extends Identifiable>
-
getAll
public List<V> getAll()
Description copied from interface:Store
Method to get every element in the store. This is useful for command line interfaces. Note that this might be very expensive.- Specified by:
getAll
in interfaceStore<V extends Identifiable>
- Returns:
-
search
public List<V> search(String key, String condition, boolean isRegEx)
Description copied from interface:Store
Allows for searching via a reg ex. Note that this may be very expensive for certain stores!- Specified by:
search
in interfaceStore<V extends Identifiable>
- Returns:
-
search
public List<V> search(String key, String condition, boolean isRegEx, List<String> attr, String dateField, Date before, Date after)
- Specified by:
search
in interfaceStore<V extends Identifiable>
-
search
public List<V> search(String key, String condition, boolean isRegEx, List<String> attr)
Description copied from interface:Store
Return a subset of all the attributes. For non-SQL stores performance may be slow.- Specified by:
search
in interfaceStore<V extends Identifiable>
- Returns:
-
size
public int size(boolean includeVersions)
- Specified by:
size
in interfaceStore<V extends Identifiable>
-
getMapConverter
public MapConverter<V> getMapConverter()
-
remove
public boolean remove(List<Identifiable> objects)
Description copied from interface:Store
Removes a list of identifiable object from the store by ID.- Specified by:
remove
in interfaceStore<V extends Identifiable>
- Returns:
-
-