1 package org.apache.turbine.services.template.mapper; 2 3 4 /* 5 * Licensed to the Apache Software Foundation (ASF) under one 6 * or more contributor license agreements. See the NOTICE file 7 * distributed with this work for additional information 8 * regarding copyright ownership. The ASF licenses this file 9 * to you under the Apache License, Version 2.0 (the 10 * "License"); you may not use this file except in compliance 11 * with the License. You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, 16 * software distributed under the License is distributed on an 17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18 * KIND, either express or implied. See the License for the 19 * specific language governing permissions and limitations 20 * under the License. 21 */ 22 23 24 import org.apache.commons.lang3.StringUtils; 25 import org.apache.turbine.services.template.TemplateService; 26 27 /** 28 * The most primitive mapper. It is used for the page objects in the 29 * Template service. It never caches and simply returns what is given to it. 30 * 31 * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a> 32 * @version $Id: DirectMapper.java 1844792 2018-10-24 21:47:54Z painter $ 33 */ 34 public class DirectMapper 35 extends BaseMapper 36 implements Mapper 37 { 38 /** 39 * Default C'tor. If you use this C'tor, you must use 40 * the bean setter to set the various properties needed for 41 * this mapper before first usage. 42 */ 43 public DirectMapper() 44 { 45 super(); 46 } 47 48 /** 49 * Strip off a possible extension, replace all "," with "." 50 * 51 * about,directions,Driving.vm --< about.directions.Driving 52 * 53 * @param template The template name. 54 * @return A class name for the given template. 55 */ 56 @Override 57 public String doMapping(String template) 58 { 59 String [] components 60 = StringUtils.split(template, String.valueOf(TemplateService.TEMPLATE_PARTS_SEPARATOR)); 61 62 String className = components[components.length - 1]; 63 64 // Strip off a possible Extension 65 int dotIndex = className.lastIndexOf(TemplateService.EXTENSION_SEPARATOR); 66 className = (dotIndex < 0) ? className : className.substring(0, dotIndex); 67 components[components.length -1] = className; 68 69 // Class names are always separated by "." 70 return StringUtils.join(components, String.valueOf(separator)); 71 } 72 }