File sourceFile = controllerState.getSourceFile();
if (sourceFile == null)
{
logger.warn("execute(): sourceFile is null, "
+ "returning the empty String");
return new OutletResult("");
}
sourceName = sourceFile.getName();
}
int startFrom = 0;
int endAt = sourceName.length();
if (!StringUtils.isEmpty(discardTo))
{
int position = sourceName.lastIndexOf(discardTo);
if (position != -1)
{
startFrom = position + discardTo.length();
}
}
if (!StringUtils.isEmpty(discardFrom))
{
int position = sourceName.indexOf(discardFrom);
if (position != -1)
{
endAt = position;
}
}
String result;
if (startFrom <= endAt)
{
result = sourceName.substring(startFrom, endAt);
}
else
{
logger.debug("execute(): startFrom is later than endAt, "
+ "returning the empty String");
result = "";
}
result = prefix + result + suffix;
return new OutletResult(result);
}