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