public class StorageMap
extends java.util.AbstractMap<java.lang.String,java.lang.String>
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:
put(String, String),
AbstractMap.putAll(Map), remove(Object), clear(),
Entry#setValue(Object)) operate as intended;AbstractMap.keySet(), entrySet() and AbstractMap.values())
operate as intended;null values and keys - The Storage doesn't
accept keys or values which are null;| Constructor and Description |
|---|
StorageMap(Storage storage)
Creates the Map with the specified Storage as data provider.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all items from the Storage.
|
boolean |
containsKey(java.lang.Object key)
Returns
true if the Storage contains the specified key,
false otherwise. |
boolean |
containsValue(java.lang.Object value)
Returns
true if the Storage contains the specified value,
false otherwise (or if the specified key is null
). |
java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.String>> |
entrySet()
Returns a Set containing all entries of the Storage.
|
java.lang.String |
get(java.lang.Object key)
Returns the value associated with the specified key in the Storage.
|
java.lang.String |
put(java.lang.String key,
java.lang.String value)
Adds (or overwrites) a new key/value pair in the Storage.
|
java.lang.String |
remove(java.lang.Object key)
Removes the key/value pair from the Storage.
|
int |
size()
Returns the number of items in the Storage.
|
clone, equals, hashCode, isEmpty, keySet, putAll, toString, valuespublic StorageMap(Storage storage)
storage - a local/session Storage instance obtained by either
Storage.getLocalStorageIfSupported() or
Storage.getSessionStorageIfSupported().public void clear()
clear in interface java.util.Map<java.lang.String,java.lang.String>clear in class java.util.AbstractMap<java.lang.String,java.lang.String>Storage.clear()public boolean containsKey(java.lang.Object key)
true if the Storage contains the specified key,
false otherwise.containsKey in interface java.util.Map<java.lang.String,java.lang.String>containsKey in class java.util.AbstractMap<java.lang.String,java.lang.String>public boolean containsValue(java.lang.Object value)
true if the Storage contains the specified value,
false otherwise (or if the specified key is null
).containsValue in interface java.util.Map<java.lang.String,java.lang.String>containsValue in class java.util.AbstractMap<java.lang.String,java.lang.String>public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.String>> entrySet()
entrySet in interface java.util.Map<java.lang.String,java.lang.String>entrySet in class java.util.AbstractMap<java.lang.String,java.lang.String>public java.lang.String get(java.lang.Object key)
get in interface java.util.Map<java.lang.String,java.lang.String>get in class java.util.AbstractMap<java.lang.String,java.lang.String>key - the key identifying the valueStorage.getItem(String)public java.lang.String put(java.lang.String key,
java.lang.String value)
put in interface java.util.Map<java.lang.String,java.lang.String>put in class java.util.AbstractMap<java.lang.String,java.lang.String>key - the key identifying the value (not null)value - the value associated with the key (not null)Storage.setItem(String, String)public java.lang.String remove(java.lang.Object key)
remove in interface java.util.Map<java.lang.String,java.lang.String>remove in class java.util.AbstractMap<java.lang.String,java.lang.String>key - the key identifying the item to removenull if the key
was not present in the StorageStorage.removeItem(String)public int size()
size in interface java.util.Map<java.lang.String,java.lang.String>size in class java.util.AbstractMap<java.lang.String,java.lang.String>Storage.getLength()