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