View Javadoc

1   package org.andromda.core.templateengine;
2   
3   import java.io.Writer;
4   
5   import java.util.List;
6   import java.util.Map;
7   
8   
9   /***
10   * The interface that all templates engines used within AndroMDA must implement.
11   * It allows us to plug-in the template engine to use for processing of
12   * templates used by the system.
13   *
14   * @author Chad Brandon
15   */
16  public interface TemplateEngine
17  {
18      /***
19       * Initializes the TempateEngine.
20       *
21       * @param namespace The name of a namespace this can be used for whatever the
22       *        template engine implementation likes. For example, it can help
23       *        determine the name of the log file to which output is logged.
24       */
25      public void initialize(String namespace)
26          throws Exception;
27  
28      /***
29       * Processes a template.
30       *
31       * @param templateFile the path to the template file that will be processed.
32       * @param templateObjects any additional objects we wish to make available
33       *        to the translation template that is processed
34       * @param output the Writer to which to write the output of the processing.
35       * @throws Exception any exception that may occur
36       */
37      public void processTemplate(
38          String templateFile,
39          Map templateObjects,
40          Writer output)
41          throws Exception;
42  
43      /***
44       * Shuts down the template engine. The meaning of this is defined by the
45       * template engine itself. At least, it should close any logfiles.
46       */
47      public void shutdown();
48  
49      /***
50       * Returns the list of macro libraries used within this template engine.
51       *
52       * @return List the list of macros
53       */
54      public List getMacroLibraries();
55  
56      /***
57       * Adds a a macro library for use within this template engine.
58       *
59       * @param macroLibrary
60       */
61      public void addMacroLibrary(String macroLibrary);
62  
63      /***
64       * Sets the location of <code>merge</code> templates. These are templates
65       * that will be merged into cartridges during processing from an external
66       * location. This allows the ability to define templates external to plugins
67       * so that these templates can override plugin templates in order to provide
68       * customization.
69       *
70       * @param the location of the merge files.
71       */
72      public void setMergeLocation(String mergeLocation);
73      
74      /***
75       * Evaluates the <code>expression</code> contained within the template
76       * being processed and returns the result.
77       *  
78       * @param expression the expression to evaluate.
79       * @param templateObjects any additional objects we wish to make available
80       *        to the template engine when the expression is evaluted.  It this is null
81       *        there will be nothing to be evaluated and therefore this operation will return
82       *        null.
83       * @return the result of the evaluated expression as a String.
84       */
85      public String getEvaluatedExpression(String expression, Map templateObjects);
86  }