Package edu.uiuc.ncsa.security.storage
Class IndexedStreamStore<V extends Identifiable>
- java.lang.Object
-
- edu.uiuc.ncsa.security.storage.IndexedStreamStore<V>
-
- All Implemented Interfaces:
Store<V>
,Map<Identifier,V>
- Direct Known Subclasses:
FileStore
public abstract class IndexedStreamStore<V extends Identifiable> extends Object implements Store<V>
A high-level class for storing things to streams. Implementations must produce the streams. These streams must be storable and retrievable by a key or identifier (being a store, this is required) and allow for retrieving streams based on other keys as well, which are simple hash strings of the identifier. A simple example would be a file system where each file has a name (a hash of the identifier) and then several other strings are used to create unique index entries. The index entries are named by hashes of the new key and their content is a simple string with the identifier in it.
Note that this will try to convert the objects to XML using a supplied converter. Failing this, it will default to java object serialization.Created by Jeff Gaynor
on 4/25/12 at 10:54 AM
-
-
Field Summary
Fields Modifier and Type Field Description protected MapConverter<V>
converter
protected IdentifiableProvider<V>
identifiableProvider
protected Initializable
initializer
-
Fields inherited from interface edu.uiuc.ncsa.security.core.Store
VERSION_TAG
-
-
Constructor Summary
Constructors Constructor Description IndexedStreamStore()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description V
create()
Create a new object of the given type.protected void
createIndexEntry(String otherKey, String identifier, OutputStream outputStream)
HashMap<Identifier,V>
getCreatedItems()
A hash map of items created by this store.protected String
hashString(String identifier)
boolean
isEmpty()
protected V
loadStream(InputStream fis)
V
put(Identifier key, V value)
protected void
put(V t)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
-
-
-
Field Detail
-
converter
protected MapConverter<V extends Identifiable> converter
-
identifiableProvider
protected IdentifiableProvider<V extends Identifiable> identifiableProvider
-
initializer
protected Initializable initializer
-
-
Method Detail
-
getCreatedItems
public HashMap<Identifier,V> getCreatedItems()
A hash map of items created by this store. You should keep track of every item created and if an item already exists return that.- Returns:
- returns created items.
-
put
protected void put(V t)
-
put
public V put(Identifier key, V value)
- Specified by:
put
in interfaceMap<Identifier,V extends Identifiable>
-
loadStream
protected V loadStream(InputStream fis) throws IOException
- Throws:
IOException
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceMap<Identifier,V extends Identifiable>
-
createIndexEntry
protected void createIndexEntry(String otherKey, String identifier, OutputStream outputStream) throws IOException
- Throws:
IOException
-
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:
-
-