org.apache.velocity.runtime.resource.loader

Class 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 Vector
paths
The paths to search for templates.
private 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.

Fields inherited from class org.apache.velocity.runtime.resource.loader.ResourceLoader

className, isCachingOn, modificationCheckInterval, rsvc

Method Summary

private InputStream
findTemplate(String path, 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.
InputStream
getResourceStream(String templateName)
Get an InputStream so that the Runtime can build a template with it.
void
init(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 org.apache.velocity.runtime.resource.loader.ResourceLoader

commonInit, getClassName, getLastModified, getModificationCheckInterval, getResourceStream, init, isCachingOn, isSourceModified, setCachingOn, setModificationCheckInterval

Field Details

paths

private Vector paths
The paths to search for templates.


templatePaths

private 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 Details

findTemplate

private InputStream findTemplate(String path,
                                 String template)
Try to find a template given a normalized path.

Parameters:

Returns:
InputStream input stream that will be parsed


getLastModified

public long getLastModified(Resource resource)
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 interface ResourceLoader


getResourceStream

public InputStream getResourceStream(String templateName)
            throws ResourceNotFoundException
Get an InputStream so that the Runtime can build a template with it.
Overrides:
getResourceStream in interface ResourceLoader

Parameters:

Returns:
InputStream containing the template

Throws:
ResourceNotFoundException - if template not found in the file template path.


init

public void init(ExtendedProperties configuration)
Initialize the template loader with a a resources class.
Overrides:
init in interface ResourceLoader


isSourceModified

public boolean isSourceModified(Resource resource)
How to keep track of all the modified times across the paths.
Overrides:
isSourceModified in interface ResourceLoader


Copyright © 2003 Apache Software Foundation. All Rights Reserved.