1 package org.andromda.core.templateengine; 2 3 import java.io.Writer; 4 import java.util.List; 5 import java.util.Map; 6 7 /** 8 * The interface that all templates engines used within AndroMDA must implement. 9 * It allows us to plug-in the template engine to use for processing of 10 * templates used by the system. 11 * 12 * @author Chad Brandon 13 * @author Bob Fields 14 */ 15 public interface TemplateEngine 16 { 17 /** 18 * Initializes the TempateEngine. 19 * 20 * @param namespace The name of a namespace this can be used for whatever the 21 * template engine implementation likes. For example, it can help 22 * determine the name of the log file to which output is logged. 23 * @throws Exception 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<String, Object> 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<String> 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 mergeLocation 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 evaluated. 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<String, Object> templateObjects); 86 }