/* * Copyright 2015 Odnoklassniki Ltd, Mail.Ru Group * * 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 one.nio.compiler; import javax.lang.model.element.Modifier; import javax.lang.model.element.NestingKind; import javax.tools.JavaFileObject; import java.io.InputStream; import java.io.OutputStream; import java.io.Reader; import java.io.Writer; import java.net.URI; class MemoryOutputFileObject implements JavaFileObject { private final OutputStream out; public MemoryOutputFileObject(OutputStream out) { this.out = out; } @Override public Kind getKind() { return Kind.CLASS; } @Override public boolean isNameCompatible(String simpleName, Kind kind) { return kind == Kind.CLASS; } @Override public NestingKind getNestingKind() { return null; } @Override public Modifier getAccessLevel() { return null; } @Override public URI toUri() { return URI.create("mem:///" + getName()); } @Override public String getName() { return "MemoryOutputFileObject.class"; } @Override public InputStream openInputStream() { throw new UnsupportedOperationException(); } @Override public OutputStream openOutputStream() { return out; } @Override public Reader openReader(boolean ignoreEncodingErrors) { throw new UnsupportedOperationException(); } @Override public CharSequence getCharContent(boolean ignoreEncodingErrors) { throw new UnsupportedOperationException(); } @Override public Writer openWriter() { throw new UnsupportedOperationException(); } @Override public long getLastModified() { return 0; } @Override public boolean delete() { return false; } }