本文整理汇总了Java中com.google.gwt.storage.client.Storage.getItem方法的典型用法代码示例。如果您正苦于以下问题:Java Storage.getItem方法的具体用法?Java Storage.getItem怎么用?Java Storage.getItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.storage.client.Storage
的用法示例。
在下文中一共展示了Storage.getItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JsListStorage
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
public JsListStorage(String prefix, Storage storage) {
this.storage = storage;
this.prefix = prefix;
String indexData = storage.getItem("list_" + prefix + "_index");
if (indexData != null) {
try {
byte[] data = fromBase64(indexData);
DataInput dataInput = new DataInput(data, 0, data.length);
int count = dataInput.readInt();
for (int i = 0; i < count; i++) {
long id = dataInput.readLong();
long order = dataInput.readLong();
index.add(new Index(id, order));
}
} catch (Exception e) {
e.printStackTrace();
}
}
updateIndex();
}
示例2: JsKeyValueStorage
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
public JsKeyValueStorage(String prefix, Storage storage) {
this.storage = storage;
this.prefix = prefix;
try {
String index = storage.getItem("kv_" + prefix + "_index");
if (index != null) {
byte[] data = fromBase64(index);
DataInput dataInput = new DataInput(data, 0, data.length);
int count = dataInput.readInt();
for (int i = 0; i < count; i++) {
items.add(dataInput.readLong());
}
}
} catch (Exception e) {
Log.e(TAG, e);
}
}
示例3: JsListStorage
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
public JsListStorage(String prefix, Storage storage) {
this.storage = storage;
this.prefix = prefix;
String indexData = storage.getItem("list_" + prefix + "_index");
if (indexData != null) {
try {
byte[] data = fromBase64(indexData);
DataInput dataInput = new DataInput(data, 0, data.length);
int count = dataInput.readInt();
for (int i = 0; i < count; i++) {
long id = dataInput.readLong();
long order = dataInput.readLong();
index.add(new Index(id, order));
}
} catch (Exception e) {
Log.e(TAG, e);
}
}
updateIndex();
}
示例4: 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;
}
示例5: getSavedItems
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private JsoArray<Entry> getSavedItems() {
Storage storage = getStorage();
if (storage != null) {
String data = storage.getItem(SAVED_ITEMS);
JsoArray<Entry> list = null;
if (data != null) {
list = JsonUtils.safeEval(data);
} else {
list = (JsoArray<Entry>) JavaScriptObject.createArray();
}
return list;
} else {
return (JsoArray<Entry>) JavaScriptObject.createArray();
}
}
示例6: renameLocalStorage
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
protected void renameLocalStorage() {
String name = getName();
if (name != null) {
final Storage s = getStorage();
if (s != null) {
final int i = storageList.getSelectedIndex();
if (i < 0) {
ApplicationPanel.showErrorDialog("Select a Storage entry");
} else {
String key = storageList.getValue(i);
String value = s.getItem(key);
storageList.removeItem(i);
s.removeItem(key);
key = STORAGE_KEY + name;
s.setItem(key, value);
storageList.insertItem(name, key, i);
}
}
}
}
示例7: restoreLocalStorage
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
protected void restoreLocalStorage() {
final Storage s = getStorage();
if (s != null) {
final int i = storageList.getSelectedIndex();
if (i < 0) {
ApplicationPanel.showErrorDialog("Select a Storage entry");
} else {
String key = storageList.getValue(i);
String value = s.getItem(key);
if (value == null)
value = "";
final String json = value;
if (listener != null) {
FormData data = JsonUtil.parseFormData(json);
listener.setFormData(data);
}
}
}
}
示例8: JsKeyValueStorage
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
public JsKeyValueStorage(String prefix, Storage storage) {
this.storage = storage;
this.prefix = prefix;
try {
String index = storage.getItem("kv_" + prefix + "_index");
if (index != null) {
byte[] data = fromBase64(index);
DataInput dataInput = new DataInput(data, 0, data.length);
int count = dataInput.readInt();
for (int i = 0; i < count; i++) {
items.add(dataInput.readLong());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例9: JsIndexStorage
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
public JsIndexStorage(String prefix, Storage storage) {
this.storage = storage;
this.prefix = prefix;
try {
String index = storage.getItem("index_" + prefix + "_index");
if (index != null) {
byte[] data = fromBase64(index);
DataInput dataInput = new DataInput(data, 0, data.length);
int count = dataInput.readInt();
for (int i = 0; i < count; i++) {
long id = dataInput.readLong();
long value = dataInput.readLong();
items.add(new Item(id, value));
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例10: createLocalId
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
public final static int createLocalId()
{
Storage storage = Storage.getLocalStorageIfSupported();
if( storage == null )
return 0;
int increment = 0;
String incrementString = storage.getItem( LOCAL_CURRENT_ID_INCREMENT );
try
{
increment = Integer.parseInt( incrementString );
}
catch( Exception e )
{
}
increment += 1;
storage.setItem( LOCAL_CURRENT_ID_INCREMENT, increment + "" );
return -increment;
}
示例11: getPreferences
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
@Override
public JSONObject getPreferences(String name)
{
Storage localStorage = Storage.getLocalStorageIfSupported();
if (localStorage == null)
return new JSONObject();
try
{
String json = localStorage.getItem(name);
return JSON.parse(json == null ? "{}" : json);
}
catch (ParseException e)
{
return new JSONObject();
}
}
示例12: loadFromHTML5Localstore
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
public static FavouriteBusStationList loadFromHTML5Localstore()
{
FavouriteBusStationList favouriteBusStationList = new FavouriteBusStationList();
final Storage localStorage = Storage.getLocalStorageIfSupported();
if (localStorage != null)
{
String tmp = localStorage.getItem(SASAbusHTML5_FAVOURITES);
if (tmp != null && tmp.length() > 0)
{
GWTStructure gwtStructure = new GWTStructure((JSONObject) JSONParser.parse(tmp));
FavouriteBusStationListUnmarshaller unmarshaller = new FavouriteBusStationListUnmarshaller();
try
{
unmarshaller.unmarschall(gwtStructure, favouriteBusStationList);
}
catch (Exception e)
{
SASAbusHTML5.handleException(e);
}
}
}
return favouriteBusStationList;
}
示例13: loadSettingsFromLocalStorage
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
/**
* Loads the configurable settings from localstorage. The settings are
* "updateNowMessage" for specifying the message to show when a new version
* of the cache is ready, and "updateCheckInterval" for specifying how often
* to check for new versions.
*/
private void loadSettingsFromLocalStorage() {
Storage localStorage = Storage.getLocalStorageIfSupported();
if (localStorage != null) {
String newMessage = localStorage.getItem(UPDATE_NOW_MSG_KEY);
if (newMessage != null && !newMessage.isEmpty()) {
updateNowMessage = newMessage;
}
String updateCheckIntervalStr = localStorage
.getItem(UPDATE_CHECK_INTERVAL_KEY);
if (updateCheckIntervalStr != null
&& !updateCheckIntervalStr.isEmpty()) {
// The value in local storage is in seconds, but we need
// milliseconds.
updateCheckInterval = Integer.valueOf(updateCheckIntervalStr) * 1000;
}
}
}
示例14: setItem
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
@Override
public void setItem(String key, String data,
int callback) {
boolean supported = isSupported();
String oldData = null;
if (supported) {
Storage s = Storage.getLocalStorageIfSupported();
oldData = s.getItem(key);
if (data != null) {
s.setItem(key, data);
} else {
s.removeItem(key);
}
}
if (callback > -1) {
serverRpc.callLocalStorageItemCallback(callback, supported, key, oldData, data);
}
}
示例15: getUniqueId
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
public static String getUniqueId() {
Storage storage = Storage.getLocalStorageIfSupported();
String id = storage.getItem("tech_unique_id");
if (id != null) {
return id;
}
Random rnd = new Random();
id = "";
for (int i = 0; i < 128; i++) {
id += ((char) ('a' + rnd.nextInt('z' - 'a')));
}
storage.setItem("tech_unique_id", id);
return id;
}