1 package pl.aislib.fm;
2
3 import java.util.Map;
4
5 import javax.servlet.http.HttpServletRequest;
6 import javax.servlet.http.HttpServletResponse;
7
8 /***
9 * Generic Template Engine class.
10 *
11 * This class should be extended to implement template engine for specific environment.
12 *
13 * @author
14 * <table>
15 * <tr><td><a href="mailto:pikus@ais.pl">Tomasz Pik</a>, AIS.PL</td></tr>
16 * <tr><td><a href="mailto:warlock@ais.pl">Michal Jastak</a>, AIS.PL</td></tr>
17 * </table>
18 * @version $Revision: 1.3 $
19 * @since AISLIB 0.1
20 */
21 public abstract class TemplateEngine {
22
23
24
25 /***
26 * Gets specified template.
27 *
28 * @param application Parent {@link Application} description.
29 * @param request {@link HttpServletRequest} object.
30 * @param response {@link HttpServletResponse} object.
31 * @param templateName Template which we want to load.
32 * @return specified template object.
33 * @throws TemplateEngineException exception.
34 */
35 public abstract Object load(
36 Application application, HttpServletRequest request, HttpServletResponse response, String templateName
37 ) throws TemplateEngineException;
38
39 /***
40 * Evaluates template.
41 *
42 * @param template <code>Template</code> object.
43 * @param parameters {@link Map} containing evaluation parameters.
44 * @return {@link String} created during evaluation process.
45 * @throws TemplateEngineException exception.
46 */
47 public abstract String evaluate(Object template, Map parameters) throws TemplateEngineException;
48
49 /***
50 * Checks if given object is a template.
51 *
52 * @param object Object which should be checked.
53 * @return <code>true</code> if object given as argument is implementation of Template, <code>false</code> otherwise.
54 */
55 public abstract boolean isTemplate(Object object);
56
57 }