KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > service > cmr > repository > TemplateService


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.service.cmr.repository;
18
19 import java.io.Writer JavaDoc;
20
21 /**
22  * Template Service.
23  * <p>
24  * Provides an interface to services for executing template engine against a template file
25  * and data model.
26  * <p>
27  * The service provides a configured list of available template engines. The template file
28  * can either be in the repository (passed as NodeRef string) or on the classpath. The data
29  * model is specified to the template engine. The FreeMarker template engine is used by default.
30  *
31  * @author Kevin Roast
32  */

33 public interface TemplateService
34 {
35     /**
36      * Process a template against the supplied data model and write to the out.
37      *
38      * @param engine Name of the template engine to use
39      * @param template Template (qualified classpath name or noderef)
40      * @param model Object model to process template against
41      *
42      * @return output of the template process as a String
43      */

44     public String JavaDoc processTemplate(String JavaDoc engine, String JavaDoc template, Object JavaDoc model)
45         throws TemplateException;
46     
47     /**
48      * Process a template against the supplied data model and write to the out.
49      *
50      * @param engine Name of the template engine to use
51      * @param template Template (qualified classpath name or noderef)
52      * @param model Object model to process template against
53      * @param out Writer object to send output too
54      */

55     public void processTemplate(String JavaDoc engine, String JavaDoc template, Object JavaDoc model, Writer JavaDoc out)
56         throws TemplateException;
57     
58     /**
59      * Return a TemplateProcessor instance for the specified engine name.
60      * Note that the processor instance is NOT thread safe!
61      *
62      * @param engine Name of the template engine to get or null for default
63      *
64      * @return TemplateProcessor
65      */

66     public TemplateProcessor getTemplateProcessor(String JavaDoc engine);
67 }
68
Popular Tags