public class

CacheUtils

extends Object
java.lang.Object
   ↳ com.pdftron.demo.utils.CacheUtils

Class Overview

modified slightly by PDFTron team in the original package, https://github.com/westlinkin/CacheUtilsLibrary FileInputStream/FileOutputStream are not closed and therefore the resources are kept open we also want to save/retrieve data in the same order (so using LinkedHashMap)

Summary

Constants
String CACHE_HEADER_LIST_OBJECT
Fields
public static String BASE_CACHE_PATH
Public Constructors
CacheUtils()
Public Methods
static void configureCache(Context context)
static void deleteFile(String fileName)
delete the file with fileName
static boolean hasCache(String fileName)
check if there is a cache file with fileName
static Date lastModified(String fileName)
Check the last modified date if the cache file.
static <T> LinkedHashMap<String, T> readDataMapFile(String fileName)
static <T> LinkedHashMap<String, T> readDataMapsFile(String fileName)
static String readFile(String fileName)
static <T> T readObjectFile(String fileName, Type t)
static <T> void writeDataMapFile(String fileName, LinkedHashMap<String, T> dataMap)
static <T> void writeDataMapsFile(String fileName, LinkedHashMap<String, T> dataMaps)
static void writeFile(String fileName, String fileContent)
static <T> void writeObjectFile(String fileName, T object)
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String CACHE_HEADER_LIST_OBJECT

Constant Value: "cache_header_list_object_v2"

Fields

public static String BASE_CACHE_PATH

Public Constructors

public CacheUtils ()

Public Methods

public static void configureCache (Context context)

public static void deleteFile (String fileName)

delete the file with fileName

Parameters
fileName the name of the file

public static boolean hasCache (String fileName)

check if there is a cache file with fileName

Parameters
fileName the name of the file
Returns
  • true if the file exits, false otherwise

public static Date lastModified (String fileName)

Check the last modified date if the cache file.

Parameters
fileName the name of the file
Returns
  • Date modified. Null if file doesn't exist.

public static LinkedHashMap<String, T> readDataMapFile (String fileName)

Parameters
fileName the name of the file
Returns
  • the map data you previous stored

public static LinkedHashMap<String, T> readDataMapsFile (String fileName)

Parameters
fileName the name of the file
Returns
  • the map list you previous stored, an empty List will be returned if there is no such file

public static String readFile (String fileName)

Parameters
fileName the name of the file
Returns
  • the content of the file, null if there is no such file

public static T readObjectFile (String fileName, Type t)

Parameters
fileName the name of the file
t the type of the object you previous stored
Returns
  • the T type object you previous stored

public static void writeDataMapFile (String fileName, LinkedHashMap<String, T> dataMap)

Parameters
fileName the name of the file
dataMap the map data you want to store

public static void writeDataMapsFile (String fileName, LinkedHashMap<String, T> dataMaps)

Parameters
fileName the name of the file
dataMaps the map list you want to store

public static void writeFile (String fileName, String fileContent)

Parameters
fileName the name of the file
fileContent the content of the file

public static void writeObjectFile (String fileName, T object)

Parameters
fileName the name of the file
object the object you want to store