author | naoto |
Fri, 16 Feb 2018 14:03:34 -0800 | |
changeset 48910 | 67cdc215ed70 |
parent 48456 | b51755ee57f6 |
child 54298 | 6207397a6603 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
48456 | 2 |
* Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. |
10 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
10 | 24 |
*/ |
25 |
||
26 |
package javax.tools; |
|
27 |
||
28 |
import java.io.File; |
|
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; |
48456 | 33 |
import java.util.Iterator; |
10 | 34 |
|
35 |
/** |
|
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
36 |
* 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
|
37 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
38 |
* 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
|
39 |
* {@linkplain JavaCompiler#getStandardFileManager getStandardFileManager}, for example: |
10 | 40 |
* |
41 |
* <pre> |
|
42 |
* JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); |
|
43 |
* {@code DiagnosticCollector<JavaFileObject>} diagnostics = |
|
44 |
* new {@code DiagnosticCollector<JavaFileObject>()}; |
|
45 |
* StandardJavaFileManager fm = compiler.getStandardFileManager(diagnostics, null, null); |
|
46 |
* </pre> |
|
47 |
* |
|
48 |
* This file manager creates file objects representing regular |
|
49 |
* {@linkplain File files}, |
|
50 |
* {@linkplain java.util.zip.ZipEntry zip file entries}, or entries in |
|
51 |
* similar file system based containers. Any file object returned |
|
52 |
* from a file manager implementing this interface must observe the |
|
53 |
* following behavior: |
|
54 |
* |
|
55 |
* <ul> |
|
56 |
* <li> |
|
57 |
* File names need not be canonical. |
|
58 |
* </li> |
|
59 |
* <li> |
|
60 |
* For file objects representing regular files |
|
61 |
* <ul> |
|
62 |
* <li> |
|
63 |
* the method <code>{@linkplain FileObject#delete()}</code> |
|
64 |
* is equivalent to <code>{@linkplain File#delete()}</code>, |
|
65 |
* </li> |
|
66 |
* <li> |
|
67 |
* the method <code>{@linkplain FileObject#getLastModified()}</code> |
|
68 |
* is equivalent to <code>{@linkplain File#lastModified()}</code>, |
|
69 |
* </li> |
|
70 |
* <li> |
|
71 |
* the methods <code>{@linkplain FileObject#getCharContent(boolean)}</code>, |
|
72 |
* <code>{@linkplain FileObject#openInputStream()}</code>, and |
|
73 |
* <code>{@linkplain FileObject#openReader(boolean)}</code> |
|
74 |
* must succeed if the following would succeed (ignoring |
|
75 |
* encoding issues): |
|
76 |
* <blockquote> |
|
77 |
* <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> |
|
78 |
* </blockquote> |
|
79 |
* </li> |
|
80 |
* <li> |
|
81 |
* and the methods |
|
82 |
* <code>{@linkplain FileObject#openOutputStream()}</code>, and |
|
83 |
* <code>{@linkplain FileObject#openWriter()}</code> must |
|
84 |
* succeed if the following would succeed (ignoring encoding |
|
85 |
* issues): |
|
86 |
* <blockquote> |
|
87 |
* <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> |
|
88 |
* </blockquote> |
|
89 |
* </li> |
|
90 |
* </ul> |
|
91 |
* </li> |
|
92 |
* <li> |
|
93 |
* The {@linkplain java.net.URI URI} returned from |
|
94 |
* <code>{@linkplain FileObject#toUri()}</code> |
|
95 |
* <ul> |
|
96 |
* <li> |
|
97 |
* must be {@linkplain java.net.URI#isAbsolute() absolute} (have a schema), and |
|
98 |
* </li> |
|
99 |
* <li> |
|
100 |
* must have a {@linkplain java.net.URI#normalize() normalized} |
|
101 |
* {@linkplain java.net.URI#getPath() path component} which |
|
102 |
* can be resolved without any process-specific context such |
|
103 |
* as the current directory (file names must be absolute). |
|
104 |
* </li> |
|
105 |
* </ul> |
|
106 |
* </li> |
|
107 |
* </ul> |
|
108 |
* |
|
109 |
* According to these rules, the following URIs, for example, are |
|
110 |
* allowed: |
|
111 |
* <ul> |
|
112 |
* <li> |
|
113 |
* <code>file:///C:/Documents%20and%20Settings/UncleBob/BobsApp/Test.java</code> |
|
114 |
* </li> |
|
115 |
* <li> |
|
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
116 |
* <code>jar:///C:/Documents%20and%20Settings/UncleBob/lib/vendorA.jar!/com/vendora/LibraryClass.class</code> |
10 | 117 |
* </li> |
118 |
* </ul> |
|
119 |
* Whereas these are not (reason in parentheses): |
|
120 |
* <ul> |
|
121 |
* <li> |
|
122 |
* <code>file:BobsApp/Test.java</code> (the file name is relative |
|
123 |
* and depend on the current directory) |
|
124 |
* </li> |
|
125 |
* <li> |
|
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
126 |
* <code>jar:lib/vendorA.jar!/com/vendora/LibraryClass.class</code> |
10 | 127 |
* (the first half of the path depends on the current directory, |
128 |
* whereas the component after ! is legal) |
|
129 |
* </li> |
|
130 |
* <li> |
|
131 |
* <code>Test.java</code> (this URI depends on the current |
|
132 |
* directory and does not have a schema) |
|
133 |
* </li> |
|
134 |
* <li> |
|
135 |
* <code>jar:///C:/Documents%20and%20Settings/UncleBob/BobsApp/../lib/vendorA.jar!com/vendora/LibraryClass.class</code> |
|
136 |
* (the path is not normalized) |
|
137 |
* </li> |
|
138 |
* </ul> |
|
139 |
* |
|
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
140 |
* <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
|
141 |
* 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
|
142 |
* 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
|
143 |
* |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
144 |
* |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
145 |
* @apiNote |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
146 |
* Some methods on this interface take a {@code Collection<? extends Path>} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
147 |
* instead of {@code Iterable<? extends Path>}. |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
148 |
* This is to prevent the possibility of accidentally calling the method |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
149 |
* with a single {@code Path} as such an argument, because although |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
150 |
* {@code Path} implements {@code Iterable<Path>}, it would almost never be |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
151 |
* 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
|
152 |
* an {@code Iterable} of its components. |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
153 |
* |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
154 |
* |
10 | 155 |
* @author Peter von der Ahé |
156 |
* @since 1.6 |
|
157 |
*/ |
|
158 |
public interface StandardJavaFileManager extends JavaFileManager { |
|
159 |
||
160 |
/** |
|
161 |
* Compares two file objects and return true if they represent the |
|
162 |
* same canonical file, zip file entry, or entry in any file |
|
163 |
* system based container. |
|
164 |
* |
|
165 |
* @param a a file object |
|
166 |
* @param b a file object |
|
167 |
* @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
|
168 |
* canonical file, zip file entry or path; false otherwise |
10 | 169 |
* |
170 |
* @throws IllegalArgumentException if either of the arguments |
|
171 |
* were created with another file manager implementation |
|
172 |
*/ |
|
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
173 |
@Override |
10 | 174 |
boolean isSameFile(FileObject a, FileObject b); |
175 |
||
176 |
/** |
|
25287 | 177 |
* Returns file objects representing the given files. |
10 | 178 |
* |
179 |
* @param files a list of files |
|
180 |
* @return a list of file objects |
|
181 |
* @throws IllegalArgumentException if the list of files includes |
|
182 |
* a directory |
|
183 |
*/ |
|
184 |
Iterable<? extends JavaFileObject> getJavaFileObjectsFromFiles( |
|
185 |
Iterable<? extends File> files); |
|
186 |
||
187 |
/** |
|
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
188 |
* Returns file objects representing the given paths. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
189 |
* |
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
190 |
* @implSpec |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
191 |
* 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
|
192 |
* {@link #getJavaFileObjectsFromFiles getJavaObjectsFromFiles}. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
193 |
* IllegalArgumentException will be thrown if any of the paths |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
194 |
* cannot be converted to a file. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
195 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
196 |
* @param paths a list of paths |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
197 |
* @return a list of file objects |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
198 |
* @throws IllegalArgumentException if the list of paths includes |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
199 |
* 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
|
200 |
* given paths. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
201 |
* |
34912
954fa9df99c7
8146572: Update "@since 1.9" to "@since 9" to match java.version.specification [langtools]
jjg
parents:
28332
diff
changeset
|
202 |
* @since 9 |
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
203 |
*/ |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
204 |
default Iterable<? extends JavaFileObject> getJavaFileObjectsFromPaths( |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
205 |
Iterable<? extends Path> paths) { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
206 |
return getJavaFileObjectsFromFiles(asFiles(paths)); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
207 |
} |
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 |
/** |
25287 | 210 |
* Returns file objects representing the given files. |
10 | 211 |
* Convenience method equivalent to: |
212 |
* |
|
213 |
* <pre> |
|
214 |
* getJavaFileObjectsFromFiles({@linkplain java.util.Arrays#asList Arrays.asList}(files)) |
|
215 |
* </pre> |
|
216 |
* |
|
217 |
* @param files an array of files |
|
218 |
* @return a list of file objects |
|
219 |
* @throws IllegalArgumentException if the array of files includes |
|
220 |
* a directory |
|
221 |
* @throws NullPointerException if the given array contains null |
|
222 |
* elements |
|
223 |
*/ |
|
224 |
Iterable<? extends JavaFileObject> getJavaFileObjects(File... files); |
|
225 |
||
226 |
/** |
|
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
227 |
* Returns file objects representing the given paths. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
228 |
* Convenience method equivalent to: |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
229 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
230 |
* <pre> |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
231 |
* getJavaFileObjectsFromPaths({@linkplain java.util.Arrays#asList Arrays.asList}(paths)) |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
232 |
* </pre> |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
233 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
234 |
* @param paths an array of paths |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
235 |
* @return a list of file objects |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
236 |
* @throws IllegalArgumentException if the array of files includes |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
237 |
* a directory |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
238 |
* @throws NullPointerException if the given array contains null |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
239 |
* elements |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
240 |
* |
34912
954fa9df99c7
8146572: Update "@since 1.9" to "@since 9" to match java.version.specification [langtools]
jjg
parents:
28332
diff
changeset
|
241 |
* @since 9 |
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
242 |
*/ |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
243 |
default Iterable<? extends JavaFileObject> getJavaFileObjects(Path... paths) { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
244 |
return getJavaFileObjectsFromPaths(Arrays.asList(paths)); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
245 |
} |
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 |
/** |
25287 | 248 |
* Returns file objects representing the given file names. |
10 | 249 |
* |
250 |
* @param names a list of file names |
|
251 |
* @return a list of file objects |
|
252 |
* @throws IllegalArgumentException if the list of file names |
|
253 |
* includes a directory |
|
254 |
*/ |
|
255 |
Iterable<? extends JavaFileObject> getJavaFileObjectsFromStrings( |
|
256 |
Iterable<String> names); |
|
257 |
||
258 |
/** |
|
25287 | 259 |
* Returns file objects representing the given file names. |
10 | 260 |
* Convenience method equivalent to: |
261 |
* |
|
262 |
* <pre> |
|
263 |
* getJavaFileObjectsFromStrings({@linkplain java.util.Arrays#asList Arrays.asList}(names)) |
|
264 |
* </pre> |
|
265 |
* |
|
266 |
* @param names a list of file names |
|
267 |
* @return a list of file objects |
|
268 |
* @throws IllegalArgumentException if the array of file names |
|
269 |
* includes a directory |
|
270 |
* @throws NullPointerException if the given array contains null |
|
271 |
* elements |
|
272 |
*/ |
|
273 |
Iterable<? extends JavaFileObject> getJavaFileObjects(String... names); |
|
274 |
||
275 |
/** |
|
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
276 |
* Associates the given search path with the given location. Any |
10 | 277 |
* previous value will be discarded. |
278 |
* |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
279 |
* If the location is a module-oriented or output location, any module-specific |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
280 |
* associations set up by {@linkplain #setLocationForModule setLocationForModule} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
281 |
* will be cancelled. |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
282 |
* |
10 | 283 |
* @param location a location |
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
284 |
* @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
|
285 |
* search path for this location |
10 | 286 |
* @see #getLocation |
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
287 |
* @throws IllegalArgumentException if {@code location} is an output |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
288 |
* location and {@code files} does not contain exactly one element |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
289 |
* @throws IOException if {@code location} is an output location and |
10 | 290 |
* does not represent an existing directory |
291 |
*/ |
|
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
292 |
void setLocation(Location location, Iterable<? extends File> files) |
10 | 293 |
throws IOException; |
294 |
||
295 |
/** |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
296 |
* Associates the given search path with the given location. |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
297 |
* Any previous value will be discarded. |
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
298 |
* |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
299 |
* If the location is a module-oriented or output location, any module-specific |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
300 |
* associations set up by {@linkplain #setLocationForModule setLocationForModule} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
301 |
* will be cancelled. |
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
302 |
* |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
303 |
* @implSpec |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
304 |
* 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
|
305 |
* {@link #getJavaFileObjectsFromFiles getJavaObjectsFromFiles}. |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
306 |
* {@linkplain IllegalArgumentException IllegalArgumentException} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
307 |
* 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
|
308 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
309 |
* @param location a location |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
310 |
* @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
|
311 |
* search path for this location |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
312 |
* @see #getLocation |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
313 |
* @throws IllegalArgumentException if {@code location} is an output |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
314 |
* location and {@code paths} does not contain exactly one element |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
315 |
* 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
|
316 |
* @throws IOException if {@code location} is an output location and |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
317 |
* {@code paths} does not represent an existing directory |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
318 |
* |
34912
954fa9df99c7
8146572: Update "@since 1.9" to "@since 9" to match java.version.specification [langtools]
jjg
parents:
28332
diff
changeset
|
319 |
* @since 9 |
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
320 |
*/ |
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
321 |
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
|
322 |
throws IOException { |
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
323 |
setLocation(location, asFiles(paths)); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
324 |
} |
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 |
/** |
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
327 |
* Associates the given search path with the given module and location, |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
328 |
* which must be a module-oriented or output location. |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
329 |
* Any previous value will be discarded. |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
330 |
* This overrides any default association derived from the search path |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
331 |
* associated with the location itself. |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
332 |
* |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
333 |
* All such module-specific associations will be cancelled if a |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
334 |
* new search path is associated with the location by calling |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
335 |
* {@linkplain #setLocation setLocation } or |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
336 |
* {@linkplain #setLocationFromPaths setLocationFromPaths}. |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
337 |
* |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
338 |
* @throws IllegalStateException if the location is not a module-oriented |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
339 |
* or output location. |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
340 |
* @throws UnsupportedOperationException if this operation is not supported by |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
341 |
* this file manager. |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
342 |
* @throws IOException if {@code location} is an output location and |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
343 |
* {@code paths} does not represent an existing directory |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
344 |
* |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
345 |
* @param location the location |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
346 |
* @param moduleName the name of the module |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
347 |
* @param paths the search path to associate with the location and module. |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
348 |
* |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
349 |
* @see setLocation |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
350 |
* @see setLocationFromPaths |
44197 | 351 |
* |
352 |
* @since 9 |
|
44019
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
353 |
*/ |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
354 |
default void setLocationForModule(Location location, String moduleName, |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
355 |
Collection<? extends Path> paths) throws IOException { |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
356 |
throw new UnsupportedOperationException(); |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
357 |
} |
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
358 |
|
284fa2ebd030
8173914: StandardJavaFileManager.setLocationForModule
jjg
parents:
37944
diff
changeset
|
359 |
/** |
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
360 |
* Returns the search path associated with the given location. |
10 | 361 |
* |
362 |
* @param location a location |
|
363 |
* @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
|
364 |
* associated search path |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
365 |
* @throws IllegalStateException if any element of the search path |
44690
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
44197
diff
changeset
|
366 |
* 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
|
367 |
* cannot be represented as a simple series of files. |
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
368 |
* |
10 | 369 |
* @see #setLocation |
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
370 |
* @see Path#toFile |
10 | 371 |
*/ |
372 |
Iterable<? extends File> getLocation(Location location); |
|
373 |
||
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
374 |
/** |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
375 |
* Returns the search path associated with the given location. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
376 |
* |
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
377 |
* @implSpec |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
378 |
* The default implementation calls {@link #getLocation getLocation} |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
379 |
* 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
|
380 |
* 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
|
381 |
* |
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
382 |
* @param location a location |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
383 |
* @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
|
384 |
* associated search path |
44690
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
44197
diff
changeset
|
385 |
* @throws IllegalStateException if the search path cannot be represented |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
44197
diff
changeset
|
386 |
* as a simple series of paths. |
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
387 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
388 |
* @see #setLocationFromPaths |
34912
954fa9df99c7
8146572: Update "@since 1.9" to "@since 9" to match java.version.specification [langtools]
jjg
parents:
28332
diff
changeset
|
389 |
* @since 9 |
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
390 |
*/ |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
391 |
default Iterable<? extends Path> getLocationAsPaths(Location location) { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
392 |
return asPaths(getLocation(location)); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
393 |
} |
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 |
* 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
|
397 |
* 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
|
398 |
* including the default file system, typically have a corresponding underlying |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
399 |
* {@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
|
400 |
* used to access that object. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
401 |
* |
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
402 |
* @implSpec |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
403 |
* The default implementation throws {@link UnsupportedOperationException} |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
404 |
* for all files. |
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
405 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
406 |
* @param file a file object |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
407 |
* @return a path representing the same underlying file system artifact |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
408 |
* @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
|
409 |
* @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
|
410 |
* |
34912
954fa9df99c7
8146572: Update "@since 1.9" to "@since 9" to match java.version.specification [langtools]
jjg
parents:
28332
diff
changeset
|
411 |
* @since 9 |
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
412 |
*/ |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
413 |
default Path asPath(FileObject file) { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
414 |
throw new UnsupportedOperationException(); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
415 |
} |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
416 |
|
37944
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
417 |
/** |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
418 |
* 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
|
419 |
* |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
420 |
* @since 9 |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
421 |
*/ |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
422 |
interface PathFactory { |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
423 |
/** |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
424 |
* 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
|
425 |
* |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
426 |
* @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
|
427 |
* @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
|
428 |
* @return the resulting {@code Path} |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
429 |
*/ |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
430 |
Path getPath(String first, String... more); |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
431 |
} |
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 |
* 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
|
435 |
* |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
436 |
* 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
|
437 |
* equivalent to calling |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
438 |
* {@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
|
439 |
* will be used. |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
440 |
* |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
441 |
* @implSpec |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
442 |
* 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
|
443 |
* |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
444 |
* @param f the factory |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
445 |
* |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
446 |
* @since 9 |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
447 |
*/ |
1153fab98d25
8149843: StandardJavaFileManager should provide a way to get paths from strings
jjg
parents:
34912
diff
changeset
|
448 |
default void setPathFactory(PathFactory f) { } |
48456 | 449 |
|
450 |
||
451 |
private static Iterable<Path> asPaths(final Iterable<? extends File> files) { |
|
452 |
return () -> new Iterator<Path>() { |
|
453 |
Iterator<? extends File> iter = files.iterator(); |
|
454 |
||
455 |
@Override |
|
456 |
public boolean hasNext() { |
|
457 |
return iter.hasNext(); |
|
458 |
} |
|
459 |
||
460 |
@Override |
|
461 |
public Path next() { |
|
462 |
return iter.next().toPath(); |
|
463 |
} |
|
464 |
}; |
|
465 |
} |
|
466 |
||
467 |
private static Iterable<File> asFiles(final Iterable<? extends Path> paths) { |
|
468 |
return () -> new Iterator<File>() { |
|
469 |
Iterator<? extends Path> iter = paths.iterator(); |
|
470 |
||
471 |
@Override |
|
472 |
public boolean hasNext() { |
|
473 |
return iter.hasNext(); |
|
474 |
} |
|
475 |
||
476 |
@Override |
|
477 |
public File next() { |
|
478 |
Path p = iter.next(); |
|
479 |
try { |
|
480 |
return p.toFile(); |
|
481 |
} catch (UnsupportedOperationException e) { |
|
482 |
throw new IllegalArgumentException(p.toString(), e); |
|
483 |
} |
|
484 |
} |
|
485 |
}; |
|
486 |
} |
|
10 | 487 |
} |