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
nullvalues 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
ConstructorsConstructorDescriptionStorageMap(Storage storage) Creates the Map with the specified Storage as data provider. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all items from the Storage.booleancontainsKey(Object key) Returnstrueif the Storage contains the specified key,falseotherwise.booleancontainsValue(Object value) Returnstrueif the Storage contains the specified value,falseotherwise (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.intsize()Returns the number of items in the Storage.Methods inherited from class java.util.AbstractMap
clone, equals, hashCode, isEmpty, keySet, putAll, toString, valuesMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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
Returnstrueif the Storage contains the specified key,falseotherwise.- Specified by:
containsKeyin interfaceMap<String,String> - Overrides:
containsKeyin classAbstractMap<String,String>
-
containsValue
Returnstrueif the Storage contains the specified value,falseotherwise (or if the specified key isnull).- Specified by:
containsValuein interfaceMap<String,String> - Overrides:
containsValuein 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.
-