public abstract class TemplateObjectStore<T extends Serializable> extends AbstractObjectStoreSupport<T>
ObjectStore
implementations so that it's easier to conform to the contract.
ObjectStore
implementations are not required to extend this class, but it is recommended to do so
in order to help guaranteeing that implementations implement the contract correctly.
Constructor and Description |
---|
TemplateObjectStore() |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(String key)
Check whether this store already contains a value for the given
key |
protected abstract boolean |
doContains(String key)
Template method for
contains(String) . |
protected abstract T |
doRemove(String key)
Template method for
remove(String) (String, Serializable)}. |
protected abstract T |
doRetrieve(String key)
Template method for
store(String, Serializable) . |
protected abstract void |
doStore(String key,
T value)
Template method for
store(String, Serializable) . |
T |
remove(String key)
Remove the object with the given
key |
T |
retrieve(String key)
* Retrieve the object stored under the given
key |
void |
store(String key,
T value)
Store the given Object.
|
validateKey, validatePresentKey
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
allKeys, clear, close, isPersistent, open, retrieveAll
public boolean contains(String key) throws ObjectStoreException
key
key
- the identifier of the object to checktrue
if the key is stored or false
no value was stored for the key.ObjectStoreException
- if the given key is null
.ObjectStoreNotAvailableException
- if any implementation-specific error occured, e.g. when the store is not availableprotected abstract boolean doContains(String key) throws ObjectStoreException
contains(String)
. Implement this method assuming that
the key
is already valid
ObjectStoreException
public void store(String key, T value) throws ObjectStoreException
key
- the identifier for value
value
- the Object to store with key
ObjectStoreException
- if the given key cannot be stored or is null
.ObjectStoreNotAvailableException
- if the store is not available or any other implementation-specific error occured.ObjectAlreadyExistsException
- if an attempt is made to store an object for a key that already has an object
associated.protected abstract void doStore(String key, T value) throws ObjectStoreException
store(String, Serializable)
. Implement this method assuming that the key is valid
and that contains(String)
has already been invoked to verify that the key doesn't already exists
in this store.
ObjectStoreException
public T retrieve(String key) throws ObjectStoreException
key
key
- the identifier of the object to retrieve.ObjectDoesNotExistException
.ObjectStoreException
- if the given key is null
.ObjectStoreNotAvailableException
- if the store is not available or any other implementation-specific error occured.ObjectDoesNotExistException
- if no value for the given key was previously stored.protected abstract T doRetrieve(String key) throws ObjectStoreException
store(String, Serializable)
. Implement this method assuming that the key is valid
and that contains(String)
has already been invoked to verify that the key actually exists in this store.
ObjectStoreException
public T remove(String key) throws ObjectStoreException
key
key
- the identifier of the object to remove.ObjectStoreException
- if the given key is null
or if the store is not available or any other
implementation-specific error occuredObjectDoesNotExistException
- if no value for the given key was previously stored.protected abstract T doRemove(String key) throws ObjectStoreException
remove(String)
(String, Serializable)}. Implement this method assuming that the key is valid
and that contains(String)
has already been invoked to verify that the key actually exists in this store.
ObjectStoreException
Copyright © 2018. All rights reserved.