org.norther.tammi.spray.engine
Interface TemplateEngine

All Superinterfaces:
Configurable, Startable
All Known Subinterfaces:
ForwardEngine, FreemarkerEngine, JSPEngine, VelocityEngine
All Known Implementing Classes:
AbstractTemplateEngine, DefaultForwardEngine, DefaultFreemarkerEngine, DefaultJSPEngine, DefaultVelocityEngine

public interface TemplateEngine
extends Configurable, Startable

TemplateEngine is an interface to template engines, such as Velocity, WebMacro, FreeMarker, and JSP.

The template engine can be configured through a property file, which is passed to the implementation of the engine.

Based on TemplateEngineService in the Apache Jakarta Turbine project.

Version:
$Id: TemplateEngine.java,v 1.9 2009/09/28 15:08:27 cvsimp Exp $
Author:
Jason van Zyl, Daniel Rall, Ilkka Priha

Method Summary
 CharSequence evaluate(CharSequence content, TemplateContext context, String template)
          Evaluates the given run-time content.
 CharSequence evaluate(TemplateContext context, String template)
          Evaluates the specified template.
 CharSequence evaluate(TemplateContext context, String template, String encoding)
          Evaluates the specified template using the given encoding.
 void execute(CharSequence content, TemplateContext context, String template, Writer writer)
          Executes the given run-time content.
 void execute(TemplateContext context, String template, String encoding, Writer writer)
          Executes the specified template using the given encoding.
 void execute(TemplateContext context, String template, Writer writer)
          Executes the specified template.
 String getDefaultEncoding()
          Gets the default encoding to apply when not explicitly specified.
 String resolveLocalizedTemplate(String template, Locale locale)
          Resolves a localized template name.
 void setDefaultEncoding(String encoding)
          Sets the default encoding to apply when not explicitly specified.
 boolean templateExists(String template)
          Checks whether a specific template exists.
 
Methods inherited from interface org.norther.tammi.core.config.Configurable
addProperty, addProperty, addPropertyFilePath, addPropertyFilePath, clearProperties, containsProperty, getConfigKey, getProperties, getProperty, getPropertyFilePath, getPropertyFilePaths, indexOfProperty, propertyMap, propertyMap, removeProperty, removeProperty, removePropertyFilePath, setConfigKey, setProperties, setProperty, setPropertyFilePath, setPropertyFilePath, setPropertyFilePaths, setPropertyFilePaths, storeProperties
 
Methods inherited from interface org.norther.tammi.core.base.Startable
isStarted, start, stop
 

Method Detail

getDefaultEncoding

String getDefaultEncoding()
Gets the default encoding to apply when not explicitly specified. If not set, the locale specific encoding of the template is used.

Returns:
the default encoding.

setDefaultEncoding

void setDefaultEncoding(String encoding)
Sets the default encoding to apply when not explicitly specified. If not set, the locale specific encoding of the template is applied.

Parameters:
encoding - the default encoding.

templateExists

boolean templateExists(String template)
Checks whether a specific template exists.

Parameters:
template - the name of the template.
Returns:
true, if the template is available.

resolveLocalizedTemplate

String resolveLocalizedTemplate(String template,
                                Locale locale)
Resolves a localized template name. It searches for a template having the given locale, or any part of it, embedded into its name. The best match will be returned. If a localized template is not found, the method searches for the plain template. The found name or null is returned.

Parameters:
template - the name of the template.
locale - the locale to apply.
Returns:
the localized name, the plain name or null.

evaluate

CharSequence evaluate(CharSequence content,
                      TemplateContext context,
                      String template)
                      throws TemplateException
Evaluates the given run-time content.

Parameters:
content - the content.
context - the context.
template - a virtual template for identifying the content.
Returns:
the evaluated content.
Throws:
TemplateException - if processing fails.

evaluate

CharSequence evaluate(TemplateContext context,
                      String template)
                      throws TemplateException
Evaluates the specified template.

Parameters:
context - the context.
template - the name of the template.
Returns:
the evaluated template.
Throws:
TemplateException - if processing fails.

evaluate

CharSequence evaluate(TemplateContext context,
                      String template,
                      String encoding)
                      throws TemplateException
Evaluates the specified template using the given encoding.

Parameters:
context - the context.
template - the name of the template.
encoding - an optional template encoding.
Returns:
the evaluated template.
Throws:
TemplateException - if processing fails.

execute

void execute(CharSequence content,
             TemplateContext context,
             String template,
             Writer writer)
             throws TemplateException
Executes the given run-time content.

Parameters:
content - the content.
context - the context.
template - a virtual template for identifying the content.
writer - a writer for the result.
Throws:
TemplateException - if processing fails.

execute

void execute(TemplateContext context,
             String template,
             Writer writer)
             throws TemplateException
Executes the specified template.

Parameters:
context - the context.
template - the name of the template.
writer - a writer for the result.
Throws:
TemplateException - if processing fails.

execute

void execute(TemplateContext context,
             String template,
             String encoding,
             Writer writer)
             throws TemplateException
Executes the specified template using the given encoding.

Parameters:
context - the context.
template - the name of the template.
encoding - an optional template encoding.
writer - a writer for the result.
Throws:
TemplateException - if processing fails.


Copyright © 2004 The Norther Organization. All rights reserved.