Overview | Package | Class | Use | Deprecated | Help
| GWT 2.7.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.google.gwt.storage.client
Class StorageMap

    java.lang.Object
      java.util.AbstractMap<java.lang.String,java.lang.String>
          com.google.gwt.storage.client.StorageMap

All Implemented Interfaces:
  java.util.Map<java.lang.String,java.lang.String>

    public class StorageMap

extends java.util.AbstractMap<java.lang.String,java.lang.String>

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:

1. Mutable - All 'write' methods (`put(String, String)`, `AbstractMap.putAll(Map)`, `remove(Object)`, `clear()`, `Entry#setValue(Object)`) operate as intended;
2. remove() on Iterators - All remove() operations on available Iterators (from `AbstractMap.keySet()`, `entrySet()` and `AbstractMap.values()`) operate as intended;
3. No `null` values and keys - The Storage doesn't accept keys or values which are `null`;
4. 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
`java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>`

Nested classes/interfaces inherited from interface java.util.Map
`java.util.Map.Entry<K,V>`

Constructor Summary
`StorageMap(Storage storage)` Creates the Map with the specified Storage as data provider.

Method Summary
`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.

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`

Constructor Detail

### StorageMap

    public StorageMap(Storage storage)

  Creates the Map with the specified Storage as data provider.

  Parameters:
    `storage` - a local/session Storage instance obtained by either `Storage.getLocalStorageIfSupported()` or `Storage.getSessionStorageIfSupported()`.

Method Detail

### clear

    public void clear()

  Removes all items from the Storage.

  Specified by:
    `clear` in interface `java.util.Map<java.lang.String,java.lang.String>`
  Overrides:
    `clear` in class `java.util.AbstractMap<java.lang.String,java.lang.String>`
  See Also:
    `Storage.clear()`

### containsKey

    public boolean containsKey(java.lang.Object key)

  Returns `true` if the Storage contains the specified key, `false` otherwise.

  Specified by:
    `containsKey` in interface `java.util.Map<java.lang.String,java.lang.String>`
  Overrides:
    `containsKey` in class `java.util.AbstractMap<java.lang.String,java.lang.String>`

### containsValue

    public boolean containsValue(java.lang.Object value)

  Returns `true` if the Storage contains the specified value, `false` otherwise (or if the specified key is `null` ).

  Specified by:
    `containsValue` in interface `java.util.Map<java.lang.String,java.lang.String>`
  Overrides:
    `containsValue` in class `java.util.AbstractMap<java.lang.String,java.lang.String>`

### entrySet

    public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.String>> entrySet()

  Returns a Set containing all entries of the Storage.

  Specified by:
    `entrySet` in interface `java.util.Map<java.lang.String,java.lang.String>`
  Specified by:
    `entrySet` in class `java.util.AbstractMap<java.lang.String,java.lang.String>`

### get

    public java.lang.String get(java.lang.Object key)

  Returns the value associated with the specified key in the Storage.

  Specified by:
    `get` in interface `java.util.Map<java.lang.String,java.lang.String>`
  Overrides:
    `get` in class `java.util.AbstractMap<java.lang.String,java.lang.String>`
  Parameters:
    `key` - the key identifying the value
  See Also:
    `Storage.getItem(String)`

### put

    public java.lang.String put(java.lang.String key,
                                java.lang.String value)

  Adds (or overwrites) a new key/value pair in the Storage.

  Specified by:
    `put` in interface `java.util.Map<java.lang.String,java.lang.String>`
  Overrides:
    `put` in class `java.util.AbstractMap<java.lang.String,java.lang.String>`
  Parameters:
    `key` - the key identifying the value (not `null`)
    `value` - the value associated with the key (not `null`)
  See Also:
    `Storage.setItem(String, String)`

### remove

    public java.lang.String remove(java.lang.Object key)

  Removes the key/value pair from the Storage.

  Specified by:
    `remove` in interface `java.util.Map<java.lang.String,java.lang.String>`
  Overrides:
    `remove` in class `java.util.AbstractMap<java.lang.String,java.lang.String>`
  Parameters:
    `key` - the key identifying the item to remove
  Returns:
    the value associated with the key - `null` if the key was not present in the Storage
  See Also:
    `Storage.removeItem(String)`

### size

    public int size()

  Returns the number of items in the Storage.

  Specified by:
    `size` in interface `java.util.Map<java.lang.String,java.lang.String>`
  Overrides:
    `size` in class `java.util.AbstractMap<java.lang.String,java.lang.String>`
  Returns:
    the number of items
  See Also:
    `Storage.getLength()`

Overview | Package | Class | Use | Deprecated | Help
| GWT 2.7.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD