langtools/src/java.compiler/share/classes/javax/tools/StandardJavaFileManager.java
author jjg
Mon, 17 Apr 2017 14:16:07 -0700
changeset 44690 aec722d1b538
parent 44197 380e1f22e460
permissions -rw-r--r--
8178509: MODULE_SOURCE_PATH: Implement missing methods 8178493: StandardJavaFileManager: Clarify/document the use of IllegalStateException Reviewed-by: jlahoda
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
44019
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
     2
 * Copyright (c) 2006, 2017, 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: 4548
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: 4548
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: 4548
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 4548
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 4548
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.File;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import java.io.IOException;
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
    30
import java.nio.file.Path;
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
    31
import java.util.Arrays;
37944
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
    32
import java.util.Collection;
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
    33
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
    34
import static javax.tools.FileManagerUtils.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
/**
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
    37
 * File manager based on {@linkplain File java.io.File} and {@linkplain Path java.nio.file.Path}.
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
    38
 *
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
    39
 * A common way to obtain an instance of this class is using
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
    40
 * {@linkplain JavaCompiler#getStandardFileManager getStandardFileManager}, for example:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * <pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 *   JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 *   {@code DiagnosticCollector<JavaFileObject>} diagnostics =
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 *       new {@code DiagnosticCollector<JavaFileObject>()};
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 *   StandardJavaFileManager fm = compiler.getStandardFileManager(diagnostics, null, null);
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 * </pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 * This file manager creates file objects representing regular
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 * {@linkplain File files},
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
 * {@linkplain java.util.zip.ZipEntry zip file entries}, or entries in
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 * similar file system based containers.  Any file object returned
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
 * from a file manager implementing this interface must observe the
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
 * following behavior:
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
 * <ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
 *   <li>
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
 *     File names need not be canonical.
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
 *   </li>
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
 *   <li>
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
 *     For file objects representing regular files
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
 *     <ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
 *       <li>
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
 *         the method <code>{@linkplain FileObject#delete()}</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
 *         is equivalent to <code>{@linkplain File#delete()}</code>,
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
 *       </li>
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
 *       <li>
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
 *         the method <code>{@linkplain FileObject#getLastModified()}</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
 *         is equivalent to <code>{@linkplain File#lastModified()}</code>,
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
 *       </li>
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
 *       <li>
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
 *         the methods <code>{@linkplain FileObject#getCharContent(boolean)}</code>,
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
 *         <code>{@linkplain FileObject#openInputStream()}</code>, and
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
 *         <code>{@linkplain FileObject#openReader(boolean)}</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
 *         must succeed if the following would succeed (ignoring
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
 *         encoding issues):
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
 *         <blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
 *           <pre>new {@linkplain java.io.FileInputStream#FileInputStream(File) FileInputStream}(new {@linkplain File#File(java.net.URI) File}({@linkplain FileObject fileObject}.{@linkplain FileObject#toUri() toUri}()))</pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
 *         </blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
 *       </li>
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
 *       <li>
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
 *         and the methods
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
 *         <code>{@linkplain FileObject#openOutputStream()}</code>, and
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
 *         <code>{@linkplain FileObject#openWriter()}</code> must
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
 *         succeed if the following would succeed (ignoring encoding
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
 *         issues):
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
 *         <blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
 *           <pre>new {@linkplain java.io.FileOutputStream#FileOutputStream(File) FileOutputStream}(new {@linkplain File#File(java.net.URI) File}({@linkplain FileObject fileObject}.{@linkplain FileObject#toUri() toUri}()))</pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
 *         </blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
 *       </li>
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
 *     </ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
 *   </li>
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
 *   <li>
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
 *     The {@linkplain java.net.URI URI} returned from
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
 *     <code>{@linkplain FileObject#toUri()}</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
 *     <ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
 *       <li>
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
 *         must be {@linkplain java.net.URI#isAbsolute() absolute} (have a schema), and
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
 *       </li>
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
 *       <li>
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
 *         must have a {@linkplain java.net.URI#normalize() normalized}
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
 *         {@linkplain java.net.URI#getPath() path component} which
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
 *         can be resolved without any process-specific context such
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
 *         as the current directory (file names must be absolute).
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
 *       </li>
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
 *     </ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
 *   </li>
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
 * </ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
 * According to these rules, the following URIs, for example, are
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
 * allowed:
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
 * <ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
 *   <li>
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
 *     <code>file:///C:/Documents%20and%20Settings/UncleBob/BobsApp/Test.java</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
 *   </li>
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
 *   <li>
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   117
 *     <code>jar:///C:/Documents%20and%20Settings/UncleBob/lib/vendorA.jar!/com/vendora/LibraryClass.class</code>
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
 *   </li>
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
 * </ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
 * Whereas these are not (reason in parentheses):
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
 * <ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
 *   <li>
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
 *     <code>file:BobsApp/Test.java</code> (the file name is relative
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
 *     and depend on the current directory)
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
 *   </li>
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
 *   <li>
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   127
 *     <code>jar:lib/vendorA.jar!/com/vendora/LibraryClass.class</code>
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
 *     (the first half of the path depends on the current directory,
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
 *     whereas the component after ! is legal)
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
 *   </li>
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
 *   <li>
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
 *     <code>Test.java</code> (this URI depends on the current
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
 *     directory and does not have a schema)
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
 *   </li>
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
 *   <li>
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
 *     <code>jar:///C:/Documents%20and%20Settings/UncleBob/BobsApp/../lib/vendorA.jar!com/vendora/LibraryClass.class</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
 *     (the path is not normalized)
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
 *   </li>
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
 * </ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
 *
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   141
 * <p>All implementations of this interface must support Path objects representing
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   142
 * files in the {@linkplain java.nio.file.FileSystems#getDefault() default file system.}
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   143
 * It is recommended that implementations should support Path objects from any filesystem.</p>
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   144
 *
44019
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   145
 *
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   146
 * @apiNote
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   147
 * Some methods on this interface take a {@code Collection<? extends Path>}
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   148
 * instead of {@code Iterable<? extends Path>}.
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   149
 * This is to prevent the possibility of accidentally calling the method
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   150
 * with a single {@code Path} as such an argument, because although
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   151
 * {@code Path} implements {@code Iterable<Path>}, it would almost never be
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   152
 * correct to call these methods with a single {@code Path} and have it be treated as
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   153
 * an {@code Iterable} of its components.
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   154
 *
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   155
 *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
 * @author Peter von der Ah&eacute;
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
 * @since 1.6
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
public interface StandardJavaFileManager extends JavaFileManager {
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
     * Compares two file objects and return true if they represent the
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
     * same canonical file, zip file entry, or entry in any file
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
     * system based container.
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
     * @param a a file object
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
     * @param b a file object
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
     * @return true if the given file objects represent the same
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   169
     * canonical file, zip file entry or path; false otherwise
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
     * @throws IllegalArgumentException if either of the arguments
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
     * were created with another file manager implementation
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
     */
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   174
    @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
    boolean isSameFile(FileObject a, FileObject b);
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 5520
diff changeset
   178
     * Returns file objects representing the given files.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
     * @param files a list of files
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
     * @return a list of file objects
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
     * @throws IllegalArgumentException if the list of files includes
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
     * a directory
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
    Iterable<? extends JavaFileObject> getJavaFileObjectsFromFiles(
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
        Iterable<? extends File> files);
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
    /**
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   189
     * Returns file objects representing the given paths.
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   190
     *
37944
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   191
     * @implSpec
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   192
     * The default implementation converts each path to a file and calls
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   193
     * {@link #getJavaFileObjectsFromFiles getJavaObjectsFromFiles}.
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   194
     * IllegalArgumentException will be thrown if any of the paths
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   195
     * cannot be converted to a file.
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   196
     *
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   197
     * @param paths a list of paths
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   198
     * @return a list of file objects
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   199
     * @throws IllegalArgumentException if the list of paths includes
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   200
     * a directory or if this file manager does not support any of the
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   201
     * given paths.
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   202
     *
34912
954fa9df99c7 8146572: Update "@since 1.9" to "@since 9" to match java.version.specification [langtools]
jjg
parents: 28332
diff changeset
   203
     * @since 9
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   204
     */
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   205
    default Iterable<? extends JavaFileObject> getJavaFileObjectsFromPaths(
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   206
            Iterable<? extends Path> paths) {
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   207
        return getJavaFileObjectsFromFiles(asFiles(paths));
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   208
    }
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   209
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   210
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 5520
diff changeset
   211
     * Returns file objects representing the given files.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
     * Convenience method equivalent to:
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
     * <pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
     *     getJavaFileObjectsFromFiles({@linkplain java.util.Arrays#asList Arrays.asList}(files))
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
     * </pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
     * @param files an array of files
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
     * @return a list of file objects
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
     * @throws IllegalArgumentException if the array of files includes
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
     * a directory
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
     * @throws NullPointerException if the given array contains null
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
     * elements
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
    Iterable<? extends JavaFileObject> getJavaFileObjects(File... files);
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
    /**
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   228
     * Returns file objects representing the given paths.
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   229
     * Convenience method equivalent to:
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   230
     *
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   231
     * <pre>
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   232
     *     getJavaFileObjectsFromPaths({@linkplain java.util.Arrays#asList Arrays.asList}(paths))
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   233
     * </pre>
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   234
     *
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   235
     * @param paths an array of paths
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   236
     * @return a list of file objects
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   237
     * @throws IllegalArgumentException if the array of files includes
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   238
     * a directory
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   239
     * @throws NullPointerException if the given array contains null
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   240
     * elements
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   241
     *
34912
954fa9df99c7 8146572: Update "@since 1.9" to "@since 9" to match java.version.specification [langtools]
jjg
parents: 28332
diff changeset
   242
     * @since 9
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   243
     */
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   244
    default Iterable<? extends JavaFileObject> getJavaFileObjects(Path... paths) {
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   245
        return getJavaFileObjectsFromPaths(Arrays.asList(paths));
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   246
    }
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   247
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   248
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 5520
diff changeset
   249
     * Returns file objects representing the given file names.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
     * @param names a list of file names
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
     * @return a list of file objects
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
     * @throws IllegalArgumentException if the list of file names
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
     * includes a directory
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
    Iterable<? extends JavaFileObject> getJavaFileObjectsFromStrings(
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
        Iterable<String> names);
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 5520
diff changeset
   260
     * Returns file objects representing the given file names.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
     * Convenience method equivalent to:
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
     * <pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
     *     getJavaFileObjectsFromStrings({@linkplain java.util.Arrays#asList Arrays.asList}(names))
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
     * </pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
     * @param names a list of file names
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
     * @return a list of file objects
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
     * @throws IllegalArgumentException if the array of file names
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
     * includes a directory
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
     * @throws NullPointerException if the given array contains null
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
     * elements
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
    Iterable<? extends JavaFileObject> getJavaFileObjects(String... names);
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
    /**
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   277
     * Associates the given search path with the given location.  Any
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
     * previous value will be discarded.
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
     *
44019
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   280
     * If the location is a module-oriented or output location, any module-specific
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   281
     * associations set up by {@linkplain #setLocationForModule setLocationForModule}
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   282
     * will be cancelled.
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   283
     *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
     * @param location a location
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   285
     * @param files a list of files, if {@code null} use the default
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   286
     * search path for this location
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
     * @see #getLocation
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   288
     * @throws IllegalArgumentException if {@code location} is an output
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   289
     * location and {@code files} does not contain exactly one element
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   290
     * @throws IOException if {@code location} is an output location and
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
     * does not represent an existing directory
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
     */
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   293
    void setLocation(Location location, Iterable<? extends File> files)
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
        throws IOException;
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
    /**
44019
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   297
     * Associates the given search path with the given location.
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   298
     * Any previous value will be discarded.
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   299
     *
44019
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   300
     * If the location is a module-oriented or output location, any module-specific
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   301
     * associations set up by {@linkplain #setLocationForModule setLocationForModule}
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   302
     * will be cancelled.
37944
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   303
     *
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   304
     * @implSpec
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   305
     * The default implementation converts each path to a file and calls
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   306
     * {@link #getJavaFileObjectsFromFiles getJavaObjectsFromFiles}.
44019
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   307
     * {@linkplain IllegalArgumentException IllegalArgumentException}
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   308
     * will be thrown if any of the paths cannot be converted to a file.
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   309
     *
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   310
     * @param location a location
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   311
     * @param paths a list of paths, if {@code null} use the default
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   312
     * search path for this location
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   313
     * @see #getLocation
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   314
     * @throws IllegalArgumentException if {@code location} is an output
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   315
     * location and {@code paths} does not contain exactly one element
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   316
     * or if this file manager does not support any of the given paths
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   317
     * @throws IOException if {@code location} is an output location and
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   318
     * {@code paths} does not represent an existing directory
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   319
     *
34912
954fa9df99c7 8146572: Update "@since 1.9" to "@since 9" to match java.version.specification [langtools]
jjg
parents: 28332
diff changeset
   320
     * @since 9
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   321
     */
37944
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   322
    default void setLocationFromPaths(Location location, Collection<? extends Path> paths)
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   323
            throws IOException {
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   324
        setLocation(location, asFiles(paths));
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   325
    }
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   326
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   327
    /**
44019
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   328
     * Associates the given search path with the given module and location,
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   329
     * which must be a module-oriented or output location.
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   330
     * Any previous value will be discarded.
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   331
     * This overrides any default association derived from the search path
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   332
     * associated with the location itself.
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   333
     *
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   334
     * All such module-specific associations will be cancelled if a
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   335
     * new search path is associated with the location by calling
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   336
     * {@linkplain #setLocation setLocation } or
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   337
     * {@linkplain #setLocationFromPaths setLocationFromPaths}.
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   338
     *
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   339
     * @throws IllegalStateException if the location is not a module-oriented
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   340
     *  or output location.
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   341
     * @throws UnsupportedOperationException if this operation is not supported by
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   342
     *  this file manager.
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   343
     * @throws IOException if {@code location} is an output location and
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   344
     * {@code paths} does not represent an existing directory
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   345
     *
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   346
     * @param location the location
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   347
     * @param moduleName the name of the module
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   348
     * @param paths the search path to associate with the location and module.
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   349
     *
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   350
     * @see setLocation
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   351
     * @see setLocationFromPaths
44197
380e1f22e460 8176492: @since value errors in java.compiler module
jjg
parents: 44019
diff changeset
   352
     *
380e1f22e460 8176492: @since value errors in java.compiler module
jjg
parents: 44019
diff changeset
   353
     * @since 9
44019
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   354
     */
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   355
    default void setLocationForModule(Location location, String moduleName,
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   356
            Collection<? extends Path> paths) throws IOException {
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   357
        throw new UnsupportedOperationException();
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   358
    }
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   359
284fa2ebd030 8173914: StandardJavaFileManager.setLocationForModule
jjg
parents: 37944
diff changeset
   360
    /**
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   361
     * Returns the search path associated with the given location.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
     * @param location a location
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
     * @return a list of files or {@code null} if this location has no
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   365
     * associated search path
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   366
     * @throws IllegalStateException if any element of the search path
44690
aec722d1b538 8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents: 44197
diff changeset
   367
     * cannot be converted to a {@linkplain File}, or if the search path
aec722d1b538 8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents: 44197
diff changeset
   368
     * cannot be represented as a simple series of files.
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   369
     *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
     * @see #setLocation
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   371
     * @see Path#toFile
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
    Iterable<? extends File> getLocation(Location location);
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   375
    /**
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   376
     * Returns the search path associated with the given location.
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   377
     *
37944
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   378
     * @implSpec
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   379
     * The default implementation calls {@link #getLocation getLocation}
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   380
     * and then returns an {@code Iterable} formed by calling {@code toPath()}
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   381
     * on each {@code File} returned from {@code getLocation}.
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   382
     *
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   383
     * @param location a location
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   384
     * @return a list of paths or {@code null} if this location has no
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   385
     * associated search path
44690
aec722d1b538 8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents: 44197
diff changeset
   386
     * @throws IllegalStateException if the search path cannot be represented
aec722d1b538 8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents: 44197
diff changeset
   387
     * as a simple series of paths.
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   388
     *
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   389
     * @see #setLocationFromPaths
34912
954fa9df99c7 8146572: Update "@since 1.9" to "@since 9" to match java.version.specification [langtools]
jjg
parents: 28332
diff changeset
   390
     * @since 9
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   391
     */
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   392
    default Iterable<? extends Path> getLocationAsPaths(Location location) {
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   393
        return asPaths(getLocation(location));
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   394
    }
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   395
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   396
    /**
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   397
     * Returns the path, if any, underlying this file object (optional operation).
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   398
     * File objects derived from a {@link java.nio.file.FileSystem FileSystem},
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   399
     * including the default file system, typically have a corresponding underlying
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   400
     * {@link java.nio.file.Path Path} object. In such cases, this method may be
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   401
     * used to access that object.
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   402
     *
37944
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   403
     * @implSpec
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   404
     * The default implementation throws {@link UnsupportedOperationException}
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   405
     * for all files.
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   406
     *
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   407
     * @param file a file object
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   408
     * @return a path representing the same underlying file system artifact
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   409
     * @throws IllegalArgumentException if the file object does not have an underlying path
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   410
     * @throws UnsupportedOperationException if the operation is not supported by this file manager
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   411
     *
34912
954fa9df99c7 8146572: Update "@since 1.9" to "@since 9" to match java.version.specification [langtools]
jjg
parents: 28332
diff changeset
   412
     * @since 9
28332
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   413
     */
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   414
    default Path asPath(FileObject file) {
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   415
        throw new UnsupportedOperationException();
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   416
    }
cd3ea1087d2b 8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents: 25874
diff changeset
   417
37944
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   418
    /**
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   419
     * Factory to create {@code Path} objects from strings.
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   420
     *
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   421
     * @since 9
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   422
     */
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   423
    interface PathFactory {
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   424
        /**
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   425
         * Converts a path string, or a sequence of strings that when joined form a path string, to a Path.
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   426
         *
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   427
         * @param first  the path string or initial part of the path string
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   428
         * @param more   additional strings to be joined to form the path string
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   429
         * @return       the resulting {@code Path}
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   430
         */
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   431
        Path getPath(String first, String... more);
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   432
    }
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   433
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   434
     /**
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   435
      * Specify a factory that can be used to generate a path from a string, or series of strings.
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   436
      *
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   437
      * If this method is not called, a factory whose {@code getPath} method is
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   438
      * equivalent to calling
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   439
      * {@link java.nio.file.Paths#get(String, String...) java.nio.file.Paths.get(first, more)}
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   440
      * will be used.
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   441
      *
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   442
      * @implSpec
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   443
      * The default implementation of this method ignores the factory that is provided.
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   444
      *
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   445
      * @param f  the factory
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   446
      *
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   447
      * @since 9
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   448
      */
1153fab98d25 8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents: 34912
diff changeset
   449
    default void setPathFactory(PathFactory f) { }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   450
}