class ScriptEngineMappingStrategy {
/**
* Returns the extension (the part after the last ".") of the given script.
*
* @param scriptName the name of the script to return the extension of.
* @return the extension of the script or <code>null</code> if there is no extension.
*/
protected static String getExtension(String scriptName)
{
if (scriptName == null)
{
return null;
}
int filePosition = scriptName.lastIndexOf("/");
String fileName;
if (scriptName.lastIndexOf("\\") > filePosition)
{
filePosition = scriptName.lastIndexOf("\\");
}
if (filePosition >= 0)
{
fileName = scriptName.substring(filePosition + 1);
}
else
{
fileName = scriptName;
}
final int extensionPosition = fileName.lastIndexOf(".");
if (extensionPosition >= 0)
{
return fileName.substring(extensionPosition + 1);
}
return null;
}
}