01: package org.apache.turbine.services.template.mapper;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21:
22: import org.apache.commons.lang.StringUtils;
23:
24: import org.apache.turbine.services.template.TemplateService;
25:
26: /**
27: * The most primitive templating mapper. It is used for the navigation template
28: * objects. It never caches and simply returns what is given to it but keeps
29: * the template extension.
30: *
31: * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
32: * @version $Id: DirectTemplateMapper.java 534527 2007-05-02 16:10:59Z tv $
33: */
34: public class DirectTemplateMapper extends BaseTemplateMapper implements
35: Mapper {
36: /**
37: * Default C'tor. If you use this C'tor, you must use
38: * the bean setter to set the various properties needed for
39: * this mapper before first usage.
40: */
41: public DirectTemplateMapper() {
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: String[] components = StringUtils.split(template, String
54: .valueOf(TemplateService.TEMPLATE_PARTS_SEPARATOR));
55:
56: return StringUtils.join(components, String.valueOf(separator));
57: }
58: }
|