org.jamon
Class ResourceTemplateSource

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

public class ResourceTemplateSource
extends Object
implements TemplateSource

An implementation of TemplateSource which retrieves templates from Java resources.


Constructor Summary
ResourceTemplateSource(ClassLoader p_classLoader, String p_templateSourceDir)
           
ResourceTemplateSource(ClassLoader p_classLoader, String p_templateSourceDir, String p_extension)
          Construct a ResourceTemplateSource, specifying a filename extension for templates.
 
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_dirPath, 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

ResourceTemplateSource

public ResourceTemplateSource(ClassLoader p_classLoader,
                              String p_templateSourceDir)

ResourceTemplateSource

public ResourceTemplateSource(ClassLoader p_classLoader,
                              String p_templateSourceDir,
                              String p_extension)
Construct a ResourceTemplateSource, 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_classLoader - the classloader to use to load resources
p_templateSourceDir - the source directory
p_extension - the filename extension for templates
Method Detail

lastModified

public long lastModified(String p_templatePath)
                  throws IOException
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
Throws:
IOException

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_dirPath,
                           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_dirPath - The directory to to look for
p_properties - The Properties instance to add any found properties to.
Throws:
IOException