|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.octo.android.robospice.persistence.ObjectPersister<T> com.octo.android.robospice.persistence.file.InFileObjectPersister<T>
T
- the class of the data to load/save.public abstract class InFileObjectPersister<T>
An ObjectPersister
that saves/loads data in a file.
Constructor Summary | |
---|---|
InFileObjectPersister(android.app.Application application,
Class<T> clazz)
|
|
InFileObjectPersister(android.app.Application application,
Class<T> clazz,
File cacheFolder)
|
Method Summary | |
---|---|
protected String |
fromKey(String cacheKey)
Get a cache key that may be de-sanitized if a KeySanitizer is
used. |
List<Object> |
getAllCacheKeys()
|
File |
getCacheFile(Object cacheKey)
|
File |
getCacheFolder()
|
protected String |
getCachePrefix()
|
long |
getCreationDateInCache(Object cacheKey)
Return the creation date of creation of cache. entry for a given cacheKey. |
KeySanitizer |
getKeySanitizer()
|
protected boolean |
isCachedAndNotExpired(File cacheFile,
long maxTimeInCacheBeforeExpiry)
|
protected boolean |
isCachedAndNotExpired(Object cacheKey,
long maxTimeInCacheBeforeExpiry)
|
boolean |
isDataInCache(Object cacheKey,
long maxTimeInCacheBeforeExpiry)
|
boolean |
isUsingKeySanitizer()
|
List<T> |
loadAllDataFromCache()
|
T |
loadDataFromCache(Object cacheKey,
long maxTimeInCache)
Load data from cache if not expired. |
protected abstract T |
readCacheDataFromFile(File file)
|
void |
removeAllDataFromCache()
|
boolean |
removeDataFromCache(Object cacheKey)
|
void |
setCacheFolder(File cacheFolder)
Set the cacheFolder to use. |
void |
setKeySanitizer(KeySanitizer keySanitizer)
|
protected String |
toKey(String cacheKey)
Get a key that may be sanitized if a KeySanitizer is used. |
Methods inherited from class com.octo.android.robospice.persistence.ObjectPersister |
---|
canHandleClass, getApplication, getHandledClass, isAsyncSaveEnabled, saveDataToCacheAndReturnData, setAsyncSaveEnabled |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public InFileObjectPersister(android.app.Application application, Class<T> clazz) throws CacheCreationException
CacheCreationException
public InFileObjectPersister(android.app.Application application, Class<T> clazz, File cacheFolder) throws CacheCreationException
CacheCreationException
Method Detail |
---|
public void setCacheFolder(File cacheFolder) throws CacheCreationException
cacheFolder
- the new cache folder to use. Can be null, will then default to
DEFAULT_ROOT_CACHE_DIR
sub folder in the application
cache dir.
CacheCreationException
- if the cache folder doesn't exist or can't be created.public final File getCacheFolder()
public long getCreationDateInCache(Object cacheKey) throws CacheLoadingException
ObjectPersister
getCreationDateInCache
in class ObjectPersister<T>
cacheKey
- the cachekey identifying the object to look for.
CacheLoadingException
- if there is no such element in cache.public List<Object> getAllCacheKeys()
getAllCacheKeys
in class ObjectPersister<T>
public List<T> loadAllDataFromCache() throws CacheLoadingException
loadAllDataFromCache
in class ObjectPersister<T>
CacheLoadingException
public boolean removeDataFromCache(Object cacheKey)
removeDataFromCache
in class ObjectPersister<T>
public void removeAllDataFromCache()
removeAllDataFromCache
in interface CacheCleaner
removeAllDataFromCache
in class ObjectPersister<T>
public T loadDataFromCache(Object cacheKey, long maxTimeInCache) throws CacheLoadingException
ObjectPersister
loadDataFromCache
in class ObjectPersister<T>
cacheKey
- the cacheKey of the data to load.maxTimeInCache
- the maximum time the data can have been stored in cached
before being considered expired. 0 means infinite.
CacheLoadingException
- if the data in cache is expired.public boolean isDataInCache(Object cacheKey, long maxTimeInCacheBeforeExpiry)
isDataInCache
in class ObjectPersister<T>
public boolean isUsingKeySanitizer()
InFileObjectPersister
uses a
KeySanitizer
.public void setKeySanitizer(KeySanitizer keySanitizer)
keySanitizer
- the new key sanitizer to be used by this
InFileObjectPersister
. May be null, in that case no
key sanitation will be used default). If key sanitation fails
on a given cache key (by throwing a
KeySanitationExcepion
, original (unsanitized) cache
keys will be used directly.public KeySanitizer getKeySanitizer()
InFileObjectPersister
. May
be null, in that case no key sanitation will be used default).public final File getCacheFile(Object cacheKey)
protected final String toKey(String cacheKey)
KeySanitizer
is used.
cacheKey
- a non-sanitized cacheKey.
KeySanitizer
is used.protected final String fromKey(String cacheKey)
KeySanitizer
is
used.
cacheKey
- a possibly sanitized cacheKey.
KeySanitizer
is
used.protected abstract T readCacheDataFromFile(File file) throws CacheLoadingException
CacheLoadingException
protected final String getCachePrefix()
protected boolean isCachedAndNotExpired(Object cacheKey, long maxTimeInCacheBeforeExpiry)
protected boolean isCachedAndNotExpired(File cacheFile, long maxTimeInCacheBeforeExpiry)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |