org.clapper.curn.output.freemarker
Class CurnTemplateLoader

java.lang.Object
  extended by org.clapper.curn.output.freemarker.CurnTemplateLoader
All Implemented Interfaces:
freemarker.cache.TemplateLoader

public class CurnTemplateLoader
extends java.lang.Object
implements freemarker.cache.TemplateLoader

Version:
$Revision: 6490 $

Method Summary
 void closeTemplateSource(java.lang.Object templateSource)
          Closes the template source.
 java.lang.Object findTemplateSource(java.lang.String name)
          Finds the object that acts as the source of the template with the given name.
 long getLastModified(java.lang.Object templateSource)
          Returns the time of last modification of the specified template source.
 java.io.Reader getReader(java.lang.Object templateSource, java.lang.String encoding)
          Returns the character stream of a template represented by the specified template source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

findTemplateSource

public java.lang.Object findTemplateSource(java.lang.String name)
                                    throws java.io.IOException
Finds the object that acts as the source of the template with the given name. According to FreeMarker documentation, this method is called by the TemplateCache when a template is requested, before calling either getLastModified(Object) or getReader(Object, String).

Specified by:
findTemplateSource in interface freemarker.cache.TemplateLoader
Parameters:
name - the name of the template, already localized and normalized
Returns:
an object representing the template source, which can be supplied in subsequent calls to getLastModified(Object) and getReader(Object, String). Null will be returned if the source for the template can not be found.
Throws:
java.io.IOException - on error

getLastModified

public long getLastModified(java.lang.Object templateSource)
Returns the time of last modification of the specified template source. This method is called after findTemplateSource(String).

Specified by:
getLastModified in interface freemarker.cache.TemplateLoader
Parameters:
templateSource - an object representing a template source, obtained through a prior call to findTemplateSource(String).
Returns:
the time of last modification of the specified template source, or -1 if the time is not known.

getReader

public java.io.Reader getReader(java.lang.Object templateSource,
                                java.lang.String encoding)
                         throws java.io.IOException
Returns the character stream of a template represented by the specified template source. This method is called after getLastModified(java.lang.Object) if it is determined that a cached copy of the template is unavailable or stale.

Specified by:
getReader in interface freemarker.cache.TemplateLoader
Parameters:
templateSource - an object representing a template source, obtained through a prior call to findTemplateSource(String).
encoding - the character encoding used to translate source bytes to characters.
Returns:
a Reader representing the template character stream.
Throws:
java.io.IOException - if an I/O error occurs while accessing the stream.

closeTemplateSource

public void closeTemplateSource(java.lang.Object templateSource)
                         throws java.io.IOException
Closes the template source. This is the last method that is called by the FreeMarker TemplateCache for a template source. The framework guarantees that this method will be called on every object that is returned from findTemplateSource(String).

Specified by:
closeTemplateSource in interface freemarker.cache.TemplateLoader
Parameters:
templateSource - the template source that should be closed.
Throws:
java.io.IOException


Copyright © 2004-2006 Brian M. Clapper. All Rights Reserved.