ForwardingJavaFileManager.java revision 3294:9adfb22ff08f
125537Sdfr/*
225537Sdfr * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
325537Sdfr * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
425537Sdfr *
525537Sdfr * This code is free software; you can redistribute it and/or modify it
625537Sdfr * under the terms of the GNU General Public License version 2 only, as
725537Sdfr * published by the Free Software Foundation.  Oracle designates this
825537Sdfr * particular file as subject to the "Classpath" exception as provided
925537Sdfr * by Oracle in the LICENSE file that accompanied this code.
1025537Sdfr *
1125537Sdfr * This code is distributed in the hope that it will be useful, but WITHOUT
1225537Sdfr * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1325537Sdfr * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1425537Sdfr * version 2 for more details (a copy is included in the LICENSE file that
1525537Sdfr * accompanied this code).
1625537Sdfr *
1725537Sdfr * You should have received a copy of the GNU General Public License version
1825537Sdfr * 2 along with this work; if not, write to the Free Software Foundation,
1925537Sdfr * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2025537Sdfr *
2125537Sdfr * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2225537Sdfr * or visit www.oracle.com if you need additional information or have any
2325537Sdfr * questions.
2425537Sdfr */
2525537Sdfr
2646112Sphkpackage javax.tools;
2725537Sdfr
2825537Sdfrimport java.io.IOException;
2940159Speterimport java.util.Iterator;
3040159Speterimport java.util.Objects;
3125537Sdfrimport java.util.ServiceLoader;
3225537Sdfrimport java.util.Set;
3325537Sdfrimport javax.tools.JavaFileObject.Kind;
3425537Sdfr
3525537Sdfr/**
3625537Sdfr * Forwards calls to a given file manager.  Subclasses of this class
3725537Sdfr * might override some of these methods and might also provide
3825537Sdfr * additional fields and methods.
3925537Sdfr *
4040159Speter * @param <M> the kind of file manager forwarded to by this object
4125537Sdfr * @author Peter von der Ah&eacute;
4225537Sdfr * @since 1.6
4331675Sdyson */
4440159Speterpublic class ForwardingJavaFileManager<M extends JavaFileManager> implements JavaFileManager {
4540159Speter
4640159Speter    /**
4740159Speter     * The file manager which all methods are delegated to.
4840159Speter     */
4925537Sdfr    protected final M fileManager;
5040961Speter
5140961Speter    /**
5240961Speter     * Creates a new instance of ForwardingJavaFileManager.
5340961Speter     * @param fileManager delegate to this file manager
5432153Sbde     */
5531324Sbde    protected ForwardingJavaFileManager(M fileManager) {
5640906Speter        this.fileManager = Objects.requireNonNull(fileManager);
5731324Sbde    }
5825537Sdfr
5925537Sdfr    /**
6025537Sdfr     * @throws SecurityException {@inheritDoc}
6125537Sdfr     * @throws IllegalStateException {@inheritDoc}
6225537Sdfr     */
6325537Sdfr    public ClassLoader getClassLoader(Location location) {
6425537Sdfr        return fileManager.getClassLoader(location);
6525537Sdfr    }
6625537Sdfr
6725537Sdfr    /**
6825537Sdfr     * @throws IOException {@inheritDoc}
6925537Sdfr     * @throws IllegalStateException {@inheritDoc}
7025537Sdfr     */
7140159Speter    public Iterable<JavaFileObject> list(Location location,
7225537Sdfr                                         String packageName,
7325537Sdfr                                         Set<Kind> kinds,
7425537Sdfr                                         boolean recurse)
7525537Sdfr        throws IOException
7625537Sdfr    {
7725537Sdfr        return fileManager.list(location, packageName, kinds, recurse);
7825537Sdfr    }
7925537Sdfr
8025537Sdfr    /**
8125537Sdfr     * @throws IllegalStateException {@inheritDoc}
8240395Speter     */
8325537Sdfr    public String inferBinaryName(Location location, JavaFileObject file) {
8425537Sdfr        return fileManager.inferBinaryName(location, file);
8525537Sdfr    }
8625537Sdfr
8725537Sdfr    /**
8825537Sdfr     * @throws IllegalArgumentException {@inheritDoc}
8925537Sdfr     */
9025537Sdfr    public boolean isSameFile(FileObject a, FileObject b) {
9125537Sdfr        return fileManager.isSameFile(a, b);
9225537Sdfr    }
9325537Sdfr
9425537Sdfr    /**
9525537Sdfr     * @throws IllegalArgumentException {@inheritDoc}
9625537Sdfr     * @throws IllegalStateException {@inheritDoc}
9725537Sdfr     */
9825537Sdfr    public boolean handleOption(String current, Iterator<String> remaining) {
9940159Speter        return fileManager.handleOption(current, remaining);
10025537Sdfr    }
10125537Sdfr
10225537Sdfr    public boolean hasLocation(Location location) {
10325537Sdfr        return fileManager.hasLocation(location);
10425537Sdfr    }
10525537Sdfr
10640159Speter    public int isSupportedOption(String option) {
10740159Speter        return fileManager.isSupportedOption(option);
10825537Sdfr    }
10925537Sdfr
11025537Sdfr    /**
11140159Speter     * @throws IllegalArgumentException {@inheritDoc}
11240159Speter     * @throws IllegalStateException {@inheritDoc}
11340159Speter     */
11440159Speter    public JavaFileObject getJavaFileForInput(Location location,
11540159Speter                                              String className,
11640159Speter                                              Kind kind)
11740159Speter        throws IOException
11840159Speter    {
11925537Sdfr        return fileManager.getJavaFileForInput(location, className, kind);
12025537Sdfr    }
12125537Sdfr
12225537Sdfr    /**
12325537Sdfr     * @throws IllegalArgumentException {@inheritDoc}
12425537Sdfr     * @throws IllegalStateException {@inheritDoc}
12525537Sdfr     */
12641055Speter    public JavaFileObject getJavaFileForOutput(Location location,
12741055Speter                                               String className,
12841055Speter                                               Kind kind,
12941055Speter                                               FileObject sibling)
13041055Speter        throws IOException
13125537Sdfr    {
13225537Sdfr        return fileManager.getJavaFileForOutput(location, className, kind, sibling);
13325537Sdfr    }
13425537Sdfr
13525537Sdfr    /**
13625537Sdfr     * @throws IllegalArgumentException {@inheritDoc}
13725537Sdfr     * @throws IllegalStateException {@inheritDoc}
13825537Sdfr     */
13925537Sdfr    public FileObject getFileForInput(Location location,
14025537Sdfr                                      String packageName,
14125537Sdfr                                      String relativeName)
14225537Sdfr        throws IOException
14341055Speter    {
14441055Speter        return fileManager.getFileForInput(location, packageName, relativeName);
14525537Sdfr    }
14625537Sdfr
14741055Speter    /**
14825537Sdfr     * @throws IllegalArgumentException {@inheritDoc}
14925537Sdfr     * @throws IllegalStateException {@inheritDoc}
15041055Speter     */
15125537Sdfr    public FileObject getFileForOutput(Location location,
15225537Sdfr                                       String packageName,
15325537Sdfr                                       String relativeName,
15431675Sdyson                                       FileObject sibling)
15525537Sdfr        throws IOException
15631675Sdyson    {
15731675Sdyson        return fileManager.getFileForOutput(location, packageName, relativeName, sibling);
15831675Sdyson    }
15931675Sdyson
16031675Sdyson    public void flush() throws IOException {
16131675Sdyson        fileManager.flush();
16231675Sdyson    }
16331675Sdyson
16431675Sdyson    public void close() throws IOException {
16531675Sdyson        fileManager.close();
16625537Sdfr    }
16730994Sphk
16830994Sphk    public Location getModuleLocation(Location location, String moduleName) throws IOException {
16925537Sdfr        return fileManager.getModuleLocation(location, moduleName);
17025537Sdfr    }
17125537Sdfr
17241055Speter    public Location getModuleLocation(Location location, JavaFileObject fo, String pkgName) throws IOException {
17325537Sdfr        return fileManager.getModuleLocation(location, fo, pkgName);
17425537Sdfr    }
17525537Sdfr
17625537Sdfr    public <S> ServiceLoader<S> getServiceLoader(Location location, Class<S> service) throws  IOException {
17741055Speter        return fileManager.getServiceLoader(location, service);
17841055Speter    }
17941055Speter
18041055Speter    public String inferModuleName(Location location) throws IOException {
18141055Speter        return fileManager.inferModuleName(location);
18241055Speter    }
18341055Speter
18441055Speter    public Iterable<Set<Location>> listModuleLocations(Location location) throws IOException {
18541055Speter        return fileManager.listModuleLocations(location);
18641055Speter    }
18741055Speter}
18841055Speter