author | jjg |
Tue, 06 Jan 2015 14:51:10 -0800 | |
changeset 28332 | cd3ea1087d2b |
parent 25874 | 83c19f00452c |
child 34912 | 954fa9df99c7 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
2 |
* Copyright (c) 2006, 2015, 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; |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
32 |
|
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
33 |
import static javax.tools.FileManagerUtils.*; |
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 |
* |
10 | 144 |
* @author Peter von der Ahé |
145 |
* @since 1.6 |
|
146 |
*/ |
|
147 |
public interface StandardJavaFileManager extends JavaFileManager { |
|
148 |
||
149 |
/** |
|
150 |
* Compares two file objects and return true if they represent the |
|
151 |
* same canonical file, zip file entry, or entry in any file |
|
152 |
* system based container. |
|
153 |
* |
|
154 |
* @param a a file object |
|
155 |
* @param b a file object |
|
156 |
* @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
|
157 |
* canonical file, zip file entry or path; false otherwise |
10 | 158 |
* |
159 |
* @throws IllegalArgumentException if either of the arguments |
|
160 |
* were created with another file manager implementation |
|
161 |
*/ |
|
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
162 |
@Override |
10 | 163 |
boolean isSameFile(FileObject a, FileObject b); |
164 |
||
165 |
/** |
|
25287 | 166 |
* Returns file objects representing the given files. |
10 | 167 |
* |
168 |
* @param files a list of files |
|
169 |
* @return a list of file objects |
|
170 |
* @throws IllegalArgumentException if the list of files includes |
|
171 |
* a directory |
|
172 |
*/ |
|
173 |
Iterable<? extends JavaFileObject> getJavaFileObjectsFromFiles( |
|
174 |
Iterable<? extends File> files); |
|
175 |
||
176 |
/** |
|
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
177 |
* Returns file objects representing the given paths. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
178 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
179 |
* <p>The default implementation converts each path to a file and calls |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
180 |
* {@link #getJavaFileObjectsFromFiles getJavaObjectsFromFiles}. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
181 |
* IllegalArgumentException will be thrown if any of the paths |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
182 |
* cannot be converted to a file. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
183 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
184 |
* @param paths a list of paths |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
185 |
* @return a list of file objects |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
186 |
* @throws IllegalArgumentException if the list of paths includes |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
187 |
* 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
|
188 |
* given paths. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
189 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
190 |
* @since 1.9 |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
191 |
*/ |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
192 |
default Iterable<? extends JavaFileObject> getJavaFileObjectsFromPaths( |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
193 |
Iterable<? extends Path> paths) { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
194 |
return getJavaFileObjectsFromFiles(asFiles(paths)); |
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 |
|
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
197 |
/** |
25287 | 198 |
* Returns file objects representing the given files. |
10 | 199 |
* Convenience method equivalent to: |
200 |
* |
|
201 |
* <pre> |
|
202 |
* getJavaFileObjectsFromFiles({@linkplain java.util.Arrays#asList Arrays.asList}(files)) |
|
203 |
* </pre> |
|
204 |
* |
|
205 |
* @param files an array of files |
|
206 |
* @return a list of file objects |
|
207 |
* @throws IllegalArgumentException if the array of files includes |
|
208 |
* a directory |
|
209 |
* @throws NullPointerException if the given array contains null |
|
210 |
* elements |
|
211 |
*/ |
|
212 |
Iterable<? extends JavaFileObject> getJavaFileObjects(File... files); |
|
213 |
||
214 |
/** |
|
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
215 |
* Returns file objects representing the given paths. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
216 |
* Convenience method equivalent to: |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
217 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
218 |
* <pre> |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
219 |
* getJavaFileObjectsFromPaths({@linkplain java.util.Arrays#asList Arrays.asList}(paths)) |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
220 |
* </pre> |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
221 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
222 |
* @param paths an array of paths |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
223 |
* @return a list of file objects |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
224 |
* @throws IllegalArgumentException if the array of files includes |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
225 |
* a directory |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
226 |
* @throws NullPointerException if the given array contains null |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
227 |
* elements |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
228 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
229 |
* @since 1.9 |
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 |
default Iterable<? extends JavaFileObject> getJavaFileObjects(Path... paths) { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
232 |
return getJavaFileObjectsFromPaths(Arrays.asList(paths)); |
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 |
|
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
235 |
/** |
25287 | 236 |
* Returns file objects representing the given file names. |
10 | 237 |
* |
238 |
* @param names a list of file names |
|
239 |
* @return a list of file objects |
|
240 |
* @throws IllegalArgumentException if the list of file names |
|
241 |
* includes a directory |
|
242 |
*/ |
|
243 |
Iterable<? extends JavaFileObject> getJavaFileObjectsFromStrings( |
|
244 |
Iterable<String> names); |
|
245 |
||
246 |
/** |
|
25287 | 247 |
* Returns file objects representing the given file names. |
10 | 248 |
* Convenience method equivalent to: |
249 |
* |
|
250 |
* <pre> |
|
251 |
* getJavaFileObjectsFromStrings({@linkplain java.util.Arrays#asList Arrays.asList}(names)) |
|
252 |
* </pre> |
|
253 |
* |
|
254 |
* @param names a list of file names |
|
255 |
* @return a list of file objects |
|
256 |
* @throws IllegalArgumentException if the array of file names |
|
257 |
* includes a directory |
|
258 |
* @throws NullPointerException if the given array contains null |
|
259 |
* elements |
|
260 |
*/ |
|
261 |
Iterable<? extends JavaFileObject> getJavaFileObjects(String... names); |
|
262 |
||
263 |
/** |
|
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
264 |
* Associates the given search path with the given location. Any |
10 | 265 |
* previous value will be discarded. |
266 |
* |
|
267 |
* @param location a location |
|
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
268 |
* @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
|
269 |
* search path for this location |
10 | 270 |
* @see #getLocation |
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
271 |
* @throws IllegalArgumentException if {@code location} is an output |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
272 |
* location and {@code files} does not contain exactly one element |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
273 |
* @throws IOException if {@code location} is an output location and |
10 | 274 |
* does not represent an existing directory |
275 |
*/ |
|
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
276 |
void setLocation(Location location, Iterable<? extends File> files) |
10 | 277 |
throws IOException; |
278 |
||
279 |
/** |
|
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
280 |
* Associates the given search path with the given location. Any |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
281 |
* previous value will be discarded. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
282 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
283 |
* <p>The default implementation converts each path to a file and calls |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
284 |
* {@link #getJavaFileObjectsFromFiles getJavaObjectsFromFiles}. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
285 |
* IllegalArgumentException will be thrown if any of the paths |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
286 |
* cannot be converted to a file.</p> |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
287 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
288 |
* @param location a location |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
289 |
* @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
|
290 |
* search path for this location |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
291 |
* @see #getLocation |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
292 |
* @throws IllegalArgumentException if {@code location} is an output |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
293 |
* location and {@code paths} does not contain exactly one element |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
294 |
* 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
|
295 |
* @throws IOException if {@code location} is an output location and |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
296 |
* {@code paths} does not represent an existing directory |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
297 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
298 |
* @since 1.9 |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
299 |
*/ |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
300 |
default void setLocationFromPaths(Location location, Iterable<? extends Path> paths) |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
301 |
throws IOException { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
302 |
setLocation(location, asFiles(paths)); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
303 |
} |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
304 |
|
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
305 |
/** |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
306 |
* Returns the search path associated with the given location. |
10 | 307 |
* |
308 |
* @param location a location |
|
309 |
* @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
|
310 |
* associated search path |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
311 |
* @throws IllegalStateException if any element of the search path |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
312 |
* cannot be converted to a {@linkplain File}. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
313 |
* |
10 | 314 |
* @see #setLocation |
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
315 |
* @see Path#toFile |
10 | 316 |
*/ |
317 |
Iterable<? extends File> getLocation(Location location); |
|
318 |
||
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
319 |
/** |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
320 |
* Returns the search path associated with the given location. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
321 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
322 |
* @param location a location |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
323 |
* @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
|
324 |
* associated search path |
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 |
* @see #setLocationFromPaths |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
327 |
* @since 1.9 |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
328 |
*/ |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
329 |
default Iterable<? extends Path> getLocationAsPaths(Location location) { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
330 |
return asPaths(getLocation(location)); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
331 |
} |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
332 |
|
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
333 |
/** |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
334 |
* 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
|
335 |
* 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
|
336 |
* including the default file system, typically have a corresponding underlying |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
337 |
* {@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
|
338 |
* used to access that object. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
339 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
340 |
* <p>The default implementation throws {@link UnsupportedOperationException} |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
341 |
* for all files.</p> |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
342 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
343 |
* @param file a file object |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
344 |
* @return a path representing the same underlying file system artifact |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
345 |
* @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
|
346 |
* @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
|
347 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
348 |
* @since 1.9 |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
349 |
*/ |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
350 |
default Path asPath(FileObject file) { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
351 |
throw new UnsupportedOperationException(); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
352 |
} |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
353 |
|
10 | 354 |
} |