001: package org.apache.turbine.services.template;
002:
003: /*
004: * Copyright 2001-2005 The Apache Software Foundation.
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License")
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: import org.apache.turbine.services.Service;
020:
021: import org.apache.turbine.util.RunData;
022:
023: /**
024: * This service provides a method for mapping templates to their
025: * appropriate Screens or Navigations. It also allows templates to
026: * define a layout/navigations/screen modularization within the
027: * template structure. It also performs caching if turned on in the
028: * properties file.
029: *
030: * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
031: * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
032: * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
033: * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
034: * @version $Id: TemplateService.java 264148 2005-08-29 14:21:04Z henning $
035: */
036: public interface TemplateService extends Service {
037: /**
038: * The key under which this service is stored in TurbineServices.
039: */
040: static final String SERVICE_NAME = "TemplateService";
041:
042: /** Default Template Name. */
043: String DEFAULT_TEMPLATE_KEY = "default.template";
044:
045: /** Default value for the Template Name */
046: String DEFAULT_TEMPLATE_VALUE = "Default";
047:
048: /** Default Extension for the template names. */
049: String DEFAULT_EXTENSION_KEY = "default.extension";
050:
051: /** Default value of the Turbine Module Caching */
052: String DEFAULT_EXTENSION_VALUE = "";
053:
054: /** Character that separates a Template Name from the Extension */
055: char EXTENSION_SEPARATOR = '.';
056:
057: /** Character that separates the various Template Parts */
058: char TEMPLATE_PARTS_SEPARATOR = ',';
059:
060: /** "Default" name for Classes and Templates */
061: String DEFAULT_NAME = "Default";
062:
063: /**
064: * Returns true if the Template Service has caching activated
065: *
066: * @return true if Caching is active.
067: */
068: boolean isCaching();
069:
070: /**
071: * Get the default template name extension specified
072: * in the template service properties.
073: *
074: * @return The default the extension.
075: */
076: String getDefaultExtension();
077:
078: /**
079: * Return Extension for a supplied template
080: *
081: * @param template The template name
082: *
083: * @return extension The extension for the supplied template
084: */
085: String getExtension(String template);
086:
087: /**
088: * Returns the Default Template Name with the Default Extension.
089: * If the extension is unset, return only the template name
090: *
091: * @return The default template Name
092: */
093: String getDefaultTemplate();
094:
095: /**
096: * Get the default page module name of the template engine
097: * service corresponding to the default template name extension.
098: *
099: * @return The default page module name.
100: */
101: String getDefaultPage();
102:
103: /**
104: * Get the default screen module name of the template engine
105: * service corresponding to the default template name extension.
106: *
107: * @return The default screen module name.
108: */
109: String getDefaultScreen();
110:
111: /**
112: * Get the default layout module name of the template engine
113: * service corresponding to the default template name extension.
114: *
115: * @return The default layout module name.
116: */
117: String getDefaultLayout();
118:
119: /**
120: * Get the default navigation module name of the template engine
121: * service corresponding to the default template name extension.
122: *
123: * @return The default navigation module name.
124: */
125: String getDefaultNavigation();
126:
127: /**
128: * Get the default layout template name of the template engine
129: * service corresponding to the default template name extension.
130: *
131: * @return The default layout template name.
132: */
133: String getDefaultLayoutTemplate();
134:
135: /**
136: * Get the default page module name of the template engine
137: * service corresponding to the template name extension of
138: * the named template.
139: *
140: * @param template The template name.
141: * @return The default page module name.
142: */
143: String getDefaultPageName(String template);
144:
145: /**
146: * Get the default screen module name of the template engine
147: * service corresponding to the template name extension of
148: * the named template.
149: *
150: * @param template The template name.
151: * @return The default screen module name.
152: */
153: String getDefaultScreenName(String template);
154:
155: /**
156: * Get the default layout module name of the template engine
157: * service corresponding to the template name extension of
158: * the named template.
159: *
160: * @param template The template name.
161: * @return The default layout module name.
162: */
163: String getDefaultLayoutName(String template);
164:
165: /**
166: * Get the default navigation module name of the template engine
167: * service corresponding to the template name extension of
168: * the named template.
169: *
170: * @param template The template name.
171: * @return The default navigation module name.
172: */
173: String getDefaultNavigationName(String template);
174:
175: /**
176: * Get the default layout template name of the template engine
177: * service corresponding to the template name extension of
178: * the named template.
179: *
180: * @param template The template name.
181: * @return The default layout template name.
182: */
183: String getDefaultLayoutTemplateName(String template);
184:
185: /**
186: * Find the default page module name for the given request.
187: *
188: * @param data The encapsulation of the request to retrieve the
189: * default page for.
190: * @return The default page module name.
191: */
192: String getDefaultPageName(RunData data);
193:
194: /**
195: * Find the default layout module name for the given request.
196: *
197: * @param data The encapsulation of the request to retrieve the
198: * default layout for.
199: * @return The default layout module name.
200: */
201: String getDefaultLayoutName(RunData data);
202:
203: /**
204: * Locate and return the name of the screen module to be used
205: * with the named screen template.
206: *
207: * @param template The screen template name.
208: * @return The found screen module name.
209: * @exception Exception, a generic exception.
210: */
211: String getScreenName(String template) throws Exception;
212:
213: /**
214: * Locate and return the name of the layout module to be used
215: * with the named layout template.
216: *
217: * @param template The layout template name.
218: * @return The found layout module name.
219: * @exception Exception, a generic exception.
220: */
221: String getLayoutName(String template) throws Exception;
222:
223: /**
224: * Locate and return the name of the navigation module to be used
225: * with the named navigation template.
226: *
227: * @param template The navigation template name.
228: * @return The found navigation module name.
229: * @exception Exception, a generic exception.
230: */
231: String getNavigationName(String name) throws Exception;
232:
233: /**
234: * Locate and return the name of the screen template corresponding
235: * to the given template name parameter.
236: *
237: * @param template The template name parameter.
238: * @return The found screen template name.
239: * @exception Exception, a generic exception.
240: */
241: String getScreenTemplateName(String template) throws Exception;
242:
243: /**
244: * Locate and return the name of the layout template corresponding
245: * to the given screen template name parameter.
246: *
247: * @param template The template name parameter.
248: * @return The found screen template name.
249: * @exception Exception, a generic exception.
250: */
251: String getLayoutTemplateName(String template) throws Exception;
252:
253: /**
254: * Locate and return the name of the navigation template corresponding
255: * to the given template name parameter.
256: *
257: * @param template The template name parameter.
258: * @return The found navigation template name.
259: * @exception Exception, a generic exception.
260: */
261: String getNavigationTemplateName(String template) throws Exception;
262:
263: /**
264: * Translates the supplied template paths into their Turbine-canonical
265: * equivalent (probably absolute paths).
266: *
267: * @param templatePaths An array of template paths.
268: * @return An array of translated template paths.
269: * @deprecated Each template engine service should know how to translate
270: * a request onto a file.
271: */
272: String[] translateTemplatePaths(String[] templatePaths);
273:
274: /**
275: * Delegates to the appropriate {@link
276: * org.apache.turbine.services.template.TemplateEngineService} to
277: * check the existance of the specified template.
278: *
279: * @param template The template to check for the existance of.
280: * @param templatePaths The paths to check for the template.
281: * @deprecated Use templateExists from the various Templating Engines
282: */
283: boolean templateExists(String template, String[] templatePaths);
284:
285: /**
286: * The {@link org.apache.turbine.services.template.TemplateEngineService}
287: * associated with the specified template's file extension.
288: *
289: * @param template The template name.
290: * @return The template engine service.
291: */
292: TemplateEngineService getTemplateEngineService(String template);
293:
294: /**
295: * Registers the provided template engine for use by the
296: * <code>TemplateService</code>.
297: *
298: * @param service The <code>TemplateEngineService</code> to register.
299: */
300: void registerTemplateEngineService(TemplateEngineService service);
301: }
|