Package org.restlet.ext.freemarker
Class ContextTemplateLoader
- java.lang.Object
-
- org.restlet.ext.freemarker.ContextTemplateLoader
-
- All Implemented Interfaces:
freemarker.cache.TemplateLoader
public class ContextTemplateLoader extends java.lang.Object implements freemarker.cache.TemplateLoaderFreeMarker template loader based on a Context's client dispatcher. You can set an instance on a FreeMarker configuration via theConfiguration.setTemplateLoader(TemplateLoader)method.- Author:
- Jerome Louvel
-
-
Constructor Summary
Constructors Constructor Description ContextTemplateLoader(org.restlet.Context context, java.lang.String baseUri)Constructor.ContextTemplateLoader(org.restlet.Context context, org.restlet.data.Reference baseRef)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseTemplateSource(java.lang.Object templateSource)Close the template source.java.lang.ObjectfindTemplateSource(java.lang.String name)Finds the object that acts as the source of the template with the given name.longgetLastModified(java.lang.Object templateSource)Returns the modification time.java.io.ReadergetReader(java.lang.Object templateSource, java.lang.String characterSet)Returns the reader for the template source.
-
-
-
Constructor Detail
-
ContextTemplateLoader
public ContextTemplateLoader(org.restlet.Context context, org.restlet.data.Reference baseRef)Constructor.- Parameters:
context- The Restlet context.baseRef- The base reference.
-
ContextTemplateLoader
public ContextTemplateLoader(org.restlet.Context context, java.lang.String baseUri)Constructor.- Parameters:
context- The Restlet context.baseUri- The base URI.
-
-
Method Detail
-
closeTemplateSource
public void closeTemplateSource(java.lang.Object templateSource) throws java.io.IOExceptionClose the template source.- Specified by:
closeTemplateSourcein interfacefreemarker.cache.TemplateLoader- Parameters:
templateSource- The template sourceRepresentation.- Throws:
java.io.IOException
-
findTemplateSource
public java.lang.Object findTemplateSource(java.lang.String name) throws java.io.IOExceptionFinds the object that acts as the source of the template with the given name.- Specified by:
findTemplateSourcein interfacefreemarker.cache.TemplateLoader- Parameters:
name- The template name.- Returns:
- The template source
Representation. - Throws:
java.io.IOException
-
getLastModified
public long getLastModified(java.lang.Object templateSource)
Returns the modification time.- Specified by:
getLastModifiedin interfacefreemarker.cache.TemplateLoader- Parameters:
templateSource- The template sourceRepresentation.- Returns:
- The modification time.
-
getReader
public java.io.Reader getReader(java.lang.Object templateSource, java.lang.String characterSet) throws java.io.IOExceptionReturns the reader for the template source.- Specified by:
getReaderin interfacefreemarker.cache.TemplateLoader- Parameters:
templateSource- The template sourceRepresentation.characterSet- The reader character set.- Throws:
java.io.IOException
-
-