V
- serializable type of the mapped valuepublic class AbstractMemoryDataStore<V extends java.io.Serializable> extends AbstractDataStore<V>
Modifier and Type | Field and Description |
---|---|
protected java.util.HashMap<java.lang.String,byte[]> |
keyValueMap
Data store map from the key to the value.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractMemoryDataStore(DataStoreFactory dataStoreFactory,
java.lang.String id) |
Modifier and Type | Method and Description |
---|---|
DataStore<V> |
clear()
Deletes all of the stored keys and values.
|
boolean |
containsKey(java.lang.String key)
Returns whether the store contains the given key.
|
boolean |
containsValue(V value)
Returns whether the store contains the given value.
|
DataStore<V> |
delete(java.lang.String key)
Deletes the stored key and value based on the given key, or ignored if the key doesn't already
exist.
|
V |
get(java.lang.String key)
Returns the stored value for the given key or
null if not found. |
boolean |
isEmpty()
Returns whether there are any stored keys.
|
java.util.Set<java.lang.String> |
keySet()
Returns the unmodifiable set of all stored keys.
|
void |
save()
Persist the key-value map into storage at the end of
set(java.lang.String, V) , delete(String) , and
clear() . |
DataStore<V> |
set(java.lang.String key,
V value)
Stores the given value for the given key (replacing any existing value).
|
int |
size()
Returns the number of stored keys.
|
java.lang.String |
toString() |
java.util.Collection<V> |
values()
Returns the unmodifiable collection of all stored values.
|
getDataStoreFactory, getId
protected java.util.HashMap<java.lang.String,byte[]> keyValueMap
protected AbstractMemoryDataStore(DataStoreFactory dataStoreFactory, java.lang.String id)
dataStoreFactory
- data store factoryid
- data store IDpublic final java.util.Set<java.lang.String> keySet() throws java.io.IOException
DataStore
Order of the keys is not specified.
java.io.IOException
public final java.util.Collection<V> values() throws java.io.IOException
DataStore
java.io.IOException
public final V get(java.lang.String key) throws java.io.IOException
DataStore
null
if not found.key
- key or null
for null
resultjava.io.IOException
public final DataStore<V> set(java.lang.String key, V value) throws java.io.IOException
DataStore
key
- keyvalue
- value objectjava.io.IOException
public DataStore<V> delete(java.lang.String key) throws java.io.IOException
DataStore
key
- key or null
to ignorejava.io.IOException
public final DataStore<V> clear() throws java.io.IOException
DataStore
java.io.IOException
public boolean containsKey(java.lang.String key) throws java.io.IOException
AbstractDataStore
Default implementation is to call DataStore.get(String)
and check if it is null
.
containsKey
in interface DataStore<V extends java.io.Serializable>
containsKey
in class AbstractDataStore<V extends java.io.Serializable>
java.io.IOException
public boolean containsValue(V value) throws java.io.IOException
AbstractDataStore
Default implementation is to call Collection.contains(Object)
on DataStore.values()
.
containsValue
in interface DataStore<V extends java.io.Serializable>
containsValue
in class AbstractDataStore<V extends java.io.Serializable>
java.io.IOException
public boolean isEmpty() throws java.io.IOException
AbstractDataStore
Default implementation is to check if AbstractDataStore.size()
is 0
.
public int size() throws java.io.IOException
AbstractDataStore
Default implementation is to call Set.size()
on DataStore.keySet()
.
public void save() throws java.io.IOException
set(java.lang.String, V)
, delete(String)
, and
clear()
.java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2011-2018 Google. All Rights Reserved.