|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.octo.android.robospice.persistence.ObjectPersisterFactory
public abstract class ObjectPersisterFactory
Super class of all factories of ObjectPersisterFactory
classes. They
are responsible for creating ObjectPersister
classes that will
save/load data for a given class. Such factories are useful because we
sometimes need to create ObjectPersister
dynamically. For instance
when we serialize items as JSON, we need to create a new
ObjectPersister
class for every class of items saved/loaded into
cache. A unique ObjectPersister
would not be able to strongly type
the load/save method and we would have to cast the result of both operations,
leading to less robust and less convenient code.
Constructor Summary | |
---|---|
ObjectPersisterFactory(android.app.Application application)
Creates an ObjectPersisterFactory given an Android application. |
|
ObjectPersisterFactory(android.app.Application application,
List<Class<?>> listHandledClasses)
Creates an ObjectPersisterFactory given an Android application
and a list of handled classes. |
Method Summary | ||
---|---|---|
boolean |
canHandleClass(Class<?> clazz)
Wether or not this bus element can persist/unpersist objects of the given class clazz. |
|
abstract
|
createObjectPersister(Class<DATA> clazz)
Creates a ObjectPersister for a given class. |
|
protected android.app.Application |
getApplication()
|
|
protected List<Class<?>> |
getListHandledClasses()
Return the list of classes persisted by this factory. |
|
boolean |
isAsyncSaveEnabled()
Indicates whether this ObjectPersisterFactory will set the
ObjectPersister instances it produces to save data asynchronously
or not. |
|
void |
setAsyncSaveEnabled(boolean isAsyncSaveEnabled)
Set whether this ObjectPersisterFactory will set the
ObjectPersister instances it produces to save data asynchronously
or not. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ObjectPersisterFactory(android.app.Application application)
ObjectPersisterFactory
given an Android application.
As no list of handled classes is specified, it will act has if it can
handle all classes.
application
- the android context needed to access android file system or
databases to store.public ObjectPersisterFactory(android.app.Application application, List<Class<?>> listHandledClasses)
ObjectPersisterFactory
given an Android application
and a list of handled classes.
application
- the android context needed to access android file system or
databases to store.listHandledClasses
- the list of classes that is handled by the factory. The
factory will try to produce an ObjectPersister
for
each element of the list.Method Detail |
---|
protected final android.app.Application getApplication()
public boolean canHandleClass(Class<?> clazz)
canHandleClass
in interface Persister
clazz
- the class of objets we are looking forward to persist.
public abstract <DATA> ObjectPersister<DATA> createObjectPersister(Class<DATA> clazz) throws CacheCreationException
ObjectPersister
for a given class.
clazz
- the class of the items that need to be saved/loaded from
cache.
ObjectPersister
able to load/save instances of class
clazz.
CacheCreationException
- if the persist fails to create its cache (it may also create
it later, but it is suggested to fail as fast as possible).public void setAsyncSaveEnabled(boolean isAsyncSaveEnabled)
ObjectPersisterFactory
will set the
ObjectPersister
instances it produces to save data asynchronously
or not.
isAsyncSaveEnabled
- whether or not data will be saved asynchronously by
ObjectPersister
instances produced by this factory.public boolean isAsyncSaveEnabled()
ObjectPersisterFactory
will set the
ObjectPersister
instances it produces to save data asynchronously
or not.
ObjectPersister
instances it produces to save
data asynchronously. False otherwise.protected List<Class<?>> getListHandledClasses()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |