KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opencms > template > I_CmsTemplate


1 /*
2 * File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/template/I_CmsTemplate.java,v $
3 * Date : $Date: 2005/05/17 13:47:32 $
4 * Version: $Revision: 1.1 $
5 *
6 * This library is part of OpenCms -
7 * the Open Source Content Mananagement System
8 *
9 * Copyright (C) 2001 The OpenCms Group
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * For further information about OpenCms, please see the
22 * OpenCms Website: http://www.opencms.org
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 */

28
29
30 package com.opencms.template;
31
32 import org.opencms.file.CmsObject;
33 import org.opencms.main.CmsException;
34
35 import com.opencms.template.cache.A_CmsElement;
36
37 import java.util.Hashtable JavaDoc;
38
39 /**
40  * Common interface for OpenCms template classes.
41  * Classes and interfaces for each customized template type
42  * have to be implemtented.
43  *
44  * @author Alexander Lucas
45  * @version $Revision: 1.1 $ $Date: 2005/05/17 13:47:32 $
46  *
47  * @deprecated Will not be supported past the OpenCms 6 release.
48  */

49 public interface I_CmsTemplate {
50
51     /**
52      * Gets the content of a given template file with the given parameters.
53      * <P>
54      * Parameters are stored in a hashtable and can derive from
55      * <UL>
56      * <LI>Template file of the parent template</LI>
57      * <LI>Body file clicked by the user</LI>
58      * <LI>URL parameters</LI>
59      * </UL>
60      * Paramter names must be in "elementName.parameterName" format.
61      *
62      * @param cms CmsObject Object for accessing system resources
63      * @param templateFile Filename of the template file
64      * @param elementName Element name of this template in our parent template
65      * @param parameters Hashtable with all template class parameters.
66      * @return Content of the template and all subtemplates.
67      * @throws CmsException
68      */

69     public byte[] getContent(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName, Hashtable JavaDoc parameters) throws CmsException;
70
71     /**
72      * Gets the content of a defined section in a given template file
73      * with the given parameters.
74      *
75      * @see #getContent(CmsObject, String, String, Hashtable, String)
76      * @param cms CmsObject Object for accessing system resources.
77      * @param templateFile Filename of the template file.
78      * @param elementName Element name of this template in our parent template.
79      * @param parameters Hashtable with all template class parameters.
80      * @param templateSelector section that should be processed.
81      * @return Content of the template and all subtemplates.
82      * @throws CmsException
83      */

84     public byte[] getContent(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName, Hashtable JavaDoc parameters, String JavaDoc templateSelector) throws CmsException;
85
86     /**
87      * Gets the key that should be used to cache the results of
88      * <EM>this</EM> template class. For simple template classes, e.g.
89      * classes only dumping file contents and not using parameters,
90      * the name of the template file may be adequate.
91      * Other classes have to return a more complex key.
92      *
93      * @param cms CmsObject Object for accessing system resources
94      * @param templateFile Filename of the template file
95      * @param parameters Hashtable with all template class parameters.
96      * @param templateSelector template section that should be processed.
97      * @return key that can be used for caching
98      */

99     public Object JavaDoc getKey(CmsObject cms, String JavaDoc templateFile, Hashtable JavaDoc parameters, String JavaDoc templateSelector);
100     /**
101      * Indicates if the results of this class are cacheable.
102      * <P>
103      * Complex classes that are able top include other subtemplates
104      * have to check the cacheability of their subclasses here!
105      *
106      * @param cms CmsObject Object for accessing system resources
107      * @param templateFile Filename of the template file
108      * @param elementName Element name of this template in our parent template.
109      * @param parameters Hashtable with all template class parameters.
110      * @param templateSelector template section that should be processed.
111      * @return <EM>true</EM> if cacheable, <EM>false</EM> otherwise.
112      */

113     public boolean isCacheable(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName, Hashtable JavaDoc parameters, String JavaDoc templateSelector);
114
115     /**
116      * Indicates if the results of this class may be cached by public proxy caches.
117      * <P>
118      * Complex classes that are able top include other subtemplates
119      * have to check the cacheability of their subclasses here!
120      *
121      * @param cms CmsObject Object for accessing system resources
122      * @param templateFile Filename of the template file
123      * @param elementName Element name of this template in our parent template.
124      * @param parameters Hashtable with all template class parameters.
125      * @param templateSelector template section that should be processed.
126      * @return <EM>true</EM> if cacheable, <EM>false</EM> otherwise.
127      */

128     public boolean isProxyPrivateCacheable(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName, Hashtable JavaDoc parameters, String JavaDoc templateSelector);
129
130     /**
131      * Indicates if the results of this class may be cached by public proxy caches.
132      * <P>
133      * Complex classes that are able top include other subtemplates
134      * have to check the cacheability of their subclasses here!
135      *
136      * @param cms CmsObject Object for accessing system resources
137      * @param templateFile Filename of the template file
138      * @param elementName Element name of this template in our parent template.
139      * @param parameters Hashtable with all template class parameters.
140      * @param templateSelector template section that should be processed.
141      * @return <EM>true</EM> if cacheable, <EM>false</EM> otherwise.
142      */

143     public boolean isProxyPublicCacheable(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName, Hashtable JavaDoc parameters, String JavaDoc templateSelector);
144
145     /**
146      * Indicates if the results of this class are "static" and may be exported.
147      * <P>
148      * Default conditions are:
149      * <ul>
150      * <li>Resource may be cached by public proxies</li>
151      * <li>There are no parameters in the URL</li>
152      * <li>The resource's internal flag must not be set</li>
153      * </ul>
154      * <P>
155      * Complex classes that are able top include other subtemplates
156      * have to check the cacheability of their subclasses here!
157      *
158      * @param cms CmsObject Object for accessing system resources
159      * @param templateFile Filename of the template file
160      * @param elementName Element name of this template in our parent template.
161      * @param parameters Hashtable with all template class parameters.
162      * @param templateSelector template section that should be processed.
163      * @return <EM>true</EM> if cacheable, <EM>false</EM> otherwise.
164      */

165     public boolean isExportable(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName, Hashtable JavaDoc parameters, String JavaDoc templateSelector);
166
167     /**
168      * Indicates if the current template class is able to stream it's results
169      * directly to the response oputput stream.
170      * <P>
171      * Classes must not set this feature, if they might throw special
172      * exception that cause HTTP errors (e.g. 404/Not Found), or if they
173      * might send HTTP redirects.
174      * <p>
175      * If a class sets this feature, it has to check the
176      * isStreaming() property of the RequestContext. If this is set
177      * to <code>true</code> the results must be streamed directly
178      * to the output stream. If it is <code>false</code> the results
179      * must not be streamed.
180      * <P>
181      * Complex classes that are able top include other subtemplates
182      * have to check the streaming ability of their subclasses here!
183      *
184      * @param cms CmsObject Object for accessing system resources
185      * @param templateFile Filename of the template file
186      * @param elementName Element name of this template in our parent template.
187      * @param parameters Hashtable with all template class parameters.
188      * @param templateSelector template section that should be processed.
189      * @return <EM>true</EM> if this class may stream it's results, <EM>false</EM> otherwise.
190      */

191     public boolean isStreamable(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName, Hashtable JavaDoc parameters, String JavaDoc templateSelector);
192
193     /**
194      * Collect caching informations from the current template class.
195      * <P>
196      * Complex classes that are able to include other subtemplates
197      * have to check the streaming ability of their subclasses here!
198      *
199      * @param cms CmsObject Object for accessing system resources
200      * @param templateFile Filename of the template file
201      * @param elementName Element name of this template in our parent template.
202      * @param parameters Hashtable with all template class parameters.
203      * @param templateSelector template section that should be processed.
204      * @return <EM>true</EM> if this class may stream it's results, <EM>false</EM> otherwise.
205      */

206     public CmsCacheDirectives collectCacheDirectives(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName, Hashtable JavaDoc parameters, String JavaDoc templateSelector);
207
208     /**
209      * Tests, if the template cache is setted.
210      * @return <code>true</code> if setted, <code>false</code> otherwise.
211      */

212     public boolean isTemplateCacheSet();
213
214     /**
215      * Set the instance of template cache that should be used to store
216      * cacheable results of the subtemplates.
217      * If the template cache is not set, caching will be disabled.
218      * @param c Template cache to be used.
219      */

220     public void setTemplateCache(com.opencms.template.I_CmsTemplateCache c);
221
222     /**
223      * Indicates if a previous cached result should be reloaded.
224      *
225      * @param cms CmsObject Object for accessing system resources
226      * @param templateFile Filename of the template file
227      * @param elementName Element name of this template in our parent template.
228      * @param parameters Hashtable with all template class parameters.
229      * @param templateSelector template section that should be processed.
230      * @return <EM>true</EM> if reload is neccesary, <EM>false</EM> otherwise.
231      */

232     public boolean shouldReload(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName, Hashtable JavaDoc parameters, String JavaDoc templateSelector);
233
234     /**
235      * Create a new element for the element cache consisting of the current template
236      * class and the given template file.
237      * <P>
238      * Complex template classes that are able to include other (sub-)templates
239      * must generate a collection of element definitions for their possible
240      * subtemplates. This collection is part of the new element.
241      * @param cms CmsObject for accessing system resources.
242      * @param templateFile Name of the template file for the new element
243      * @param parameters All parameters of the current request
244      * @return New element for the element cache
245      */

246     public A_CmsElement createElement(CmsObject cms, String JavaDoc templateFile, Hashtable JavaDoc parameters);
247 }
248
Popular Tags