public class StorageManager extends Object
| Constructor and Description |
|---|
StorageManager()
Default constructor setting up the StorageManager all inclusive Logger and
Phonegap references are setup locally
|
StorageManager(com.googlecode.gwtphonegap.client.PhoneGap phonegap,
Logger logger)
Constructor allowing to inject the Phonegap reference and a Logger
|
| Modifier and Type | Method and Description |
|---|---|
void |
addResourceToCache(String relativeUrl,
Integer version)
Check first if the resource with the given url and version is already
present, if not try to download the same in a sequential way asynchronously
|
Boolean |
checkResourceVersion(StorageResource resource)
Check if the version registered in the cache does match this resources
version
|
void |
clearResourceItems()
Remove all ResourceItem related keys from the LocalStorage and as well
related resource files, ClearCache
|
void |
clearStorage()
Clear all cached items - key/value pairs in the LocalStorage - Related
files in the cache directory
|
void |
clearStorageItems()
Remove all StorageItem related keys from the LocalStorage, thus clear the
cached json objects and references etc.
|
int |
getAllCachedResourceItems(com.google.gwt.core.client.Callback<StorageInfo,com.googlecode.gwtphonegap.client.file.FileError> callback)
Retrieve all ResourceItems related keys from the LocalStorage
|
String |
getCacheDirectory() |
boolean |
getCacheEnabled() |
com.google.gwt.storage.client.Storage |
getLocalStorage()
Retrieve a reference to the local Storage (Browsers HTML5 key-value store)
|
String |
getRemoteAppBaseUrl() |
String |
getRemoteResourceUrl(String relativeUrl)
Retrieve the url of the resource on the remote server based on the current
runtime environement
|
String |
getStorageUrl() |
boolean |
getWlanEnabled() |
boolean |
isResourceCachingPossible()
Evaluates if Caching is possible at all on the given client device at the
moment of evaluation.
|
boolean |
readStorageItem(StorageItem item,
boolean useCache,
int expectedVersion,
int validTime,
com.google.gwt.core.client.Callback<StorageItem,StorageError> callback)
Retrieve the item from the storage.
|
boolean |
readStorageItemFromLocalApplication(StorageItem item,
com.google.gwt.core.client.Callback<StorageItem,StorageError> callback)
Read the item asynch from the applications own source server with the given
credentials and base path eg.
|
boolean |
readStorageItemFromLocalFile(StorageItem item,
com.google.gwt.core.client.Callback<StorageItem,StorageError> callback)
Read the item from the Local File storage
|
boolean |
readStorageItemFromLocalStorage(StorageItem item)
Read the item from the local html5 storage.
|
boolean |
readStorageItemFromRemoteApplication(StorageItem item,
com.google.gwt.core.client.Callback<StorageItem,StorageError> callback)
Read the item asynch from the configured remote application base
|
boolean |
readStorageItemFromUrl(String url,
StorageItem item,
com.google.gwt.core.client.Callback<StorageItem,StorageError> callback)
Read the JSON item asynch from the given url and the
standard name of the item eg.
|
boolean |
retrieveResourceUrl(String relativeUrl,
Integer version,
com.google.gwt.core.client.Callback<String,com.googlecode.gwtphonegap.client.file.FileError> callback)
Evaluates in case of the runtime (browser/phonegap) the full url where a
resource must be retrieved from.
|
void |
setCacheDirectory(String cacheDirectory) |
void |
setCacheEnabled(boolean cacheEnabled) |
void |
setRemoteAppBaseUrl(String baseUrl) |
void |
setStorageUrl(String storageUrl) |
void |
setWlanEnabled(boolean wlanEnabled) |
boolean |
writeStorageItemToLocalFile(StorageItem item,
com.google.gwt.core.client.Callback<StorageItem,StorageError> callback)
Write the item to a local file
|
boolean |
writeStorageItemToLocalStorage(StorageItem item)
Write the given item to the local HTML5 storage.
|
public StorageManager()
public StorageManager(com.googlecode.gwtphonegap.client.PhoneGap phonegap, Logger logger)
phonegap - Give the phonegap reference you have already. Give null if
you want it to be treated here automatically.logger - Give a logger reference or null if you want it to be treated
here locally.public String getRemoteAppBaseUrl()
public void setRemoteAppBaseUrl(String baseUrl)
public String getStorageUrl()
public void setStorageUrl(String storageUrl)
public String getCacheDirectory()
public void setCacheDirectory(String cacheDirectory)
public void setCacheEnabled(boolean cacheEnabled)
public boolean getCacheEnabled()
public void setWlanEnabled(boolean wlanEnabled)
public boolean getWlanEnabled()
public boolean isResourceCachingPossible()
public com.google.gwt.storage.client.Storage getLocalStorage()
public boolean writeStorageItemToLocalStorage(StorageItem item)
item - The object to be serialized and stored under the ID within the
local storagepublic boolean readStorageItemFromLocalStorage(StorageItem item)
item - The item to be read from the local storage with the given ID as
key.public void clearStorageItems()
public boolean writeStorageItemToLocalFile(StorageItem item, com.google.gwt.core.client.Callback<StorageItem,StorageError> callback)
item - The StorageItem to be stored to the file system within the
defined cache directorycallback - Is called once the asynch action completed or failed.public boolean readStorageItemFromLocalFile(StorageItem item, com.google.gwt.core.client.Callback<StorageItem,StorageError> callback)
item - The StorageItem (or inherited objects) to be read from the
local cache file system location.callback - Is called once the asynch action completed or failedpublic boolean readStorageItem(StorageItem item, boolean useCache, int expectedVersion, int validTime, com.google.gwt.core.client.Callback<StorageItem,StorageError> callback)
item - The item to be read by ID from 1. the cache, 2. localAppPath 3.
remoteAppPath in this priority orderuseCache - If true, the system will first try to retrieve the value
from the local cache before it reads the same from the
applications pathvalidTime - The maximum age in seconds of the cache to be accepted as
a valid item value, if elapsed it will try to read from the
applications path / If <= 0 don't careexpectedVersion - The versionNumber which must be available in the
cache to be a valid cache item. If <=0 don't care.public boolean readStorageItemFromLocalApplication(StorageItem item, com.google.gwt.core.client.Callback<StorageItem,StorageError> callback)
item - callback - is called once the asynch action completed or failedpublic boolean readStorageItemFromRemoteApplication(StorageItem item, com.google.gwt.core.client.Callback<StorageItem,StorageError> callback)
item - callback - is called once the asynch action completed or failedpublic boolean readStorageItemFromUrl(String url, StorageItem item, com.google.gwt.core.client.Callback<StorageItem,StorageError> callback)
url - The url to read from eg. for local application relative path
"storage/v1/" eg. for remote location
"http://host.domain.ch/testapp/storage/v1/"item - callback - is called once the asynch action completed or failedpublic String getRemoteResourceUrl(String relativeUrl)
relativeUrl - relative url of the resource according the app basepublic boolean retrieveResourceUrl(String relativeUrl, Integer version, com.google.gwt.core.client.Callback<String,com.googlecode.gwtphonegap.client.file.FileError> callback)
relativeUrl - of the resource as it is available in the application
itself.version - Check if the version of the stored resource equals. Not
checked if version=0public Boolean checkResourceVersion(StorageResource resource)
public void clearResourceItems()
public void addResourceToCache(String relativeUrl, Integer version)
relativeUrl - version - public void clearStorage()
public int getAllCachedResourceItems(com.google.gwt.core.client.Callback<StorageInfo,com.googlecode.gwtphonegap.client.file.FileError> callback)
Copyright © 2016. All rights reserved.