    001    package org.apache.turbine.services.template.mapper;
    002
    003
    004    /*
    005     * Licensed to the Apache Software Foundation (ASF) under one
    006     * or more contributor license agreements.  See the NOTICE file
    007     * distributed with this work for additional information
    008     * regarding copyright ownership.  The ASF licenses this file
    009     * to you under the Apache License, Version 2.0 (the
    010     * "License"); you may not use this file except in compliance
    011     * with the License.  You may obtain a copy of the License at
    012     *
    013     *   http://www.apache.org/licenses/LICENSE-2.0
    014     *
    015     * Unless required by applicable law or agreed to in writing,
    016     * software distributed under the License is distributed on an
    017     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    018     * KIND, either express or implied.  See the License for the
    019     * specific language governing permissions and limitations
    020     * under the License.
    021     */
    022
    023
    024    import org.apache.commons.lang.StringUtils;
    025    import org.apache.turbine.services.template.TemplateService;
    026
    027    /**
    028     * The most primitive templating mapper. It is used for the navigation template
    029     * objects. It never caches and simply returns what is given to it but keeps
    030     * the template extension.
    031     *
    032     * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
    033     * @version $Id: DirectTemplateMapper.java 1078552 2011-03-06 19:58:46Z tv $
    034     */
    035    public class DirectTemplateMapper
    036        extends BaseTemplateMapper
    037        implements Mapper
    038    {
    039        /**
    040         * Default C'tor. If you use this C'tor, you must use
    041         * the bean setter to set the various properties needed for
    042         * this mapper before first usage.
    043         */
    044        public DirectTemplateMapper()
    045        {
    046            super();
    047        }
    048
    049        /**
    050         * Replace all "," with ".", but keep the extension.
    051         *
    052         * about,directions,Driving.vm --> about/directions/Driving.vm
    053         *
    054         * @param template The template name.
    055         * @return A class name for the given template.
    056         */
    057        @Override
    058        public String doMapping(String template)
    059        {
    060            String [] components
    061                = StringUtils.split(template, String.valueOf(TemplateService.TEMPLATE_PARTS_SEPARATOR));
    062
    063            return StringUtils.join(components, String.valueOf(separator));
    064        }
    065    }