Package com.google.gwt.storage.client
Class StorageImpl
- java.lang.Object
-
- com.google.gwt.storage.client.StorageImpl
-
- Direct Known Subclasses:
StorageImplNonNativeEvents
class StorageImpl extends java.lang.ObjectThis 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
Fields Modifier and Type Field Description protected static JavaScriptObjectjsHandlerstatic java.lang.StringLOCAL_STORAGEstatic java.lang.StringSESSION_STORAGEprotected static java.util.List<StorageEvent.Handler>storageEventHandlers
-
Constructor Summary
Constructors Modifier Constructor Description protectedStorageImpl()This class can never be instantiated by itself.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description HandlerRegistrationaddStorageEventHandler(StorageEvent.Handler handler)Registers an event handler for StorageEvents.protected voidaddStorageEventHandler0()voidclear(java.lang.String storage)Removes all items in the Storage.java.lang.StringgetItem(java.lang.String storage, java.lang.String key)Returns the item in the Storage associated with the specified key.intgetLength(java.lang.String storage)Returns the number of items in this Storage.protected java.util.List<StorageEvent.Handler>getStorageEventHandlers()protected StoragegetStorageFromEvent(StorageEvent event)Returns theStorageobject that was affected in the event.protected static voidhandleStorageEvent(StorageEvent event)Handles StorageEvents if aStorageEvent.Handleris registered.protected static booleanhasStorageEventHandlers()Returnstrueif at least one StorageEvent handler is registered,falseotherwise.java.lang.Stringkey(java.lang.String storage, int index)Returns the key at the specified index.voidremoveItem(java.lang.String storage, java.lang.String key)Removes the item in the Storage associated with the specified key.voidremoveStorageEventHandler(StorageEvent.Handler handler)De-registers an event handler for StorageEvents.protected voidremoveStorageEventHandler0()voidsetItem(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.
-
-
-
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
-
-
Method Detail
-
handleStorageEvent
protected static final void handleStorageEvent(StorageEvent event)
Handles StorageEvents if aStorageEvent.Handleris registered.
-
hasStorageEventHandlers
protected static boolean hasStorageEventHandlers()
Returnstrueif at least one StorageEvent handler is registered,falseotherwise.
-
addStorageEventHandler
public HandlerRegistration addStorageEventHandler(StorageEvent.Handler handler)
Registers an event handler for StorageEvents.- Parameters:
handler-- Returns:
HandlerRegistrationused 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- eitherLOCAL_STORAGEorSESSION_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- eitherLOCAL_STORAGEorSESSION_STORAGEkey- 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- eitherLOCAL_STORAGEorSESSION_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- eitherLOCAL_STORAGEorSESSION_STORAGEindex- 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- eitherLOCAL_STORAGEorSESSION_STORAGEkey- 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- eitherLOCAL_STORAGEorSESSION_STORAGEkey- the key to a value in the Storagedata- 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()
-
getStorageFromEvent
protected Storage getStorageFromEvent(StorageEvent event)
Returns theStorageobject that was affected in the event.- Returns:
- the
Storageobject that was affected in the event.
-
removeStorageEventHandler0
protected void removeStorageEventHandler0()
-
-