1 package org.apache.turbine.services.template.mapper;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import org.apache.commons.lang.StringUtils;
20
21 import org.apache.turbine.services.template.TemplateService;
22
23 /***
24 * The most primitive mapper. It is used for the page objects in the
25 * Template service. It never caches and simply returns what is given to it.
26 *
27 * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
28 * @version $Id: DirectMapper.java 264148 2005-08-29 14:21:04Z henning $
29 */
30 public class DirectMapper
31 extends BaseMapper
32 implements Mapper
33 {
34 /***
35 * Default C'tor. If you use this C'tor, you must use
36 * the bean setter to set the various properties needed for
37 * this mapper before first usage.
38 */
39 public DirectMapper()
40 {
41 }
42
43 /***
44 * Strip off a possible extension, replace all "," with "."
45 *
46 * about,directions,Driving.vm --> about.directions.Driving
47 *
48 * @param template The template name.
49 * @return A class name for the given template.
50 */
51 public String doMapping(String template)
52 {
53 String [] components
54 = StringUtils.split(template, String.valueOf(TemplateService.TEMPLATE_PARTS_SEPARATOR));
55
56 String className = components[components.length - 1];
57
58
59 int dotIndex = className.lastIndexOf(TemplateService.EXTENSION_SEPARATOR);
60 className = (dotIndex < 0) ? className : className.substring(0, dotIndex);
61 components[components.length -1] = className;
62
63
64 return StringUtils.join(components, String.valueOf(separator));
65 }
66 }