com.octo.android.robospice.persistence.ormlite
Class InDatabaseObjectPersister<T,ID>
java.lang.Object
com.octo.android.robospice.persistence.ObjectPersister<T>
com.octo.android.robospice.persistence.ormlite.InDatabaseObjectPersister<T,ID>
- All Implemented Interfaces:
- CacheCleaner, Persister
public class InDatabaseObjectPersister<T,ID>
- extends ObjectPersister<T>
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
InDatabaseObjectPersister
public InDatabaseObjectPersister(android.app.Application application,
RoboSpiceDatabaseHelper databaseHelper,
Class<T> modelObjectType)
- Parameters:
application
- the android context needed to access android file system or databases to store.
InDatabaseObjectPersister
public InDatabaseObjectPersister(android.app.Application application,
RoboSpiceDatabaseHelper databaseHelper,
Class<T> modelObjectType,
Map<Class<?>,android.net.Uri> mapHandledClassesToNotificationUri)
- Parameters:
application
- the android context needed to access android file system or databases to store.
loadDataFromCache
public T loadDataFromCache(Object cacheKey,
long maxTimeInCache)
throws CacheLoadingException
- Description copied from class:
ObjectPersister
- Load data from cache if not expired.
- Specified by:
loadDataFromCache
in class ObjectPersister<T>
- Parameters:
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.
- Returns:
- the data if it could be loaded.
- Throws:
CacheLoadingException
- if the data in cache is expired.
saveDataToCacheAndReturnData
public T saveDataToCacheAndReturnData(T data,
Object cacheKey)
throws CacheSavingException
- Specified by:
saveDataToCacheAndReturnData
in class ObjectPersister<T>
- Throws:
CacheSavingException
isDataInCache
public boolean isDataInCache(Object cacheKey,
long maxTimeInCache)
- Specified by:
isDataInCache
in class ObjectPersister<T>
getCreationDateInCache
public long getCreationDateInCache(Object cacheKey)
throws CacheLoadingException
- Description copied from class:
ObjectPersister
- Return the creation date of creation of cache. entry for a given
cacheKey.
- Specified by:
getCreationDateInCache
in class ObjectPersister<T>
- Parameters:
cacheKey
- the cachekey identifying the object to look for.
- Returns:
- a long corresponding to the creation date of creation of cache.
- Throws:
CacheLoadingException
- if there is no such element in cache.
saveAllForeignObjectsToCache
protected <E> void saveAllForeignObjectsToCache(E data)
throws SQLException,
IllegalAccessException,
InvocationTargetException
- During this operation, we must save a new POJO (parent) into the database. The problem is
that is the POJO contains children POJOs, then saving the parent would not work as the parent
must exist in the database prior to saving the children. SO :
- we copy the children into memory,
- put the children to null on parent
- save the parent to the database
- if saving filled the parent with previous children, we remove them
- re inject the children into the parent
- save the children (as the parent now exists in database).
- Parameters:
data
- the parent POJO to save in the database.
- Throws:
SQLException
IllegalArgumentException
IllegalAccessException
InvocationTargetException
removeDataFromCache
public boolean removeDataFromCache(Object cacheKey)
- Specified by:
removeDataFromCache
in class ObjectPersister<T>
removeAllDataFromCache
public void removeAllDataFromCache()
- Specified by:
removeAllDataFromCache
in interface CacheCleaner
- Specified by:
removeAllDataFromCache
in class ObjectPersister<T>
loadAllDataFromCache
public List<T> loadAllDataFromCache()
throws CacheLoadingException
- Specified by:
loadAllDataFromCache
in class ObjectPersister<T>
- Throws:
CacheLoadingException
getAllCacheKeys
public List<Object> getAllCacheKeys()
- Specified by:
getAllCacheKeys
in class ObjectPersister<T>
getIdField
protected com.j256.ormlite.field.FieldType getIdField(Class clazz)
throws SQLException
- Throws:
SQLException
getDatabaseTableConfig
protected com.j256.ormlite.table.DatabaseTableConfig getDatabaseTableConfig(Class clazz)
throws SQLException
- Throws:
SQLException
Copyright © 2012-2014. All Rights Reserved.