当前位置: 首页>>代码示例>>Java>>正文


Java Storage.getSessionStorageIfSupported方法代码示例

本文整理汇总了Java中com.google.gwt.storage.client.Storage.getSessionStorageIfSupported方法的典型用法代码示例。如果您正苦于以下问题:Java Storage.getSessionStorageIfSupported方法的具体用法?Java Storage.getSessionStorageIfSupported怎么用?Java Storage.getSessionStorageIfSupported使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.storage.client.Storage的用法示例。


在下文中一共展示了Storage.getSessionStorageIfSupported方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: get

import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
public static String get(String prefname) {
    String value = null;
    // check browser session storage
    Storage sessionStorage = Storage.getSessionStorageIfSupported();
    if (sessionStorage != null) {
        value = sessionStorage.getItem(PREFIX+prefname);
    }

    // check browser local storage
    if (value == null) {
        Storage localStorage = Storage.getLocalStorageIfSupported();
        if (localStorage != null) {
            value = localStorage.getItem(PREFIX+prefname);
        }
    }

    // check map
    if (value==null) {
        value = localPrefMap.get(prefname);
    }
    return value;
}
 
开发者ID:lsst,项目名称:firefly,代码行数:23,代码来源:Preferences.java

示例2: getSessionStorage

import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
/**
 * Returns a Session Storage.
 *
 * @return the sessionStorage instance, or <code>null</code> if Web Storage is NOT supported.
 */
public static StorageExt getSessionStorage() {
  if (sessionStorage == null && Storage.isSessionStorageSupported()) {
    sessionStorage = new StorageExt(Storage.getSessionStorageIfSupported());
  }
  return sessionStorage;
}
 
开发者ID:seanchenxi,项目名称:gwt-storage,代码行数:12,代码来源:StorageExt.java

示例3: set

import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
public static void set(String prefname, String prefvalue, boolean sessionScope) {

       if (sessionScope) {
            // put preference into session storage, if available
            // otherwise into local static map
            Storage sessionStorage = Storage.getSessionStorageIfSupported();
            if (sessionStorage != null) {
                //oldvalue = sessionStorage.getItem(PREFIX+prefname);
                if (prefvalue == null) {
                    sessionStorage.removeItem(PREFIX+prefname);
                } else {
                    sessionStorage.setItem(PREFIX+prefname, prefvalue);
                }
            } else {
                //oldvalue =  localPrefMap.get(prefname);
                localPrefMap.put(prefname, prefvalue);
            }
        }

        else {
            // check browser local storage
            Storage localStorage = Storage.getLocalStorageIfSupported();
            String oldvalue;
            if (localStorage != null) {
                oldvalue = localStorage.getItem(PREFIX+prefname);
                if (prefvalue == null) {
                    localStorage.removeItem(PREFIX+prefname);
                } else {
                    localStorage.setItem(PREFIX+prefname, prefvalue);
                }
            } else {
                oldvalue =  localPrefMap.get(prefname);
                localPrefMap.put(prefname, prefvalue);
            }
           if (notBulkUpdate && loginManager != null && loginManager.isLoggedIn()) {
               if ((prefvalue != null && !prefvalue.equals(oldvalue)) ||
                       (oldvalue != null && !oldvalue.equals(prefvalue))) {
                   // logged in user - also put preferences to db
                   loginManager.setPreference(prefname, prefvalue);
               }
           }
       }

        // no need to fire event
        // fire event if preference value has changed 
        //if ((prefvalue != null && !prefvalue.equals(oldvalue)) ||
        //        (oldvalue != null && !oldvalue.equals(prefvalue))) {
        //    HashMap<String,String> prefmap = new HashMap<String,String>(1);
        //    prefmap.put(prefname,prefvalue);
        //    WebEventManager.getAppEvManager().fireEvent(new WebEvent(Preferences.class, Name.PREFERENCE_UPDATE, prefmap));
        //}
    }
 
开发者ID:lsst,项目名称:firefly,代码行数:53,代码来源:Preferences.java

示例4: StorageBackend

import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
StorageBackend() {
  storageBackend =
      (Storage.isLocalStorageSupported())
          ? Storage.getLocalStorageIfSupported()
          : Storage.getSessionStorageIfSupported();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:7,代码来源:LocalComments.java


注:本文中的com.google.gwt.storage.client.Storage.getSessionStorageIfSupported方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。