Package ch.autumo.commons.cache
Class FileCache
java.lang.Object
ch.autumo.commons.cache.FileCache
File cache.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final long
Buffer limit.protected static final org.slf4j.Logger
Logger. -
Constructor Summary
ConstructorDescriptionFile cache constructor.FileCache
(String resourcePath, ContentType contentType) File cache constructor.File cache constructor.FileCache
(Path filePath, ContentType contentType) File cache constructor.FileCache
(Path filePath, ContentType contentType, boolean forcedCaching) File cache constructor.File cache constructor.File cache constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clear cache if cached.boolean
getData()
Get data as stream from file or cache, depending of the buffer size.Return encoding.Get file full pat.long
When was the file last modified or '-1' if it is a resource.Return mime type if anyGet text data.boolean
Is it an archive?boolean
isBinary()
Is it a binary?boolean
isCached()
Cached?boolean
Is it a resource (e.g.boolean
isText()
Is it a text file?
-
Field Details
-
LOG
protected static final org.slf4j.Logger LOGLogger. -
BUFFER_LIMIT
public static final long BUFFER_LIMITBuffer limit.
-
-
Constructor Details
-
FileCache
File cache constructor.- Parameters:
filePath
- file pathmimeType
- mime type, e.g. "text/html"- Throws:
IOException
- if file cache cannot be created
-
FileCache
File cache constructor.- Parameters:
filePath
- file pathcontentType
- content header type, e.g. "text/html; charset=UTF-8"- Throws:
IOException
- if file cache cannot be created
-
FileCache
File cache constructor.- Parameters:
filePath
- file pathmimeType
- mime type, e.g. "text/html"forcedCaching
- force caching?- Throws:
IOException
- if file cache cannot be created
-
FileCache
File cache constructor.- Parameters:
filePath
- file pathcontentType
- content header type, e.g. "text/html; charset=UTF-8"forcedCaching
- force caching?- Throws:
IOException
- if file cache cannot be created
-
FileCache
File cache constructor.- Parameters:
resourcePath
- resource path- Throws:
IOException
- if file cache cannot be created
-
FileCache
File cache constructor.- Parameters:
resourcePath
- resource pathmimeType
- mime type, e.g. "text/html"- Throws:
IOException
- if file cache cannot be created
-
FileCache
File cache constructor.- Parameters:
resourcePath
- resource pathcontentType
- content header type, e.g. "text/html; charset=UTF-8"- Throws:
IOException
- if file cache cannot be created
-
-
Method Details
-
getData
Get data as stream from file or cache, depending of the buffer size.- Returns:
- data stream
- Throws:
IOException
- if data cannot be acquired from cache
-
getTextData
Get text data.- Returns:
- cached data as text or null
- Throws:
IOException
- if text data cannot be acquired from cache
-
getMimeType
Return mime type if any- Returns:
- mime type
-
getEncoding
Return encoding.- Returns:
- encoding
-
getFullPath
Get file full pat.- Returns:
- file path
-
isCached
public boolean isCached()Cached?- Returns:
- true if so
-
getLastModified
public long getLastModified()When was the file last modified or '-1' if it is a resource.- Returns:
- last modification of file or -1
-
isArchive
public boolean isArchive()Is it an archive?- Returns:
- is it an archive
-
isBinary
public boolean isBinary()Is it a binary?- Returns:
- is it a binary
-
isText
public boolean isText()Is it a text file?- Returns:
- is it a text file
-
isResource
public boolean isResource()Is it a resource (e.g. from JAR)?- Returns:
- is it a resoruce
-
clear
public void clear()Clear cache if cached. -
equals
-