KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > format > template > Template


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9
10 package org.jboss.portal.format.template;
11
12 import java.io.StringWriter JavaDoc;
13 import java.io.Writer JavaDoc;
14
15 import org.apache.log4j.Logger;
16
17 /**
18  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
19  */

20 public abstract class Template
21 {
22
23    public final Logger log = Logger.getLogger(getClass());
24
25    protected final Context local;
26
27    public Template(Context local)
28    {
29       this.local = local;
30    }
31
32    public final String JavaDoc render(Context ctx)
33    {
34       StringWriter JavaDoc writer = new StringWriter JavaDoc();
35       render(ctx, writer);
36       return writer.toString();
37    }
38
39    public final Context getLocalContext()
40    {
41       return local;
42    }
43
44    /**
45     * This may be subclassed.
46     */

47    public void render(Context ctx, Writer JavaDoc writer)
48    {
49    }
50
51 }
52
Popular Tags