org.jamon
Class FileTemplateSource

java.lang.Object
  extended by org.jamon.FileTemplateSource
All Implemented Interfaces:
TemplateSource

public class FileTemplateSource
extends Object
implements TemplateSource

The standard implementation of TemplateSource which retrieves templates from the filesystem location under a specified root directory. By default, templates are expected to have extens ".jamon"; this can be overridden.


Constructor Summary
FileTemplateSource(File p_templateSourceDir)
          Construct a FileTemplateSource, using the default extension ".jamon".
FileTemplateSource(File p_templateSourceDir, String p_extension)
          Construct a FileTemplateSource, specifying a filename extension for templates.
FileTemplateSource(String p_templateSourceDir)
          Construct a FileTemplateSource
 
Method Summary
 boolean available(String p_templatePath)
          Determines whether the indicated template source is available.
 String getExternalIdentifier(String p_templatePath)
          Get an identifying string for the specified template.
 InputStream getStreamFor(String p_templatePath)
          Get a InputStream for the source of the specified template.
 TemplateLocation getTemplateLocation(String p_templatePath)
           
 long lastModified(String p_templatePath)
          Determines when the indicated template was last modified, in ms since the epoch.
 void loadProperties(String p_path, Properties p_properties)
          Load any properties that might be used to influence the processing of templates within the specified directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileTemplateSource

public FileTemplateSource(String p_templateSourceDir)
Construct a FileTemplateSource

Parameters:
p_templateSourceDir - the source directory

FileTemplateSource

public FileTemplateSource(File p_templateSourceDir)
Construct a FileTemplateSource, using the default extension ".jamon".

Parameters:
p_templateSourceDir - the source directory

FileTemplateSource

public FileTemplateSource(File p_templateSourceDir,
                          String p_extension)
Construct a FileTemplateSource, specifying a filename extension for templates. If the supplied extension is null or empty, no extension is expected, otherwise the extension should NOT include a leading ".".

Parameters:
p_templateSourceDir - the source directory
p_extension - the filename extension for templates
Method Detail

lastModified

public long lastModified(String p_templatePath)
Description copied from interface: TemplateSource
Determines when the indicated template was last modified, in ms since the epoch.

Specified by:
lastModified in interface TemplateSource
Parameters:
p_templatePath - the path to the template
Returns:
the timestamp of when the template was last modified

available

public boolean available(String p_templatePath)
Description copied from interface: TemplateSource
Determines whether the indicated template source is available.

Specified by:
available in interface TemplateSource
Parameters:
p_templatePath - the path to the template
Returns:
whether the template source is available

getStreamFor

public InputStream getStreamFor(String p_templatePath)
                         throws IOException
Description copied from interface: TemplateSource
Get a InputStream for the source of the specified template.

Specified by:
getStreamFor in interface TemplateSource
Parameters:
p_templatePath - the path to the template
Returns:
an InputStream for the data comprising the template
Throws:
IOException

getExternalIdentifier

public String getExternalIdentifier(String p_templatePath)
Description copied from interface: TemplateSource
Get an identifying string for the specified template.

Specified by:
getExternalIdentifier in interface TemplateSource
Parameters:
p_templatePath - the path to the template
Returns:
an identifying string

getTemplateLocation

public TemplateLocation getTemplateLocation(String p_templatePath)
Specified by:
getTemplateLocation in interface TemplateSource

loadProperties

public void loadProperties(String p_path,
                           Properties p_properties)
                    throws IOException
Description copied from interface: TemplateSource
Load any properties that might be used to influence the processing of templates within the specified directory.

Specified by:
loadProperties in interface TemplateSource
Parameters:
p_path - The directory to to look for
p_properties - The Properties instance to add any found properties to.
Throws:
IOException