org.zodiac.script.engine.java.CharSequenceJavaFileObject Maven / Gradle / Ivy
package org.zodiac.script.engine.java;
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
import java.io.File;
import java.net.URI;
public class CharSequenceJavaFileObject extends SimpleJavaFileObject {
private CharSequence content;
public CharSequenceJavaFileObject(String javaFilePath, String className, CharSequence content) throws Exception {
super(new File(javaFilePath + className.replace('.', '/') + JavaFileObject.Kind.SOURCE.extension).toURI(),
JavaFileObject.Kind.SOURCE);
this.content = content;
}
public CharSequenceJavaFileObject(String className, String content) {
super(URI.create("string:///" + className.replace('.', '/') + Kind.SOURCE.extension), Kind.SOURCE);
this.content = content;
}
@Override
public CharSequence getCharContent(boolean ignoreEncodingErrors) {
return content;
}
}