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.19.4.1 2004/03/03 23:23:02 geirm Exp $

Author: Jason van Zyl

Field Summary
Vectorpaths
The paths to search for templates.
HashtabletemplatePaths
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
InputStreamfindTemplate(String path, String template)
Try to find a template given a normalized path.
longgetLastModified(Resource resource)
InputStreamgetResourceStream(String templateName)
Get an InputStream so that the Runtime can build a template with it.
voidinit(ExtendedProperties configuration)
booleanisSourceModified(Resource resource)
How to keep track of all the modified times across the paths.

Field Detail

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 Detail

findTemplate

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

Parameters: String a normalized path

Returns: InputStream input stream that will be parsed

getLastModified

public long getLastModified(Resource resource)

getResourceStream

public InputStream getResourceStream(String templateName)
Get an InputStream so that the Runtime can build a template with it.

Parameters: name name of template to get

Returns: InputStream containing the template

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

init

public void init(ExtendedProperties configuration)

isSourceModified

public boolean isSourceModified(Resource resource)
How to keep track of all the modified times across the paths. Note that a file might have appeared in a directory which is earlier in the path; so we should search the path and see if the file we find that way is the same as the one that we have cached.
Copyright B) 2002 Apache Software Foundation. All Rights Reserved.