Path: blob/master/src/java.compiler/share/classes/javax/tools/ForwardingJavaFileManager.java
41152 views
/*1* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.tools;2627import java.io.IOException;28import java.util.Iterator;29import java.util.Objects;30import java.util.ServiceLoader;31import java.util.Set;32import javax.tools.JavaFileObject.Kind;3334/**35* Forwards calls to a given file manager. Subclasses of this class36* might override some of these methods and might also provide37* additional fields and methods.38*39* @param <M> the kind of file manager forwarded to by this object40* @author Peter von der Ahé41* @since 1.642*/43public class ForwardingJavaFileManager<M extends JavaFileManager> implements JavaFileManager {4445/**46* The file manager which all methods are delegated to.47*/48protected final M fileManager;4950/**51* Creates a new instance of {@code ForwardingJavaFileManager}.52* @param fileManager delegate to this file manager53*/54protected ForwardingJavaFileManager(M fileManager) {55this.fileManager = Objects.requireNonNull(fileManager);56}5758/**59* @throws SecurityException {@inheritDoc}60* @throws IllegalStateException {@inheritDoc}61*/62@Override63public ClassLoader getClassLoader(Location location) {64return fileManager.getClassLoader(location);65}6667/**68* @throws IOException {@inheritDoc}69* @throws IllegalStateException {@inheritDoc}70*/71@Override72public Iterable<JavaFileObject> list(Location location,73String packageName,74Set<Kind> kinds,75boolean recurse)76throws IOException77{78return fileManager.list(location, packageName, kinds, recurse);79}8081/**82* @throws IllegalStateException {@inheritDoc}83*/84@Override85public String inferBinaryName(Location location, JavaFileObject file) {86return fileManager.inferBinaryName(location, file);87}8889/**90* @throws IllegalArgumentException {@inheritDoc}91*/92@Override93public boolean isSameFile(FileObject a, FileObject b) {94return fileManager.isSameFile(a, b);95}9697/**98* @throws IllegalArgumentException {@inheritDoc}99* @throws IllegalStateException {@inheritDoc}100*/101@Override102public boolean handleOption(String current, Iterator<String> remaining) {103return fileManager.handleOption(current, remaining);104}105106@Override107public boolean hasLocation(Location location) {108return fileManager.hasLocation(location);109}110111@Override112public int isSupportedOption(String option) {113return fileManager.isSupportedOption(option);114}115116/**117* @throws IllegalArgumentException {@inheritDoc}118* @throws IllegalStateException {@inheritDoc}119*/120@Override121public JavaFileObject getJavaFileForInput(Location location,122String className,123Kind kind)124throws IOException125{126return fileManager.getJavaFileForInput(location, className, kind);127}128129/**130* @throws IllegalArgumentException {@inheritDoc}131* @throws IllegalStateException {@inheritDoc}132*/133@Override134public JavaFileObject getJavaFileForOutput(Location location,135String className,136Kind kind,137FileObject sibling)138throws IOException139{140return fileManager.getJavaFileForOutput(location, className, kind, sibling);141}142143/**144* @throws IllegalArgumentException {@inheritDoc}145* @throws IllegalStateException {@inheritDoc}146*/147@Override148public FileObject getFileForInput(Location location,149String packageName,150String relativeName)151throws IOException152{153return fileManager.getFileForInput(location, packageName, relativeName);154}155156/**157* @throws IllegalArgumentException {@inheritDoc}158* @throws IllegalStateException {@inheritDoc}159*/160@Override161public FileObject getFileForOutput(Location location,162String packageName,163String relativeName,164FileObject sibling)165throws IOException166{167return fileManager.getFileForOutput(location, packageName, relativeName, sibling);168}169170@Override171public void flush() throws IOException {172fileManager.flush();173}174175@Override176public void close() throws IOException {177fileManager.close();178}179180/**181* @since 9182*/183@Override184public Location getLocationForModule(Location location, String moduleName) throws IOException {185return fileManager.getLocationForModule(location, moduleName);186}187188/**189* @since 9190*/191@Override192public Location getLocationForModule(Location location, JavaFileObject fo) throws IOException {193return fileManager.getLocationForModule(location, fo);194}195196/**197* @since 9198*/199@Override200public <S> ServiceLoader<S> getServiceLoader(Location location, Class<S> service) throws IOException {201return fileManager.getServiceLoader(location, service);202}203204/**205* @since 9206*/207@Override208public String inferModuleName(Location location) throws IOException {209return fileManager.inferModuleName(location);210}211212/**213* @since 9214*/215@Override216public Iterable<Set<Location>> listLocationsForModules(Location location) throws IOException {217return fileManager.listLocationsForModules(location);218}219220/**221* @since 9222*/223@Override224public boolean contains(Location location, FileObject fo) throws IOException {225return fileManager.contains(location, fo);226}227}228229230