langtools/src/share/classes/javax/tools/JavaFileManager.java
author jjg
Thu, 10 Jun 2010 17:09:56 -0700
changeset 5848 c5a4ce47e780
parent 5520 86e4b9a9da40
child 9303 eae35c201e19
permissions -rw-r--r--
6960407: Potential rebranding issues in openjdk/langtools repository sources Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     2
 * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package javax.tools;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import java.io.Closeable;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import java.io.Flushable;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import java.io.IOException;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import java.util.Iterator;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import java.util.Set;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import static javax.tools.JavaFileObject.Kind;
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * File manager for tools operating on Java™ programming language
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * source and class files.  In this context, <em>file</em> means an
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * abstraction of regular files and other sources of data.
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * <p>When constructing new JavaFileObjects, the file manager must
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * determine where to create them.  For example, if a file manager
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * manages regular files on a file system, it would most likely have a
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 * current/working directory to use as default location when creating
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * or finding files.  A number of hints can be provided to a file
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * manager as to where to create files.  Any file manager might choose
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 * to ignore these hints.
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 * <p>Some methods in this interface use class names.  Such class
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 * names must be given in the Java Virtual Machine internal form of
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 * fully qualified class and interface names.  For convenience '.'
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
 * and '/' are interchangeable.  The internal form is defined in
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 * chapter four of the
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
 * <a href="http://java.sun.com/docs/books/vmspec/2nd-edition/jvms-maintenance.html">Java
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
 * Virtual Machine Specification</a>.
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
 * <blockquote><p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
 *   <i>Discussion:</i> this means that the names
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
 *   "java/lang.package-info", "java/lang/package-info",
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
 *   "java.lang.package-info", are valid and equivalent.  Compare to
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
 *   binary name as defined in the
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
 *   <a href="http://java.sun.com/docs/books/jls/">Java Language
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
 *   Specification (JLS)</a> section 13.1 "The Form of a Binary".
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
 * </p></blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
 * <p>The case of names is significant.  All names should be treated
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
 * as case-sensitive.  For example, some file systems have
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
 * case-insensitive, case-aware file names.  File objects representing
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
 * such files should take care to preserve case by using {@link
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
 * java.io.File#getCanonicalFile} or similar means.  If the system is
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
 * not case-aware, file objects must use other means to preserve case.
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
 * <p><em><a name="relative_name">Relative names</a>:</em> some
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
 * methods in this interface use relative names.  A relative name is a
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
 * non-null, non-empty sequence of path segments separated by '/'.
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
 * '.' or '..'  are invalid path segments.  A valid relative name must
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
 * match the "path-rootless" rule of <a
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
 * href="http://www.ietf.org/rfc/rfc3986.txt">RFC&nbsp;3986</a>,
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
 * section&nbsp;3.3.  Informally, this should be true:
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
 * <!-- URI.create(relativeName).normalize().getPath().equals(relativeName) -->
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
 * <pre>  URI.{@linkplain java.net.URI#create create}(relativeName).{@linkplain java.net.URI#normalize normalize}().{@linkplain java.net.URI#getPath getPath}().equals(relativeName)</pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
 * <p>All methods in this interface might throw a SecurityException.
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
 * <p>An object of this interface is not required to support
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
 * multi-threaded access, that is, be synchronized.  However, it must
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
 * support concurrent access to different file objects created by this
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
 * object.
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
 * <p><em>Implementation note:</em> a consequence of this requirement
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
 * is that a trivial implementation of output to a {@linkplain
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
 * java.util.jar.JarOutputStream} is not a sufficient implementation.
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
 * That is, rather than creating a JavaFileObject that returns the
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
 * JarOutputStream directly, the contents must be cached until closed
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
 * and then written to the JarOutputStream.
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
 * <p>Unless explicitly allowed, all methods in this interface might
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
 * throw a NullPointerException if given a {@code null} argument.
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
 * @author Peter von der Ah&eacute;
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
 * @author Jonathan Gibbons
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
 * @see JavaFileObject
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
 * @see FileObject
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
 * @since 1.6
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
public interface JavaFileManager extends Closeable, Flushable, OptionChecker {
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
     * Interface for locations of file objects.  Used by file managers
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
     * to determine where to place or search for file objects.
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
    interface Location {
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
         * Gets the name of this location.
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
         *
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
         * @return a name
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
        String getName();
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
         * Determines if this is an output location.  An output
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
         * location is a location that is conventionally used for
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
         * output.
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
         *
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
         * @return true if this is an output location, false otherwise
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
        boolean isOutputLocation();
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
     * Gets a class loader for loading plug-ins from the given
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
     * location.  For example, to load annotation processors, a
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
     * compiler will request a class loader for the {@link
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     * StandardLocation#ANNOTATION_PROCESSOR_PATH
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
     * ANNOTATION_PROCESSOR_PATH} location.
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     * @param location a location
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
     * @return a class loader for the given location; or {@code null}
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
     * if loading plug-ins from the given location is disabled or if
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
     * the location is not known
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
     * @throws SecurityException if a class loader can not be created
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
     * in the current security context
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
     * @throws IllegalStateException if {@link #close} has been called
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
     * and this file manager cannot be reopened
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
    ClassLoader getClassLoader(Location location);
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
     * Lists all file objects matching the given criteria in the given
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
     * location.  List file objects in "subpackages" if recurse is
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
     * true.
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
     * <p>Note: even if the given location is unknown to this file
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
     * manager, it may not return {@code null}.  Also, an unknown
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
     * location may not cause an exception.
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
     * @param location     a location
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
     * @param packageName  a package name
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
     * @param kinds        return objects only of these kinds
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
     * @param recurse      if true include "subpackages"
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
     * @return an Iterable of file objects matching the given criteria
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
     * @throws IOException if an I/O error occurred, or if {@link
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
     * #close} has been called and this file manager cannot be
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
     * reopened
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
     * @throws IllegalStateException if {@link #close} has been called
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
     * and this file manager cannot be reopened
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
    Iterable<JavaFileObject> list(Location location,
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
                                  String packageName,
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
                                  Set<Kind> kinds,
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
                                  boolean recurse)
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
        throws IOException;
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
     * Infers a binary name of a file object based on a location.  The
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
     * binary name returned might not be a valid JLS binary name.
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
     * @param location a location
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
     * @param file a file object
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
     * @return a binary name or {@code null} the file object is not
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
     * found in the given location
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
     * @throws IllegalStateException if {@link #close} has been called
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
     * and this file manager cannot be reopened
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
    String inferBinaryName(Location location, JavaFileObject file);
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
     * Compares two file objects and return true if they represent the
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
     * same underlying object.
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
     * @param a a file object
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
     * @param b a file object
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
     * @return true if the given file objects represent the same
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
     * underlying object
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
     * @throws IllegalArgumentException if either of the arguments
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
     * were created with another file manager and this file manager
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
     * does not support foreign file objects
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
    boolean isSameFile(FileObject a, FileObject b);
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
     * Handles one option.  If {@code current} is an option to this
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
     * file manager it will consume any arguments to that option from
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
     * {@code remaining} and return true, otherwise return false.
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
     * @param current current option
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
     * @param remaining remaining options
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
     * @return true if this option was handled by this file manager,
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
     * false otherwise
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
     * @throws IllegalArgumentException if this option to this file
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
     * manager is used incorrectly
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
     * @throws IllegalStateException if {@link #close} has been called
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
     * and this file manager cannot be reopened
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
    boolean handleOption(String current, Iterator<String> remaining);
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
     * Determines if a location is known to this file manager.
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
     * @param location a location
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
     * @return true if the location is known
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
    boolean hasLocation(Location location);
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
     * Gets a {@linkplain JavaFileObject file object} for input
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
     * representing the specified class of the specified kind in the
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
     * given location.
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
     * @param location a location
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
     * @param className the name of a class
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
     * @param kind the kind of file, must be one of {@link
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
     * JavaFileObject.Kind#SOURCE SOURCE} or {@link
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
     * JavaFileObject.Kind#CLASS CLASS}
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
     * @return a file object, might return {@code null} if the
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
     * file does not exist
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
     * @throws IllegalArgumentException if the location is not known
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
     * to this file manager and the file manager does not support
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
     * unknown locations, or if the kind is not valid
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
     * @throws IOException if an I/O error occurred, or if {@link
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
     * #close} has been called and this file manager cannot be
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
     * reopened
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
     * @throws IllegalStateException if {@link #close} has been called
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
     * and this file manager cannot be reopened
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
    JavaFileObject getJavaFileForInput(Location location,
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
                                       String className,
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
                                       Kind kind)
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
        throws IOException;
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
     * Gets a {@linkplain JavaFileObject file object} for output
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
     * representing the specified class of the specified kind in the
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
     * given location.
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
     * <p>Optionally, this file manager might consider the sibling as
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
     * a hint for where to place the output.  The exact semantics of
5848
c5a4ce47e780 6960407: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5520
diff changeset
   259
     * this hint is unspecified.  The JDK compiler, javac, for
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
     * example, will place class files in the same directories as
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
     * originating source files unless a class file output directory
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
     * is provided.  To facilitate this behavior, javac might provide
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
     * the originating source file as sibling when calling this
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
     * method.
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
     * @param location a location
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
     * @param className the name of a class
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
     * @param kind the kind of file, must be one of {@link
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
     * JavaFileObject.Kind#SOURCE SOURCE} or {@link
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
     * JavaFileObject.Kind#CLASS CLASS}
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
     * @param sibling a file object to be used as hint for placement;
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
     * might be {@code null}
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
     * @return a file object for output
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
     * @throws IllegalArgumentException if sibling is not known to
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
     * this file manager, or if the location is not known to this file
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
     * manager and the file manager does not support unknown
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
     * locations, or if the kind is not valid
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
     * @throws IOException if an I/O error occurred, or if {@link
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
     * #close} has been called and this file manager cannot be
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
     * reopened
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
     * @throws IllegalStateException {@link #close} has been called
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
     * and this file manager cannot be reopened
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
    JavaFileObject getJavaFileForOutput(Location location,
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
                                        String className,
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
                                        Kind kind,
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
                                        FileObject sibling)
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
        throws IOException;
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
     * Gets a {@linkplain FileObject file object} for input
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
     * representing the specified <a href="JavaFileManager.html#relative_name">relative
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
     * name</a> in the specified package in the given location.
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
     * <p>If the returned object represents a {@linkplain
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
     * JavaFileObject.Kind#SOURCE source} or {@linkplain
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
     * JavaFileObject.Kind#CLASS class} file, it must be an instance
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
     * of {@link JavaFileObject}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
     * <p>Informally, the file object returned by this method is
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
     * located in the concatenation of the location, package name, and
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
     * relative name.  For example, to locate the properties file
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
     * "resources/compiler.properties" in the package
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
     * "com.sun.tools.javac" in the {@linkplain
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
     * StandardLocation#SOURCE_PATH SOURCE_PATH} location, this method
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
     * might be called like so:
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
     * <pre>getFileForInput(SOURCE_PATH, "com.sun.tools.javac", "resources/compiler.properties");</pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
     * <p>If the call was executed on Windows, with SOURCE_PATH set to
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
     * <code>"C:\Documents&nbsp;and&nbsp;Settings\UncleBob\src\share\classes"</code>,
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
     * a valid result would be a file object representing the file
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
     * <code>"C:\Documents&nbsp;and&nbsp;Settings\UncleBob\src\share\classes\com\sun\tools\javac\resources\compiler.properties"</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
     * @param location a location
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
     * @param packageName a package name
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
     * @param relativeName a relative name
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
     * @return a file object, might return {@code null} if the file
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
     * does not exist
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
     * @throws IllegalArgumentException if the location is not known
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
     * to this file manager and the file manager does not support
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
     * unknown locations, or if {@code relativeName} is not valid
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
     * @throws IOException if an I/O error occurred, or if {@link
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
     * #close} has been called and this file manager cannot be
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
     * reopened
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
     * @throws IllegalStateException if {@link #close} has been called
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
     * and this file manager cannot be reopened
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
    FileObject getFileForInput(Location location,
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
                               String packageName,
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
                               String relativeName)
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
        throws IOException;
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
     * Gets a {@linkplain FileObject file object} for output
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
     * representing the specified <a href="JavaFileManager.html#relative_name">relative
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
     * name</a> in the specified package in the given location.
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
     * <p>Optionally, this file manager might consider the sibling as
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
     * a hint for where to place the output.  The exact semantics of
5848
c5a4ce47e780 6960407: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5520
diff changeset
   341
     * this hint is unspecified.  The JDK compiler, javac, for
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
     * example, will place class files in the same directories as
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
     * originating source files unless a class file output directory
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
     * is provided.  To facilitate this behavior, javac might provide
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
     * the originating source file as sibling when calling this
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
     * method.
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
     * <p>If the returned object represents a {@linkplain
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
     * JavaFileObject.Kind#SOURCE source} or {@linkplain
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
     * JavaFileObject.Kind#CLASS class} file, it must be an instance
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
     * of {@link JavaFileObject}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
     * <p>Informally, the file object returned by this method is
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
     * located in the concatenation of the location, package name, and
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
     * relative name or next to the sibling argument.  See {@link
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
     * #getFileForInput getFileForInput} for an example.
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
     * @param location a location
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
     * @param packageName a package name
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
     * @param relativeName a relative name
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
     * @param sibling a file object to be used as hint for placement;
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
     * might be {@code null}
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
     * @return a file object
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
     * @throws IllegalArgumentException if sibling is not known to
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
     * this file manager, or if the location is not known to this file
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
     * manager and the file manager does not support unknown
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
     * locations, or if {@code relativeName} is not valid
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
     * @throws IOException if an I/O error occurred, or if {@link
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
     * #close} has been called and this file manager cannot be
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
     * reopened
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
     * @throws IllegalStateException if {@link #close} has been called
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
     * and this file manager cannot be reopened
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
    FileObject getFileForOutput(Location location,
06bc494ca11e Initial load
duke
parents:
diff changeset
   375
                                String packageName,
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
                                String relativeName,
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
                                FileObject sibling)
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
        throws IOException;
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
     * Flushes any resources opened for output by this file manager
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
     * directly or indirectly.  Flushing a closed file manager has no
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
     * effect.
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
     * @throws IOException if an I/O error occurred
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
     * @see #close
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   388
    void flush() throws IOException;
06bc494ca11e Initial load
duke
parents:
diff changeset
   389
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
     * Releases any resources opened by this file manager directly or
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
     * indirectly.  This might render this file manager useless and
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
     * the effect of subsequent calls to methods on this object or any
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
     * objects obtained through this object is undefined unless
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
     * explicitly allowed.  However, closing a file manager which has
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
     * already been closed has no effect.
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
     * @throws IOException if an I/O error occurred
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
     * @see #flush
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
    void close() throws IOException;
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
}