1 package org.apache.turbine.services.template.mapper; 2 3 18 19 import org.apache.commons.lang.StringUtils; 20 21 import org.apache.turbine.services.template.TemplateService; 22 import org.apache.turbine.services.template.TurbineTemplate; 23 24 32 33 public abstract class BaseTemplateMapper 34 extends BaseMapper 35 { 36 37 protected String prefix = ""; 38 39 44 public BaseTemplateMapper() 45 { 46 super(); 47 } 48 49 53 public String getPrefix() 54 { 55 return prefix; 56 } 57 58 62 public void setPrefix(String prefix) 63 { 64 this.prefix = prefix; 65 } 66 67 78 public String getDefaultName(String template) 79 { 80 String res = super.getDefaultName(template); 81 82 String [] components 84 = StringUtils.split(res, String.valueOf(separator)); 85 86 if (components[components.length -1 ].indexOf(TemplateService.EXTENSION_SEPARATOR) < 0) 87 { 88 StringBuffer resBuf = new StringBuffer (); 89 resBuf.append(res); 90 String [] templateComponents = StringUtils.split(template, String.valueOf(TemplateService.TEMPLATE_PARTS_SEPARATOR)); 91 92 int dotIndex = templateComponents[templateComponents.length -1].lastIndexOf(TemplateService.EXTENSION_SEPARATOR); 94 if (dotIndex < 0) 95 { 96 if (StringUtils.isNotEmpty(TurbineTemplate.getDefaultExtension())) 97 { 98 resBuf.append(TemplateService.EXTENSION_SEPARATOR); 99 resBuf.append(TurbineTemplate.getDefaultExtension()); 100 } 101 } 102 else 103 { 104 resBuf.append(templateComponents[templateComponents.length -1].substring(dotIndex)); 105 } 106 res = resBuf.toString(); 107 } 108 return res; 109 } 110 } 111 | Popular Tags |