ch.obermuhlner.scriptengine.java.JavaStringObject Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-scriptengine Show documentation
Show all versions of java-scriptengine Show documentation
Java script engine for Java as a scripting language.
package ch.obermuhlner.scriptengine.java;
import javax.tools.SimpleJavaFileObject;
import java.io.IOException;
import java.net.URI;
public class JavaStringObject extends SimpleJavaFileObject {
private final String source;
protected JavaStringObject(String name, String source) {
super(URI.create("string:///" + name.replaceAll("\\.", "/") + Kind.SOURCE.extension), Kind.SOURCE);
this.source = source;
}
@Override
public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
return source;
}
}