View Javadoc

1   package org.apache.turbine.services.template.mapper;
2   
3   
4   /*
5    * Copyright 2001-2004 The Apache Software Foundation.
6    *
7    * Licensed under the Apache License, Version 2.0 (the "License")
8    * you may not use this file except in compliance with the License.
9    * You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  
20  
21  import org.apache.commons.lang.StringUtils;
22  
23  import org.apache.turbine.services.template.TemplateService;
24  
25  /***
26   * The most primitive templating mapper. It is used for the navigation template
27   * objects. It never caches and simply returns what is given to it but keeps
28   * the template extension.
29   *
30   * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
31   * @version $Id: DirectTemplateMapper.java 222043 2004-12-06 17:47:33Z painter $
32   */
33  public class DirectTemplateMapper
34      extends BaseTemplateMapper
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 DirectTemplateMapper()
43      {
44      }
45  
46      /***
47       * Replace all "," with ".", but keep the extension.
48       *
49       * about,directions,Driving.vm --> about/directions/Driving.vm
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          return StringUtils.join(components, String.valueOf(separator));
60      }
61  }