diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2013-08-03 12:33:39 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2013-08-03 12:33:39 +0200 |
commit | 34137b599dbea13c94224dff2955376b1394dbc9 (patch) | |
tree | 889b4c334014965e451f8d9b308b952a13b4d8d5 /container-compiler-plugin/src/test/java/io/trygvis/container/compiler/JavaSourceFromString.java | |
parent | 4e794b5ed03e5020770becb068d11e6838feec64 (diff) | |
download | container-playground-34137b599dbea13c94224dff2955376b1394dbc9.tar.gz container-playground-34137b599dbea13c94224dff2955376b1394dbc9.tar.bz2 container-playground-34137b599dbea13c94224dff2955376b1394dbc9.tar.xz container-playground-34137b599dbea13c94224dff2955376b1394dbc9.zip |
wip
Diffstat (limited to 'container-compiler-plugin/src/test/java/io/trygvis/container/compiler/JavaSourceFromString.java')
-rw-r--r-- | container-compiler-plugin/src/test/java/io/trygvis/container/compiler/JavaSourceFromString.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/container-compiler-plugin/src/test/java/io/trygvis/container/compiler/JavaSourceFromString.java b/container-compiler-plugin/src/test/java/io/trygvis/container/compiler/JavaSourceFromString.java new file mode 100644 index 0000000..e07a11f --- /dev/null +++ b/container-compiler-plugin/src/test/java/io/trygvis/container/compiler/JavaSourceFromString.java @@ -0,0 +1,32 @@ +package io.trygvis.container.compiler; + +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import java.net.URI; + +/** + * A file object used to represent source coming from a string. + */ +public class JavaSourceFromString extends SimpleJavaFileObject { + /** + * The source code of this "file". + */ + final String code; + + /** + * Constructs a new JavaSourceFromString. + * + * @param name the name of the compilation unit represented by this file object + * @param code the source code for the compilation unit represented by this file object + */ + JavaSourceFromString(String name, String code) { + super(URI.create("string:///" + name.replace('.', '/') + Kind.SOURCE.extension), + Kind.SOURCE); + this.code = code; + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return code; + } +} |