View Javadoc

1   package org.apache.turbine.services.template.mapper;
2   
3   /*
4    * Copyright 2001-2005 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License")
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import org.apache.commons.lang.StringUtils;
20  
21  import org.apache.turbine.services.template.TemplateService;
22  
23  /***
24   * The most primitive templating mapper. It is used for the navigation template
25   * objects. It never caches and simply returns what is given to it but keeps
26   * the template extension.
27   *
28   * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
29   * @version $Id: DirectTemplateMapper.java 264148 2005-08-29 14:21:04Z henning $
30   */
31  public class DirectTemplateMapper
32      extends BaseTemplateMapper
33      implements Mapper
34  {
35      /***
36       * Default C'tor. If you use this C'tor, you must use
37       * the bean setter to set the various properties needed for
38       * this mapper before first usage.
39       */
40      public DirectTemplateMapper()
41      {
42      }
43  
44      /***
45       * Replace all "," with ".", but keep the extension.
46       *
47       * about,directions,Driving.vm --> about/directions/Driving.vm
48       *
49       * @param template The template name.
50       * @return A class name for the given template.
51       */
52      public String doMapping(String template)
53      {
54          String [] components
55              = StringUtils.split(template, String.valueOf(TemplateService.TEMPLATE_PARTS_SEPARATOR));
56  
57          return StringUtils.join(components, String.valueOf(separator));
58      }
59  }