in src/java/org/apache/turbine/services/template/mapper/ClassMapper.java [102:178]
public String doMapping(String template)
{
log.debug("doMapping({})", template);
// Copy our elements into an array
List<String> components
= new ArrayList<>(Arrays.asList(StringUtils.split(
template,
String.valueOf(TemplateService.TEMPLATE_PARTS_SEPARATOR))));
int componentSize = components.size() - 1 ;
// This method never gets an empty string passed.
// So this is never < 0
String className = components.get(componentSize);
components.remove(componentSize--);
log.debug("className is {}", className);
// Strip off a possible Extension
int dotIndex = className.lastIndexOf(TemplateService.EXTENSION_SEPARATOR);
className = (dotIndex < 0) ? className : className.substring(0, dotIndex);
// This is an optimization. If the name we're looking for is
// already the default name for the template, don't do a "first run"
// which looks for an exact match.
boolean firstRun = !className.equals(TemplateService.DEFAULT_NAME);
for(;;)
{
String pkg = StringUtils.join(components.iterator(), String.valueOf(separator));
StringBuilder testName = new StringBuilder();
log.debug("classPackage is now: {}", pkg);
if (!components.isEmpty())
{
testName.append(pkg);
testName.append(separator);
}
testName.append((firstRun)
? className
: TemplateService.DEFAULT_NAME);
log.debug("Looking for {}", testName);
try
{
loader.getAssembler(testName.toString());
log.debug("Found it, returning {}", testName);
return testName.toString();
}
catch (TurbineException e)
{
log.error("Turbine Exception Class mapping", e);
}
catch (Exception e)
{
// Not found. Go on.
}
if (firstRun)
{
firstRun = false;
}
else
{
if (components.isEmpty())
{
break; // for(;;)
}
components.remove(componentSize--);
}
}
log.debug("Returning default");
return getDefaultName(template);
}