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.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
Fields Modifier and Type Field Description 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
Constructors Modifier Constructor Description protected
StorageImpl()
This class can never be instantiated by itself.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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()
protected Storage
getStorageFromEvent(StorageEvent event)
Returns theStorage
object that was affected in the event.protected static void
handleStorageEvent(StorageEvent event)
Handles StorageEvents if aStorageEvent.Handler
is registered.protected static boolean
hasStorageEventHandlers()
Returnstrue
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.
-
-
-
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.Handler
is registered.
-
hasStorageEventHandlers
protected static boolean hasStorageEventHandlers()
Returnstrue
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
- eitherLOCAL_STORAGE
orSESSION_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_STORAGE
orSESSION_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
- eitherLOCAL_STORAGE
orSESSION_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_STORAGE
orSESSION_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
- eitherLOCAL_STORAGE
orSESSION_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
- eitherLOCAL_STORAGE
orSESSION_STORAGE
key
- 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 theStorage
object that was affected in the event.- Returns:
- the
Storage
object that was affected in the event.
-
removeStorageEventHandler0
protected void removeStorageEventHandler0()
-
-