org.snapscript.studio.agent.debug.ResourceExtractor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snap-agent Show documentation
Show all versions of snap-agent Show documentation
Dynamic scripting for the JVM
package org.snapscript.studio.agent.debug;
public class ResourceExtractor {
private static final String SOURCE_SUFFIX = ".snap";
public static String extractModule(String path) {
int length = path.length();
if(path.endsWith(SOURCE_SUFFIX)) {
path = path.substring(0, length - 5);
}
if(path.startsWith("/")) {
path = path.substring(1);
}
return path.replace('/', '.');
}
public static String extractResource(String module) {
String path = module;
if(!path.startsWith("/")) {
path = "/" + path;
}
if(!path.endsWith(SOURCE_SUFFIX)) {
path = path.replace('.', '/');
path = path + SOURCE_SUFFIX;
}
return path;
}
}