public class FileResourceLoader extends ResourceLoader
Modifier and Type | Field and Description |
---|---|
private java.util.List<java.lang.String> |
paths
The paths to search for templates.
|
private java.util.Map<java.lang.String,java.lang.String> |
templatePaths
Used to map the path that a template was found on
so that we can properly check the modification
times of the files.
|
className, isCachingOn, log, modificationCheckInterval, rsvc
Constructor and Description |
---|
FileResourceLoader() |
Modifier and Type | Method and Description |
---|---|
private void |
closeQuiet(java.io.InputStream is) |
private java.io.InputStream |
findTemplate(java.lang.String path,
java.lang.String template)
Try to find a template given a normalized path.
|
private java.io.File |
getFile(java.lang.String path,
java.lang.String template)
Create a File based on either a relative path if given, or absolute path otherwise
|
long |
getLastModified(Resource resource)
Get the last modified time of the InputStream source
that was used to create the template.
|
java.io.Reader |
getResourceReader(java.lang.String templateName,
java.lang.String encoding)
Get a Reader so that the Runtime can build a
template with it.
|
void |
init(ExtProperties configuration)
Initialize the template loader with a
a resources class.
|
boolean |
isSourceModified(Resource resource)
How to keep track of all the modified times
across the paths.
|
boolean |
resourceExists(java.lang.String name)
Overrides superclass for better performance.
|
buildReader, commonInit, getClassName, getModificationCheckInterval, isCachingOn, setCachingOn, setModificationCheckInterval
private java.util.List<java.lang.String> paths
private java.util.Map<java.lang.String,java.lang.String> templatePaths
public void init(ExtProperties configuration)
ResourceLoader
init
in class ResourceLoader
ResourceLoader.init(org.apache.velocity.util.ExtProperties)
public java.io.Reader getResourceReader(java.lang.String templateName, java.lang.String encoding) throws ResourceNotFoundException
getResourceReader
in class ResourceLoader
templateName
- name of template to getResourceNotFoundException
- if template not found
in the file template path.public boolean resourceExists(java.lang.String name)
resourceExists
in class ResourceLoader
name
- The name of a resource.private java.io.InputStream findTemplate(java.lang.String path, java.lang.String template) throws java.io.IOException
path
- a normalized pathtemplate
- name of template to findjava.io.IOException
private void closeQuiet(java.io.InputStream is)
public boolean isSourceModified(Resource resource)
isSourceModified
in class ResourceLoader
resource
- public long getLastModified(Resource resource)
ResourceLoader
getLastModified
in class ResourceLoader
ResourceLoader.getLastModified(org.apache.velocity.runtime.resource.Resource)
private java.io.File getFile(java.lang.String path, java.lang.String template)