org.apache.velocity.runtime.resource.loader
Class FileResourceLoader
java.lang.Object
|
+--org.apache.velocity.runtime.resource.loader.ResourceLoader
|
+--org.apache.velocity.runtime.resource.loader.FileResourceLoader
- public class FileResourceLoader
- extends ResourceLoader
A loader for templates stored on the file system.
- Version:
- $Id: FileResourceLoader.java,v 1.15 2002/02/07 06:21:14 dlr Exp $
- Author:
- Jason van Zyl
Field Summary |
private java.util.Vector |
paths
The paths to search for templates. |
private java.util.Hashtable |
templatePaths
Used to map the path that a template was found on
so that we can properly check the modification
times of the files. |
Method Summary |
private java.io.InputStream |
findTemplate(java.lang.String path,
java.lang.String template)
Try to find a template given a normalized path. |
long |
getLastModified(Resource resource)
Get the last modified time of the InputStream source
that was used to create the template. |
java.io.InputStream |
getResourceStream(java.lang.String templateName)
Get an InputStream so that the Runtime can build a
template with it. |
void |
init(org.apache.commons.collections.ExtendedProperties 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. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
paths
private java.util.Vector paths
- The paths to search for templates.
templatePaths
private java.util.Hashtable templatePaths
- Used to map the path that a template was found on
so that we can properly check the modification
times of the files.
FileResourceLoader
public FileResourceLoader()
init
public void init(org.apache.commons.collections.ExtendedProperties configuration)
- Description copied from class:
ResourceLoader
- Initialize the template loader with a
a resources class.
- Overrides:
init
in class ResourceLoader
getResourceStream
public java.io.InputStream getResourceStream(java.lang.String templateName)
throws ResourceNotFoundException
- Get an InputStream so that the Runtime can build a
template with it.
- Overrides:
getResourceStream
in class ResourceLoader
- Parameters:
name
- name of template to get- Returns:
- InputStream containing the template
- Throws:
ResourceNotFoundException
- if template not found
in the file template path.
findTemplate
private java.io.InputStream findTemplate(java.lang.String path,
java.lang.String template)
- Try to find a template given a normalized path.
- Parameters:
String
- a normalized path- Returns:
- InputStream input stream that will be parsed
isSourceModified
public boolean isSourceModified(Resource resource)
- How to keep track of all the modified times
across the paths.
- Overrides:
isSourceModified
in class ResourceLoader
getLastModified
public long getLastModified(Resource resource)
- Description copied from class:
ResourceLoader
- Get the last modified time of the InputStream source
that was used to create the template. We need the template
here because we have to extract the name of the template
in order to locate the InputStream source.
- Overrides:
getLastModified
in class ResourceLoader
Copyright © 2003 Apache Software Foundation. All Rights Reserved.