
com.octo.android.robospice.persistence.ObjectPersister Maven / Gradle / Ivy
The newest version!
package com.octo.android.robospice.persistence;
import java.util.List;
import android.app.Application;
import com.octo.android.robospice.persistence.exception.CacheLoadingException;
import com.octo.android.robospice.persistence.exception.CacheSavingException;
/**
* Super class of all entities responsible for loading/saving objects of a given
* class in the cache.
* @author sni
* @param
* the class of the objects this {@link ObjectPersister} can
* persist/unpersist.
*/
public abstract class ObjectPersister implements Persister, CacheCleaner {
private boolean isAsyncSaveEnabled;
private Application application;
private Class clazz;
public ObjectPersister(Application application, Class clazz) {
this.application = application;
this.clazz = clazz;
}
public Application getApplication() {
return application;
}
public Class getHandledClass() {
return clazz;
}
@Override
public boolean canHandleClass(Class> clazz) {
return clazz.equals(this.clazz);
}
/**
* Load data from cache if not expired.
* @param cacheKey
* the cacheKey of the data to load.
* @param maxTimeInCache
* the maximum time the data can have been stored in cached
* before being considered expired. 0 means infinite.
* @return the data if it could be loaded.
* @throws CacheLoadingException
* if the data in cache is expired.
*/
public abstract T loadDataFromCache(Object cacheKey, long maxTimeInCache) throws CacheLoadingException;
public abstract List loadAllDataFromCache() throws CacheLoadingException;
public abstract List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy