Package com.google.gwt.storage.client
Class StorageMap
Exposes the local/session
Storage
as a standard Map<String, String>
.
Experimental API: This API is still under development and is subject to change.
The following characteristics are associated with this Map:
- Mutable - All 'write' methods (
put(String, String)
,AbstractMap.putAll(Map)
,remove(Object)
,clear()
,Map.Entry.setValue(Object)
) operate as intended; - remove() on Iterators - All remove() operations on available
Iterators (from
AbstractMap.keySet()
,entrySet()
andAbstractMap.values()
) operate as intended; - No
null
values and keys - The Storage doesn't accept keys or values which arenull
; - String values and keys - All keys and values in this Map are String types.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,
V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
ConstructorDescriptionStorageMap
(Storage storage) Creates the Map with the specified Storage as data provider. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes all items from the Storage.boolean
containsKey
(Object key) Returnstrue
if the Storage contains the specified key,false
otherwise.boolean
containsValue
(Object value) Returnstrue
if the Storage contains the specified value,false
otherwise (or if the specified key isnull
).entrySet()
Returns a Set containing all entries of the Storage.Returns the value associated with the specified key in the Storage.Adds (or overwrites) a new key/value pair in the Storage.Removes the key/value pair from the Storage.int
size()
Returns the number of items in the Storage.Methods inherited from class java.util.AbstractMap
clone, equals, hashCode, isEmpty, keySet, putAll, toString, values
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
StorageMap
Creates the Map with the specified Storage as data provider.- Parameters:
storage
- a local/session Storage instance obtained by eitherStorage.getLocalStorageIfSupported()
orStorage.getSessionStorageIfSupported()
.
-
-
Method Details
-
clear
public void clear()Removes all items from the Storage. -
containsKey
Returnstrue
if the Storage contains the specified key,false
otherwise.- Specified by:
containsKey
in interfaceMap<String,
String> - Overrides:
containsKey
in classAbstractMap<String,
String>
-
containsValue
Returnstrue
if the Storage contains the specified value,false
otherwise (or if the specified key isnull
).- Specified by:
containsValue
in interfaceMap<String,
String> - Overrides:
containsValue
in classAbstractMap<String,
String>
-
entrySet
Returns a Set containing all entries of the Storage. -
get
Returns the value associated with the specified key in the Storage. -
put
Adds (or overwrites) a new key/value pair in the Storage. -
remove
Removes the key/value pair from the Storage. -
size
public int size()Returns the number of items in the Storage.
-