K - The type of keys on this ChunkV - The type of values on this Chunkpublic abstract class DefaultChunk<K,V> extends java.lang.Object implements Chunk<K,V>
| Modifier and Type | Class and Description |
|---|---|
static interface |
DefaultChunk.OnProgressUpdateListener |
Chunk.EmptyChunk<K,V>| Constructor and Description |
|---|
DefaultChunk() |
| Modifier and Type | Method and Description |
|---|---|
void |
addEventFactory(DeleteEventFactory deleteEventFactory)
Add an DeleteEventFactory to use when generating insert events.
|
void |
addEventFactory(InsertEventFactory insertEventFactory)
Add an InsertEventFactory to use when generating insert events.
|
void |
addEventFactory(QueryEventFactory queryEventFactory)
Add an QueryEventFactory to use when generating insert events.
|
void |
addEventFactory(UpdateEventFactory updateEventFactory)
Add an UpdateEventFactory to use when generating insert events.
|
int |
delete(K key,
DeleteEventFactory<K>... customEventFactories)
Delete a key from this Chunk, returning the number of values deleted.
|
protected abstract int |
doDelete(K key,
DefaultChunk.OnProgressUpdateListener onProgressUpdateListener)
Update the value at the given key in the Chunk.
|
protected abstract K |
doInsert(V value,
DefaultChunk.OnProgressUpdateListener onProgressUpdateListener)
Insert a value to the Chunk.
|
protected abstract QueryResult |
doQuery(K key,
DefaultChunk.OnProgressUpdateListener onProgressUpdateListener)
Query values from the Chunk.
|
protected abstract int |
doUpdate(K key,
V value,
DefaultChunk.OnProgressUpdateListener progressUpdateListener)
Update the value at the given key in the Chunk.
|
K |
insert(V value,
InsertEventFactory<K,V>... customEventFactories)
Insert a value into this Chunk, returning the key at which the get can be retrieved later.
|
QueryResult<V> |
query(K key,
QueryEventFactory<K,V>... customEventFactories)
Query a key at this Chunk, returning a QueryResult contianing the queried values.
|
void |
setEventDispatcher(EventDispatcher eventDispatcher)
Set the EventDispatcher on this Chunk.
|
int |
update(K key,
V value,
UpdateEventFactory<K,V>... customEventFactories)
Update a key with a value at this Chunk, returning the number of values updated.
|
public K insert(V value, InsertEventFactory<K,V>... customEventFactories) throws InsertException
insert in interface Chunk<K,V>value - the value to insertcustomEventFactories - optional InsertEventFactories used to generate events for this operation.InsertExceptionprotected abstract K doInsert(V value, DefaultChunk.OnProgressUpdateListener onProgressUpdateListener) throws InsertException
This method should be overriden by subclasses in order to store the value in an implementation specific manner. There is no requirement to send any events from this method.
The semantics of this method is implementation specific. That is, some implementations may choose to throw an InsertException if the given key already exists in the Chunk, whilst other implementations may wish to replace the value in that case.
value - The value to be storedonProgressUpdateListener - InsertExceptionpublic QueryResult<V> query(K key, QueryEventFactory<K,V>... customEventFactories) throws QueryException
query in interface Chunk<K,V>key - the key to querycustomEventFactories - optional QueryEventFactories used to generate events for this operation.QueryExceptionprotected abstract QueryResult doQuery(K key, DefaultChunk.OnProgressUpdateListener onProgressUpdateListener) throws QueryException
This method should be overriden by subclasses in order to obtain the values in an implementation specific manner. There is no requirement to send any events from this method.
key - The key to obtain the required valuesQueryExceptionpublic int update(K key, V value, UpdateEventFactory<K,V>... customEventFactories) throws UpdateException
update in interface Chunk<K,V>key - the key to updatevalue - the value to updatecustomEventFactories - optional UpdateEventFactories used to generate events for this operation.UpdateExceptionprotected abstract int doUpdate(K key, V value, DefaultChunk.OnProgressUpdateListener progressUpdateListener) throws UpdateException
This method should be overriden by subclasses in order to update the value in an implementation specific manner. There is no requirement to send any events from this method.
The semantics of this method is implementation specific. That is, some implementations may choose to throw an UpdateException if the given key does not exist in the Chunk, whilst other implementations may wish to insert the value in that case.
key - The key of the value to be updated.value - The value to be stored.progressUpdateListener - UpdateExceptionpublic int delete(K key, DeleteEventFactory<K>... customEventFactories) throws DeleteException
delete in interface Chunk<K,V>key - the key to deletecustomEventFactories - optional DeleteEventFactories used to generate events for this operation.DeleteExceptionprotected abstract int doDelete(K key, DefaultChunk.OnProgressUpdateListener onProgressUpdateListener) throws DeleteException
This method should be overriden by subclasses in order to update the value in an implementation specific manner. There is no requirement to send any events from this method.
The semantics of this method is implementation specific. That is, some implementations may choose to throw an DeleteException if the given key does not exist in the Chunk, whilst other implementations may wish to do nothing.
key - The key of the value to be deleted.onProgressUpdateListener - DeleteExceptionpublic void setEventDispatcher(EventDispatcher eventDispatcher)
Operations on this Chunk will dispatch events to the given EventDispatcher. The events dispatched are generated by EventFactories that are either previously added to this Chunk, or else passed in as a parameter to the Chunk operation.
setEventDispatcher in interface Chunk<K,V>eventDispatcher - The EventDispatcher to be used for events on this Chunk.public void addEventFactory(InsertEventFactory insertEventFactory)
addEventFactory in interface Chunk<K,V>public void addEventFactory(QueryEventFactory queryEventFactory)
addEventFactory in interface Chunk<K,V>public void addEventFactory(UpdateEventFactory updateEventFactory)
addEventFactory in interface Chunk<K,V>public void addEventFactory(DeleteEventFactory deleteEventFactory)
addEventFactory in interface Chunk<K,V>