1 package org.apache.turbine.services.template;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.turbine.services.Service;
23
24 import org.apache.turbine.util.RunData;
25
26 /***
27 * This service provides a method for mapping templates to their
28 * appropriate Screens or Navigations. It also allows templates to
29 * define a layout/navigations/screen modularization within the
30 * template structure. It also performs caching if turned on in the
31 * properties file.
32 *
33 * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
34 * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
35 * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
36 * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
37 * @version $Id: TemplateService.java 534527 2007-05-02 16:10:59Z tv $
38 */
39 public interface TemplateService
40 extends Service
41 {
42 /***
43 * The key under which this service is stored in TurbineServices.
44 */
45 static final String SERVICE_NAME = "TemplateService";
46
47 /*** Default Template Name. */
48 String DEFAULT_TEMPLATE_KEY = "default.template";
49
50 /*** Default value for the Template Name */
51 String DEFAULT_TEMPLATE_VALUE = "Default";
52
53 /*** Default Extension for the template names. */
54 String DEFAULT_EXTENSION_KEY = "default.extension";
55
56 /*** Default value of the Turbine Module Caching */
57 String DEFAULT_EXTENSION_VALUE = "";
58
59 /*** Character that separates a Template Name from the Extension */
60 char EXTENSION_SEPARATOR = '.';
61
62 /*** Character that separates the various Template Parts */
63 char TEMPLATE_PARTS_SEPARATOR = ',';
64
65 /*** "Default" name for Classes and Templates */
66 String DEFAULT_NAME = "Default";
67
68 /***
69 * Returns true if the Template Service has caching activated
70 *
71 * @return true if Caching is active.
72 */
73 boolean isCaching();
74
75 /***
76 * Get the default template name extension specified
77 * in the template service properties.
78 *
79 * @return The default the extension.
80 */
81 String getDefaultExtension();
82
83 /***
84 * Return Extension for a supplied template
85 *
86 * @param template The template name
87 *
88 * @return extension The extension for the supplied template
89 */
90 String getExtension(String template);
91
92 /***
93 * Returns the Default Template Name with the Default Extension.
94 * If the extension is unset, return only the template name
95 *
96 * @return The default template Name
97 */
98 String getDefaultTemplate();
99
100 /***
101 * Get the default page module name of the template engine
102 * service corresponding to the default template name extension.
103 *
104 * @return The default page module name.
105 */
106 String getDefaultPage();
107
108 /***
109 * Get the default screen module name of the template engine
110 * service corresponding to the default template name extension.
111 *
112 * @return The default screen module name.
113 */
114 String getDefaultScreen();
115
116 /***
117 * Get the default layout module name of the template engine
118 * service corresponding to the default template name extension.
119 *
120 * @return The default layout module name.
121 */
122 String getDefaultLayout();
123
124 /***
125 * Get the default navigation module name of the template engine
126 * service corresponding to the default template name extension.
127 *
128 * @return The default navigation module name.
129 */
130 String getDefaultNavigation();
131
132 /***
133 * Get the default layout template name of the template engine
134 * service corresponding to the default template name extension.
135 *
136 * @return The default layout template name.
137 */
138 String getDefaultLayoutTemplate();
139
140 /***
141 * Get the default page module name of the template engine
142 * service corresponding to the template name extension of
143 * the named template.
144 *
145 * @param template The template name.
146 * @return The default page module name.
147 */
148 String getDefaultPageName(String template);
149
150 /***
151 * Get the default screen module name of the template engine
152 * service corresponding to the template name extension of
153 * the named template.
154 *
155 * @param template The template name.
156 * @return The default screen module name.
157 */
158 String getDefaultScreenName(String template);
159
160 /***
161 * Get the default layout module name of the template engine
162 * service corresponding to the template name extension of
163 * the named template.
164 *
165 * @param template The template name.
166 * @return The default layout module name.
167 */
168 String getDefaultLayoutName(String template);
169
170 /***
171 * Get the default navigation module name of the template engine
172 * service corresponding to the template name extension of
173 * the named template.
174 *
175 * @param template The template name.
176 * @return The default navigation module name.
177 */
178 String getDefaultNavigationName(String template);
179
180 /***
181 * Get the default layout template name of the template engine
182 * service corresponding to the template name extension of
183 * the named template.
184 *
185 * @param template The template name.
186 * @return The default layout template name.
187 */
188 String getDefaultLayoutTemplateName(String template);
189
190 /***
191 * Find the default page module name for the given request.
192 *
193 * @param data The encapsulation of the request to retrieve the
194 * default page for.
195 * @return The default page module name.
196 */
197 String getDefaultPageName(RunData data);
198
199 /***
200 * Find the default layout module name for the given request.
201 *
202 * @param data The encapsulation of the request to retrieve the
203 * default layout for.
204 * @return The default layout module name.
205 */
206 String getDefaultLayoutName(RunData data);
207
208 /***
209 * Locate and return the name of the screen module to be used
210 * with the named screen template.
211 *
212 * @param template The screen template name.
213 * @return The found screen module name.
214 * @exception Exception, a generic exception.
215 */
216 String getScreenName(String template)
217 throws Exception;
218
219 /***
220 * Locate and return the name of the layout module to be used
221 * with the named layout template.
222 *
223 * @param template The layout template name.
224 * @return The found layout module name.
225 * @exception Exception, a generic exception.
226 */
227 String getLayoutName(String template)
228 throws Exception;
229
230 /***
231 * Locate and return the name of the navigation module to be used
232 * with the named navigation template.
233 *
234 * @param template The navigation template name.
235 * @return The found navigation module name.
236 * @exception Exception, a generic exception.
237 */
238 String getNavigationName(String name)
239 throws Exception;
240
241 /***
242 * Locate and return the name of the screen template corresponding
243 * to the given template name parameter.
244 *
245 * @param template The template name parameter.
246 * @return The found screen template name.
247 * @exception Exception, a generic exception.
248 */
249 String getScreenTemplateName(String template)
250 throws Exception;
251
252 /***
253 * Locate and return the name of the layout template corresponding
254 * to the given screen template name parameter.
255 *
256 * @param template The template name parameter.
257 * @return The found screen template name.
258 * @exception Exception, a generic exception.
259 */
260 String getLayoutTemplateName(String template)
261 throws Exception;
262
263 /***
264 * Locate and return the name of the navigation template corresponding
265 * to the given template name parameter.
266 *
267 * @param template The template name parameter.
268 * @return The found navigation template name.
269 * @exception Exception, a generic exception.
270 */
271 String getNavigationTemplateName(String template)
272 throws Exception;
273
274 /***
275 * Translates the supplied template paths into their Turbine-canonical
276 * equivalent (probably absolute paths).
277 *
278 * @param templatePaths An array of template paths.
279 * @return An array of translated template paths.
280 * @deprecated Each template engine service should know how to translate
281 * a request onto a file.
282 */
283 String[] translateTemplatePaths(String[] templatePaths);
284
285 /***
286 * Delegates to the appropriate {@link
287 * org.apache.turbine.services.template.TemplateEngineService} to
288 * check the existance of the specified template.
289 *
290 * @param template The template to check for the existance of.
291 * @param templatePaths The paths to check for the template.
292 * @deprecated Use templateExists from the various Templating Engines
293 */
294 boolean templateExists(String template,
295 String[] templatePaths);
296
297
298 /***
299 * The {@link org.apache.turbine.services.template.TemplateEngineService}
300 * associated with the specified template's file extension.
301 *
302 * @param template The template name.
303 * @return The template engine service.
304 */
305 TemplateEngineService getTemplateEngineService(String template);
306
307 /***
308 * Registers the provided template engine for use by the
309 * <code>TemplateService</code>.
310 *
311 * @param service The <code>TemplateEngineService</code> to register.
312 */
313 void registerTemplateEngineService(TemplateEngineService service);
314 }