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