Package com.transifex.txnative.cache
Class TxFileOutputCacheDecorator
java.lang.Object
com.transifex.txnative.cache.TxDecoratorCache
com.transifex.txnative.cache.TxFileOutputCacheDecorator
- All Implemented Interfaces:
TxCache
Decorator class responsible for storing any updates of the translations to a directory specified
in the constructor.
Storing the translations happens asynchronously on a background thread after
update(LocaleData.TranslationMap)
is called.
-
Field Summary
Fields inherited from class com.transifex.txnative.cache.TxDecoratorCache
mInternalCache
-
Constructor Summary
ModifierConstructorDescriptionTxFileOutputCacheDecorator
(File dstDirectory, TxCache internalCache) Creates a new instance with a specific directory for storing the translations to the disk and an internal cache.protected
TxFileOutputCacheDecorator
(Executor executor, File dstDirectory, TxCache internalCache) Creates a new instance with a specific directory for storing the translations to the disk and an internal cache. -
Method Summary
Modifier and TypeMethodDescriptionvoid
update
(LocaleData.TranslationMap translationMap) Updates the cache with the provided translations and writes them to the specified directory after clearing its content, if any.Methods inherited from class com.transifex.txnative.cache.TxDecoratorCache
get, get
-
Field Details
-
TAG
-
-
Constructor Details
-
TxFileOutputCacheDecorator
Creates a new instance with a specific directory for storing the translations to the disk and an internal cache.- Parameters:
dstDirectory
- The destination directory to write the translations to when theupdate(LocaleData.TranslationMap)
is called.internalCache
- The internal cache.
-
TxFileOutputCacheDecorator
protected TxFileOutputCacheDecorator(@Nullable Executor executor, @NonNull File dstDirectory, @NonNull TxCache internalCache) Creates a new instance with a specific directory for storing the translations to the disk and an internal cache.- Parameters:
executor
- The executor that will run the IO operations; ifnull
is provided,Executors.newSingleThreadExecutor()
is used.dstDirectory
- The destination directory to write the translations to when theupdate(LocaleData.TranslationMap)
is called.internalCache
- The internal cache.
-
-
Method Details
-
update
Updates the cache with the provided translations and writes them to the specified directory after clearing its content, if any.For the serialization and writing of the translations on disk,
TranslationMapStorage
is used internally. Each translation file uses "txstrings.json" as filename. Unlike TranslationMapStorage, pre-existing translations are not kept.- Specified by:
update
in interfaceTxCache
- Overrides:
update
in classTxDecoratorCache
-