src/share/classes/javax/tools/ForwardingJavaFileManager.java

Mon, 10 Jan 2011 15:08:31 -0800

author
jjg
date
Mon, 10 Jan 2011 15:08:31 -0800
changeset 816
7c537f4298fb
parent 554
9d9f26857129
child 1357
c75be5bc5283
permissions
-rw-r--r--

6396503: javac should not require assertions enabled
Reviewed-by: mcimadamore

     1 /*
     2  * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package javax.tools;
    28 import java.io.IOException;
    29 import java.net.URI;
    30 import java.util.Iterator;
    31 import java.util.Set;
    32 import javax.tools.JavaFileObject.Kind;
    34 /**
    35  * Forwards calls to a given file manager.  Subclasses of this class
    36  * might override some of these methods and might also provide
    37  * additional fields and methods.
    38  *
    39  * @param <M> the kind of file manager forwarded to by this object
    40  * @author Peter von der Ah&eacute;
    41  * @since 1.6
    42  */
    43 public class ForwardingJavaFileManager<M extends JavaFileManager> implements JavaFileManager {
    45     /**
    46      * The file manager which all methods are delegated to.
    47      */
    48     protected final M fileManager;
    50     /**
    51      * Creates a new instance of ForwardingJavaFileManager.
    52      * @param fileManager delegate to this file manager
    53      */
    54     protected ForwardingJavaFileManager(M fileManager) {
    55         fileManager.getClass(); // null check
    56         this.fileManager = fileManager;
    57     }
    59     /**
    60      * @throws SecurityException {@inheritDoc}
    61      * @throws IllegalStateException {@inheritDoc}
    62      */
    63     public ClassLoader getClassLoader(Location location) {
    64         return fileManager.getClassLoader(location);
    65     }
    67     /**
    68      * @throws IOException {@inheritDoc}
    69      * @throws IllegalStateException {@inheritDoc}
    70      */
    71     public Iterable<JavaFileObject> list(Location location,
    72                                          String packageName,
    73                                          Set<Kind> kinds,
    74                                          boolean recurse)
    75         throws IOException
    76     {
    77         return fileManager.list(location, packageName, kinds, recurse);
    78     }
    80     /**
    81      * @throws IllegalStateException {@inheritDoc}
    82      */
    83     public String inferBinaryName(Location location, JavaFileObject file) {
    84         return fileManager.inferBinaryName(location, file);
    85     }
    87     /**
    88      * @throws IllegalArgumentException {@inheritDoc}
    89      */
    90     public boolean isSameFile(FileObject a, FileObject b) {
    91         return fileManager.isSameFile(a, b);
    92     }
    94     /**
    95      * @throws IllegalArgumentException {@inheritDoc}
    96      * @throws IllegalStateException {@inheritDoc}
    97      */
    98     public boolean handleOption(String current, Iterator<String> remaining) {
    99         return fileManager.handleOption(current, remaining);
   100     }
   102     public boolean hasLocation(Location location) {
   103         return fileManager.hasLocation(location);
   104     }
   106     public int isSupportedOption(String option) {
   107         return fileManager.isSupportedOption(option);
   108     }
   110     /**
   111      * @throws IllegalArgumentException {@inheritDoc}
   112      * @throws IllegalStateException {@inheritDoc}
   113      */
   114     public JavaFileObject getJavaFileForInput(Location location,
   115                                               String className,
   116                                               Kind kind)
   117         throws IOException
   118     {
   119         return fileManager.getJavaFileForInput(location, className, kind);
   120     }
   122     /**
   123      * @throws IllegalArgumentException {@inheritDoc}
   124      * @throws IllegalStateException {@inheritDoc}
   125      */
   126     public JavaFileObject getJavaFileForOutput(Location location,
   127                                                String className,
   128                                                Kind kind,
   129                                                FileObject sibling)
   130         throws IOException
   131     {
   132         return fileManager.getJavaFileForOutput(location, className, kind, sibling);
   133     }
   135     /**
   136      * @throws IllegalArgumentException {@inheritDoc}
   137      * @throws IllegalStateException {@inheritDoc}
   138      */
   139     public FileObject getFileForInput(Location location,
   140                                       String packageName,
   141                                       String relativeName)
   142         throws IOException
   143     {
   144         return fileManager.getFileForInput(location, packageName, relativeName);
   145     }
   147     /**
   148      * @throws IllegalArgumentException {@inheritDoc}
   149      * @throws IllegalStateException {@inheritDoc}
   150      */
   151     public FileObject getFileForOutput(Location location,
   152                                        String packageName,
   153                                        String relativeName,
   154                                        FileObject sibling)
   155         throws IOException
   156     {
   157         return fileManager.getFileForOutput(location, packageName, relativeName, sibling);
   158     }
   160     public void flush() throws IOException {
   161         fileManager.flush();
   162     }
   164     public void close() throws IOException {
   165         fileManager.close();
   166     }
   167 }

mercurial