GWT 2.7.0

com.google.gwt.storage.client
Class StorageImpl

java.lang.Object
  extended by com.google.gwt.storage.client.StorageImpl
Direct Known Subclasses:
StorageImplNonNativeEvents

 class StorageImpl
extends java.lang.Object

This is the HTML5 Storage implementation according to the standard recommendation.

Never use this class directly, instead use Storage.

See Also:
W3C Web Storage - Storage

Field Summary
protected static JavaScriptObject jsHandler
           
static java.lang.String LOCAL_STORAGE
           
static java.lang.String SESSION_STORAGE
           
protected static java.util.List<StorageEvent.Handler> storageEventHandlers
           
 
Constructor Summary
protected StorageImpl()
          This class can never be instantiated by itself.
 
Method Summary
 HandlerRegistration addStorageEventHandler(StorageEvent.Handler handler)
          Registers an event handler for StorageEvents.
protected  void addStorageEventHandler0()
           
 void clear(java.lang.String storage)
          Removes all items in the Storage.
 java.lang.String getItem(java.lang.String storage, java.lang.String key)
          Returns the item in the Storage associated with the specified key.
 int getLength(java.lang.String storage)
          Returns the number of items in this Storage.
protected  java.util.List<StorageEvent.Handler> getStorageEventHandlers()
          Returns the List of StorageEvent.Handlers registered, which is never null.
protected  Storage getStorageFromEvent(StorageEvent event)
          Returns the Storage object that was affected in the event.
protected static void handleStorageEvent(StorageEvent event)
          Handles StorageEvents if a StorageEvent.Handler is registered.
protected static boolean hasStorageEventHandlers()
          Returns true if at least one StorageEvent handler is registered, false otherwise.
 java.lang.String key(java.lang.String storage, int index)
          Returns the key at the specified index.
 void removeItem(java.lang.String storage, java.lang.String key)
          Removes the item in the Storage associated with the specified key.
 void removeStorageEventHandler(StorageEvent.Handler handler)
          De-registers an event handler for StorageEvents.
protected  void removeStorageEventHandler0()
           
 void setItem(java.lang.String storage, java.lang.String key, java.lang.String data)
          Sets the value in the Storage associated with the specified key to the specified data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCAL_STORAGE

public static final java.lang.String LOCAL_STORAGE
See Also:
Constant Field Values

SESSION_STORAGE

public static final java.lang.String SESSION_STORAGE
See Also:
Constant Field Values

storageEventHandlers

protected static java.util.List<StorageEvent.Handler> storageEventHandlers

jsHandler

protected static JavaScriptObject jsHandler
Constructor Detail

StorageImpl

protected StorageImpl()
This class can never be instantiated by itself.

Method Detail

handleStorageEvent

protected static final void handleStorageEvent(StorageEvent event)
Handles StorageEvents if a StorageEvent.Handler is registered.


hasStorageEventHandlers

protected static boolean hasStorageEventHandlers()
Returns true if at least one StorageEvent handler is registered, false otherwise.


addStorageEventHandler

public HandlerRegistration addStorageEventHandler(StorageEvent.Handler handler)
Registers an event handler for StorageEvents.

Parameters:
handler -
Returns:
HandlerRegistration used to remove this handler
See Also:
W3C Web Storage - the storage event

clear

public void clear(java.lang.String storage)
Removes all items in the Storage.

Parameters:
storage - either LOCAL_STORAGE or SESSION_STORAGE
See Also:
W3C Web Storage - Storage.clear()

getItem

public java.lang.String getItem(java.lang.String storage,
                                java.lang.String key)
Returns the item in the Storage associated with the specified key.

Parameters:
storage - either LOCAL_STORAGE or SESSION_STORAGE
key - the key to a value in the Storage
Returns:
the value associated with the given key
See Also:
W3C Web Storage - Storage.getItem(k)

getLength

public int getLength(java.lang.String storage)
Returns the number of items in this Storage.

Parameters:
storage - either LOCAL_STORAGE or SESSION_STORAGE
Returns:
number of items in this Storage
See Also:
W3C Web Storage - Storage.length()

key

public java.lang.String key(java.lang.String storage,
                            int index)
Returns the key at the specified index.

Parameters:
storage - either LOCAL_STORAGE or SESSION_STORAGE
index - the index of the key
Returns:
the key at the specified index in this Storage
See Also:
W3C Web Storage - Storage.key(n)

removeItem

public void removeItem(java.lang.String storage,
                       java.lang.String key)
Removes the item in the Storage associated with the specified key.

Parameters:
storage - either LOCAL_STORAGE or SESSION_STORAGE
key - the key to a value in the Storage
See Also:
W3C Web Storage - Storage.removeItem(k)

removeStorageEventHandler

public void removeStorageEventHandler(StorageEvent.Handler handler)
De-registers an event handler for StorageEvents.

Parameters:
handler -
See Also:
W3C Web Storage - the storage event

setItem

public void setItem(java.lang.String storage,
                    java.lang.String key,
                    java.lang.String data)
Sets the value in the Storage associated with the specified key to the specified data.

Parameters:
storage - either LOCAL_STORAGE or SESSION_STORAGE
key - the key to a value in the Storage
data - the value associated with the key
See Also:
W3C Web Storage - Storage.setItem(k,v)

addStorageEventHandler0

protected void addStorageEventHandler0()

getStorageEventHandlers

protected java.util.List<StorageEvent.Handler> getStorageEventHandlers()
Returns the List of StorageEvent.Handlers registered, which is never null.


getStorageFromEvent

protected Storage getStorageFromEvent(StorageEvent event)
Returns the Storage object that was affected in the event.

Returns:
the Storage object that was affected in the event.

removeStorageEventHandler0

protected void removeStorageEventHandler0()

GWT 2.7.0