org.restlet.ext.freemarker
Class ContextTemplateLoader

java.lang.Object
  extended by org.restlet.ext.freemarker.ContextTemplateLoader
All Implemented Interfaces:
TemplateLoader

public class ContextTemplateLoader
extends Object
implements TemplateLoader

FreeMarker template loader based on a Context's client dispatcher. You can set an instance on a FreeMarker configuration via the Configuration.setTemplateLoader(TemplateLoader) method.

Author:
Jerome Louvel

Constructor Summary
ContextTemplateLoader(Context context, Reference baseRef)
          Constructor.
ContextTemplateLoader(Context context, String baseUri)
          Constructor.
 
Method Summary
 void closeTemplateSource(Object templateSource)
          Close the template source.
 Object findTemplateSource(String name)
          Finds the object that acts as the source of the template with the given name.
 long getLastModified(Object templateSource)
          Returns the modification time.
 Reader getReader(Object templateSource, String characterSet)
          Returns the reader for the template source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextTemplateLoader

public ContextTemplateLoader(Context context,
                             Reference baseRef)
Constructor.

Parameters:
context - The Restlet context.
baseRef - The base reference.

ContextTemplateLoader

public ContextTemplateLoader(Context context,
                             String baseUri)
Constructor.

Parameters:
context - The Restlet context.
baseUri - The base URI.
Method Detail

closeTemplateSource

public void closeTemplateSource(Object templateSource)
                         throws IOException
Close the template source.

Specified by:
closeTemplateSource in interface TemplateLoader
Parameters:
templateSource - The template source Representation.
Throws:
IOException

findTemplateSource

public Object findTemplateSource(String name)
                          throws IOException
Finds the object that acts as the source of the template with the given name.

Specified by:
findTemplateSource in interface TemplateLoader
Parameters:
name - The template name.
Returns:
The template source Representation.
Throws:
IOException

getLastModified

public long getLastModified(Object templateSource)
Returns the modification time.

Specified by:
getLastModified in interface TemplateLoader
Parameters:
templateSource - The template source Representation.
Returns:
The modification time.

getReader

public Reader getReader(Object templateSource,
                        String characterSet)
                 throws IOException
Returns the reader for the template source.

Specified by:
getReader in interface TemplateLoader
Parameters:
templateSource - The template source Representation.
characterSet - The reader character set.
Throws:
IOException


Copyright © 2005-2013 Restlet.