All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.fge.compiler.FromStringFileObject Maven / Gradle / Ivy

There is a newer version: 0.8.2
Show newest version
package com.github.fge.compiler;

import javax.tools.SimpleJavaFileObject;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

public final class FromStringFileObject
    extends SimpleJavaFileObject
{
    private final String sourceCode;

    public FromStringFileObject(final String fullClassName,
        final String sourceCode)
        throws URISyntaxException
    {
        super(buildURI(fullClassName), Kind.SOURCE);
        this.sourceCode = sourceCode;
    }

    @Override
    public CharSequence getCharContent(final boolean ignoreEncodingErrors)
        throws IOException
    {
        return sourceCode;
    }

    private static URI buildURI(final String fullClassName)
        throws URISyntaxException
    {
        final String path = '/' + fullClassName.replace('.', '/')
            + Kind.SOURCE.extension;
        return new URI("string", null, path, null);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy