public class VolatileChunk<K,V> extends DefaultChunk<K,V>
Modifier and Type | Class and Description |
---|---|
static interface |
VolatileChunk.KeyFactory<K,V>
A factory class for producing keys from values.
|
DefaultChunk.OnProgressUpdateListener
Chunk.EmptyChunk<K,V>
Constructor and Description |
---|
VolatileChunk(java.util.Map<K,V> map,
VolatileChunk.KeyFactory<K,V> keyFactory)
Constructs a new HashMapChunk that uses the given backing Map and the given KeyFactory
to generate keys during insertion.
|
VolatileChunk(VolatileChunk.KeyFactory<K,V> keyFactory)
Constructs a new HashMapChunk that uses the given KeyFactory to generate keys
during insertion.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected int |
doDelete(K key,
DefaultChunk.OnProgressUpdateListener onProgressUpdateListener)
Delete the given key from the backing storage.
|
protected K |
doInsert(V value,
DefaultChunk.OnProgressUpdateListener onProgressUpdateListener)
Insert the given value into the backing storage.
|
protected QueryResult<V> |
doQuery(K key,
DefaultChunk.OnProgressUpdateListener onProgressUpdateListener)
Query the given key from the backing storage.
|
protected int |
doUpdate(K key,
V value,
DefaultChunk.OnProgressUpdateListener progressUpdateListener)
Update the given key in backing storage with the given value.
|
protected java.util.Collection<V> |
getValues()
Returns an unmodifiable collection of values from the backing map.
|
java.lang.String |
toString() |
addEventFactory, addEventFactory, addEventFactory, addEventFactory, delete, insert, query, setEventDispatcher, update
public VolatileChunk(VolatileChunk.KeyFactory<K,V> keyFactory)
keyFactory
- A KeyFactory used to create keys to insert objects under.public VolatileChunk(java.util.Map<K,V> map, VolatileChunk.KeyFactory<K,V> keyFactory)
This implementation uses the given Map directly for storage. Changes to this Chunk will be reflected in the given Map, and vice-versa.
map
- The Map to use as backing storage.keyFactory
- A KeyFactory used to create keys to insert objects under.protected K doInsert(V value, DefaultChunk.OnProgressUpdateListener onProgressUpdateListener) throws InsertException
doInsert
in class DefaultChunk<K,V>
value
- The value to be storedInsertException
protected QueryResult<V> doQuery(K key, DefaultChunk.OnProgressUpdateListener onProgressUpdateListener) throws QueryException
doQuery
in class DefaultChunk<K,V>
key
- The key to obtain the required valuesQueryException
protected int doUpdate(K key, V value, DefaultChunk.OnProgressUpdateListener progressUpdateListener) throws UpdateException
Some Chunk implementations might allow update of multiple values with a non-specific key. Not this one.
doUpdate
in class DefaultChunk<K,V>
key
- The key of the value to be updated.value
- The value to be stored.UpdateException
protected int doDelete(K key, DefaultChunk.OnProgressUpdateListener onProgressUpdateListener) throws DeleteException
Some Chunk implementations might allow update of multiple values with a non-specific key. Not this one.
doDelete
in class DefaultChunk<K,V>
key
- The key of the value to be deleted.DeleteException
public java.lang.String toString()
toString
in class java.lang.Object
protected java.util.Collection<V> getValues()
public void close() throws java.io.IOException
java.io.IOException