
org.abstractmeta.toolbox.compilation.compiler.impl.JavaSourceFileObject Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of compilation-toolbox Show documentation
Show all versions of compilation-toolbox Show documentation
Java compilation and class loading utility
The newest version!
/**
* Copyright 2011 Adrian Witas
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.abstractmeta.toolbox.compilation.compiler.impl;
import javax.tools.SimpleJavaFileObject;
import java.net.URI;
/**
* Provides implementation of SimpleJavaFileObject.
* This implementation stores java source code for a given class.
* Iterable of this type is supplied {@link javax.tools.JavaCompiler#getTask(java.io.Writer, javax.tools.JavaFileManager, javax.tools.DiagnosticListener, Iterable, Iterable, Iterable)}
* to create actual compilation task: {@link javax.tools.JavaCompiler.CompilationTask}
*
* @author Adrian Witas
*/
public class JavaSourceFileObject extends SimpleJavaFileObject {
private final CharSequence source;
protected JavaSourceFileObject(URI uri, CharSequence source) {
super(uri, Kind.SOURCE);
this.source = source;
}
@Override
public CharSequence getCharContent(final boolean ignoreEncodingErrors) throws UnsupportedOperationException {
if (source == null) {
throw new IllegalStateException("source was null");
}
return source;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy