org.andromda.core.templateengine
Interface TemplateEngine


public interface TemplateEngine

The interface that all templates engines used within AndroMDA must implement. It allows us to plug-in the template engine to use for processing of templates used by the system.

Author:
Chad Brandon, Bob Fields

Method Summary
 void addMacroLibrary(String macroLibrary)
          Adds a a macro library for use within this template engine.
 String getEvaluatedExpression(String expression, Map<String,Object> templateObjects)
          Evaluates the expression contained within the template being processed and returns the result.
 List<String> getMacroLibraries()
          Returns the list of macro libraries used within this template engine.
 void initialize(String namespace)
          Initializes the TempateEngine.
 void processTemplate(String templateFile, Map<String,Object> templateObjects, Writer output)
          Processes a template.
 void setMergeLocation(String mergeLocation)
          Sets the location of merge templates.
 void shutdown()
          Shuts down the template engine.
 

Method Detail

initialize

void initialize(String namespace)
                throws Exception
Initializes the TempateEngine.

Parameters:
namespace - The name of a namespace this can be used for whatever the template engine implementation likes. For example, it can help determine the name of the log file to which output is logged.
Throws:
Exception

processTemplate

void processTemplate(String templateFile,
                     Map<String,Object> templateObjects,
                     Writer output)
                     throws Exception
Processes a template.

Parameters:
templateFile - the path to the template file that will be processed.
templateObjects - any additional objects we wish to make available to the translation template that is processed
output - the Writer to which to write the output of the processing.
Throws:
Exception - any exception that may occur

shutdown

void shutdown()
Shuts down the template engine. The meaning of this is defined by the template engine itself. At least, it should close any logfiles.


getMacroLibraries

List<String> getMacroLibraries()
Returns the list of macro libraries used within this template engine.

Returns:
List the list of macros

addMacroLibrary

void addMacroLibrary(String macroLibrary)
Adds a a macro library for use within this template engine.

Parameters:
macroLibrary -

setMergeLocation

void setMergeLocation(String mergeLocation)
Sets the location of merge templates. These are templates that will be merged into cartridges during processing from an external location. This allows the ability to define templates external to plugins so that these templates can override plugin templates in order to provide customization.

Parameters:
mergeLocation - the location of the merge files.

getEvaluatedExpression

String getEvaluatedExpression(String expression,
                              Map<String,Object> templateObjects)
Evaluates the expression contained within the template being processed and returns the result.

Parameters:
expression - the expression to evaluate.
templateObjects - any additional objects we wish to make available to the template engine when the expression is evaluated. It this is null there will be nothing to be evaluated and therefore this operation will return null.
Returns:
the result of the evaluated expression as a String.


Copyright © 2003-2012 AndroMDA.org. All Rights Reserved.