Example usage for com.google.gwt.storage.client StorageMap containsKey

List of usage examples for com.google.gwt.storage.client StorageMap containsKey

Introduction

In this page you can find the example usage for com.google.gwt.storage.client StorageMap containsKey.

Prototype

@Override
public boolean containsKey(Object key) 

Source Link

Document

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

Usage

From source file:com.data2semantics.yasgui.client.helpers.LocalStorageHelper.java

License:Open Source License

/**
 * Get value from local storage for given key. Appends current domain name to key, 
 * as we want different local storage when yasgui is loaded via iframe. 
 * //from   w w w.  ja  v a2  s  .  com
 * @param key
 * @return
 */
private static String getFromLocalStorage(String key) {
    StorageMap storageMap = getStorageMap();
    String domain = Helper.getCurrentHost();
    if (storageMap.containsKey(domain + "_" + key)) {
        return storageMap.get(domain + "_" + key);
    } else if (storageMap.containsKey(key)) {
        //for backwards compatability (i.e. the time when we didnt use the basedomain as part of the key)
        String value = storageMap.get(key);
        setInLocalStorage(key, value); //settings it again stores it under correct key with domain name
        storageMap.remove(key);//remove old key
        return value;
    }
    return null;
}

From source file:com.imaginedreal.mgwt.trafficflow.client.AppEntryPoint.java

License:Apache License

private void createLocalStorageDefaults() {
    Storage localStorage;//from w ww.j  a va2 s  .  com
    StorageMap storageMap;

    localStorage = Storage.getLocalStorageIfSupported();
    if (localStorage != null) {
        storageMap = new StorageMap(localStorage);
        if (!storageMap.containsKey("KEY_LAST_UPDATED")) {
            localStorage.setItem("KEY_LAST_UPDATED", "January 1, 1970 0:00 AM");
        }
        if (!storageMap.containsKey("KEY_CURRENT_MAP")) {
            localStorage.setItem("KEY_CURRENT_MAP", "seattle");
        }
        if (!storageMap.containsKey("KEY_SEATTLE_MAP_XY")) {
            localStorage.setItem("KEY_SEATTLE_MAP_XY", "-35,-1475");
        }
        if (!storageMap.containsKey("KEY_TACOMA_MAP_XY")) {
            localStorage.setItem("KEY_TACOMA_MAP_XY", "-475,-225");
        }
        if (!storageMap.containsKey("KEY_SHOW_CAMERAS")) {
            localStorage.setItem("KEY_SHOW_CAMERAS", "false");
        }
        if (!storageMap.containsKey("KEY_COLOR_STOPANDGO")) {
            localStorage.setItem("KEY_COLOR_STOPANDGO", "000000");
        }
        if (!storageMap.containsKey("KEY_COLOR_HEAVY")) {
            localStorage.setItem("KEY_COLOR_HEAVY", "ff0000");
        }
        if (!storageMap.containsKey("KEY_COLOR_MODERATE")) {
            localStorage.setItem("KEY_COLOR_MODERATE", "ffff00");
        }
        if (!storageMap.containsKey("KEY_COLOR_WIDEOPEN")) {
            localStorage.setItem("KEY_COLOR_WIDEOPEN", "00ff00");
        }
        if (!storageMap.containsKey("KEY_COLOR_NODATA")) {
            localStorage.setItem("KEY_COLOR_NODATA", "ffffff");
        }
        if (!storageMap.containsKey("KEY_COLOR_NOEQUIPMENT")) {
            localStorage.setItem("KEY_COLOR_NOEQUIPMENT", "808080");
        }
    }
}