|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectfreemarker.template.cache.FileRetriever
public class FileRetriever
Retrieves cacheable objects through the file system. This is the default
retriever for FileTemplateCache.
| Field Summary | |
|---|---|
protected java.io.File |
directoryRoot
The root directory where the retriever will get files. |
protected java.lang.String |
encoding
The text encoding of the template files. |
protected java.lang.String |
filenameSuffix
The filename suffix required for a file to be retrieved. |
protected TemplateRegistry |
registry
The template registry to use to instantiate objects. |
| Constructor Summary | |
|---|---|
FileRetriever()
Creates new FileRetriever. |
|
FileRetriever(java.io.File rootDir)
Creates a new FileRetriever, with a directory root. |
|
FileRetriever(FileRetrieverParameters params)
Creates a new FileRetriever, with the given parameters. |
|
FileRetriever(java.lang.String path)
Constructs a FileRetriever with a directory in which it will look for template files. |
|
| Method Summary | |
|---|---|
boolean |
connectionOk()
Corresponds to checkCacheDir for file-system implementations. |
boolean |
equals(java.lang.Object o)
Is this file retriever equal to another object? |
boolean |
exists(java.lang.String location)
Tests whether the object still exists in the template repository. |
java.lang.String |
getConnection()
Gets the connection for this retriever. |
java.lang.String |
getEncoding()
Returns the character encoding to be used when reading template files. |
java.lang.String |
getFilenameSuffix()
Returns the file suffix. |
java.io.File |
getPath()
Returns the root directory for this retriever. |
java.util.List<java.lang.String> |
getPreloadData()
Returns a list of objects ( Strings) to pre-load the cache with. |
TemplateRegistry |
getTemplateRegistry()
Gets the current template registry implementation in use. |
int |
hashCode()
Retrieve the hash code for this object |
protected boolean |
isSuffixValid(java.lang.String name)
Determine whether the filename ends with the appropriate filename suffix. |
long |
lastModified(java.lang.String location)
Determines when the object in the template repository was last modified. |
Cacheable |
loadData(java.lang.String location,
java.lang.String type,
Cache cache)
Retrieves the appropriate data to be stored in the cache. |
protected java.io.File |
nameToFile(java.lang.String name)
Converts a cache element name to a File. |
protected void |
readDirectory(java.io.File dir,
java.lang.String relativeDirPath,
java.util.List<java.lang.String> visitedFiles)
Recursively updates the cache from the files in a (sub)directory and its subdirectories. |
void |
setTemplateRegistry(TemplateRegistry cRegistry)
Deprecated. this is the only mutable state, and should be removed in the next release |
java.lang.String |
toString()
Returns a string representation of the object. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected java.io.File directoryRoot
protected java.lang.String filenameSuffix
protected java.lang.String encoding
protected TemplateRegistry registry
| Constructor Detail |
|---|
public FileRetriever()
public FileRetriever(java.lang.String path)
path - the absolute path of the directory containing
templates for this retriever
java.lang.IllegalArgumentException - the root directory is nullpublic FileRetriever(java.io.File rootDir)
rootDir - the root directory for the file system
java.lang.IllegalArgumentException - the root directory is nullpublic FileRetriever(FileRetrieverParameters params)
params - the parameters for this file retriever
java.lang.IllegalArgumentException - the root directory is null| Method Detail |
|---|
public boolean connectionOk()
throws TemplateException
connectionOk in interface CacheRetrievertrue if the connection is ok, otherwise false
TemplateException - the directory no longer exists, or is not
a directorypublic java.lang.String getConnection()
getConnection in interface CacheRetrieverpublic java.io.File getPath()
public java.lang.String getFilenameSuffix()
public boolean exists(java.lang.String location)
exists in interface CacheRetrieverlocation - the location of the object to be tested
true if the object still exists in the repository,
otherwise falselastModified(java.lang.String)
public java.util.List<java.lang.String> getPreloadData()
throws TemplateException
Strings) to pre-load the cache with.
getPreloadData in interface CacheRetrieverList of Strings to preload the
cache with
TemplateException
protected void readDirectory(java.io.File dir,
java.lang.String relativeDirPath,
java.util.List<java.lang.String> visitedFiles)
throws java.io.IOException
dir - the directory to be read.relativeDirPath - a string representing the directory's path
relative to the root cache directory.visitedFiles - a List of files that have been visited so far.
java.io.IOException
public long lastModified(java.lang.String location)
throws TemplateException
Determines when the object in the template repository was last modified.
lastModified in interface CacheRetrieverlocation - the location of the object to be tested
TemplateException - is thrown whenever the item:
protected boolean isSuffixValid(java.lang.String name)
throws TemplateException
name - the filename to be checked
TemplateException - the suffix is invalid
protected java.io.File nameToFile(java.lang.String name)
throws TemplateException
name - the filename relative to the directory root of the retriever
TemplateException
public Cacheable loadData(java.lang.String location,
java.lang.String type,
Cache cache)
throws TemplateException
loadData in interface CacheRetrieverlocation - the filename, relative to the root directory, of the
template data to loadtype - the type of item to be loadedcache - the cache to which the item will be added
TemplateException - the object could not be loadedpublic java.lang.String getEncoding()
getEncoding in interface TextEncodingpublic void setTemplateRegistry(TemplateRegistry cRegistry)
setTemplateRegistry in interface RegistryAcceptercRegistry - the registry to be used for creating new objectspublic TemplateRegistry getTemplateRegistry()
getTemplateRegistry in interface RegistryAccepterpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - the object to compare this object with
true if the objects are equal, otherwise
falsepublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.ObjectString representation of the object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||