com.octo.android.robospice.persistence.file
Class InFileObjectPersisterFactory

java.lang.Object
  extended by com.octo.android.robospice.persistence.ObjectPersisterFactory
      extended by com.octo.android.robospice.persistence.file.InFileObjectPersisterFactory
All Implemented Interfaces:
CacheCleaner, Persister
Direct Known Subclasses:
GsonObjectPersisterFactory, Jackson2ObjectPersisterFactory, JacksonObjectPersisterFactory, JsonObjectPersisterFactory, RetrofitObjectPersisterFactory, SimpleSerializerObjectPersisterFactory

public abstract class InFileObjectPersisterFactory
extends ObjectPersisterFactory
implements CacheCleaner

A factory that will create ObjectPersister instances that save/load data in a file.

Author:
sni

Constructor Summary
InFileObjectPersisterFactory(android.app.Application application)
           
InFileObjectPersisterFactory(android.app.Application application, File cacheFolder)
           
InFileObjectPersisterFactory(android.app.Application application, List<Class<?>> listHandledClasses)
           
InFileObjectPersisterFactory(android.app.Application application, List<Class<?>> listHandledClasses, File cacheFolder)
           
 
Method Summary
abstract
<T> InFileObjectPersister<T>
createInFileObjectPersister(Class<T> clazz, File cacheFolder)
           
<T> InFileObjectPersister<T>
createObjectPersister(Class<T> clazz)
          Creates a ObjectPersister for a given class.
 File getCacheFolder()
           
 String getCachePrefix()
           
 KeySanitizer getKeySanitizer()
           
 void removeAllDataFromCache()
           
 void setCacheFolder(File cacheFolder)
          Sets the folder used by object persisters of this factory.
 void setCachePrefix(String cachePrefix)
          Sets the cachePrefix used by object persisters of this factory.
 void setKeySanitizer(KeySanitizer keySanitizer)
           
 
Methods inherited from class com.octo.android.robospice.persistence.ObjectPersisterFactory
canHandleClass, getApplication, getListHandledClasses, isAsyncSaveEnabled, setAsyncSaveEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InFileObjectPersisterFactory

public InFileObjectPersisterFactory(android.app.Application application)
                             throws CacheCreationException
Throws:
CacheCreationException

InFileObjectPersisterFactory

public InFileObjectPersisterFactory(android.app.Application application,
                                    File cacheFolder)
                             throws CacheCreationException
Throws:
CacheCreationException

InFileObjectPersisterFactory

public InFileObjectPersisterFactory(android.app.Application application,
                                    List<Class<?>> listHandledClasses)
                             throws CacheCreationException
Throws:
CacheCreationException

InFileObjectPersisterFactory

public InFileObjectPersisterFactory(android.app.Application application,
                                    List<Class<?>> listHandledClasses,
                                    File cacheFolder)
                             throws CacheCreationException
Throws:
CacheCreationException
Method Detail

setCacheFolder

public void setCacheFolder(File cacheFolder)
                    throws CacheCreationException
Sets the folder used by object persisters of this factory.

Parameters:
cacheFolder - the new cache folder of this factory (and persisters it will create). Ca be null, it will then default to the sub folder InFileObjectPersister.DEFAULT_ROOT_CACHE_DIR in side the application cache folder. Will be created if doesn't exist yet.
Throws:
CacheCreationException

setCachePrefix

public void setCachePrefix(String cachePrefix)
Sets the cachePrefix used by object persisters of this factory.

Parameters:
cachePrefix - the new cache cachePrefix of this factory (and persisters it will create). Defaults to "className".

getCacheFolder

public File getCacheFolder()

getCachePrefix

public String getCachePrefix()

getKeySanitizer

public KeySanitizer getKeySanitizer()

setKeySanitizer

public void setKeySanitizer(KeySanitizer keySanitizer)
Parameters:
keySanitizer - the new key sanitizer to be used by this InFileObjectPersisterFactory and persisters. May be null, in that case no key sanitation will be used. This is the default.

createObjectPersister

public final <T> InFileObjectPersister<T> createObjectPersister(Class<T> clazz)
Description copied from class: ObjectPersisterFactory
Creates a ObjectPersister for a given class.

Specified by:
createObjectPersister in class ObjectPersisterFactory
Parameters:
clazz - the class of the items that need to be saved/loaded from cache.
Returns:
a ObjectPersister able to load/save instances of class clazz.

createInFileObjectPersister

public abstract <T> InFileObjectPersister<T> createInFileObjectPersister(Class<T> clazz,
                                                                         File cacheFolder)
                                                              throws CacheCreationException
Throws:
CacheCreationException

removeAllDataFromCache

public void removeAllDataFromCache()
Specified by:
removeAllDataFromCache in interface CacheCleaner


Copyright © 2012-2014. All Rights Reserved.