author | amurillo |
Fri, 10 Jun 2016 15:13:40 -0700 | |
changeset 38958 | d8a4ce6d05ad |
parent 36526 | 3b41f1c69604 |
child 42261 | bb52b5514ad5 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
36526 | 2 |
* Copyright (c) 2005, 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.IOException; |
|
29 |
import java.util.Iterator; |
|
29291
076c277565f7
8073550: java* tools: replace obj.getClass hacks with Assert.checkNonNull or Objects.requireNonNull
mcimadamore
parents:
25874
diff
changeset
|
30 |
import java.util.Objects; |
36526 | 31 |
import java.util.ServiceLoader; |
10 | 32 |
import java.util.Set; |
33 |
import javax.tools.JavaFileObject.Kind; |
|
34 |
||
35 |
/** |
|
36 |
* Forwards calls to a given file manager. Subclasses of this class |
|
37 |
* might override some of these methods and might also provide |
|
38 |
* additional fields and methods. |
|
39 |
* |
|
40 |
* @param <M> the kind of file manager forwarded to by this object |
|
41 |
* @author Peter von der Ahé |
|
42 |
* @since 1.6 |
|
43 |
*/ |
|
44 |
public class ForwardingJavaFileManager<M extends JavaFileManager> implements JavaFileManager { |
|
45 |
||
46 |
/** |
|
47 |
* The file manager which all methods are delegated to. |
|
48 |
*/ |
|
49 |
protected final M fileManager; |
|
50 |
||
51 |
/** |
|
52 |
* Creates a new instance of ForwardingJavaFileManager. |
|
53 |
* @param fileManager delegate to this file manager |
|
54 |
*/ |
|
55 |
protected ForwardingJavaFileManager(M fileManager) { |
|
29291
076c277565f7
8073550: java* tools: replace obj.getClass hacks with Assert.checkNonNull or Objects.requireNonNull
mcimadamore
parents:
25874
diff
changeset
|
56 |
this.fileManager = Objects.requireNonNull(fileManager); |
10 | 57 |
} |
58 |
||
59 |
/** |
|
60 |
* @throws SecurityException {@inheritDoc} |
|
61 |
* @throws IllegalStateException {@inheritDoc} |
|
62 |
*/ |
|
63 |
public ClassLoader getClassLoader(Location location) { |
|
64 |
return fileManager.getClassLoader(location); |
|
65 |
} |
|
66 |
||
67 |
/** |
|
68 |
* @throws IOException {@inheritDoc} |
|
69 |
* @throws IllegalStateException {@inheritDoc} |
|
70 |
*/ |
|
71 |
public Iterable<JavaFileObject> list(Location location, |
|
72 |
String packageName, |
|
73 |
Set<Kind> kinds, |
|
74 |
boolean recurse) |
|
75 |
throws IOException |
|
76 |
{ |
|
77 |
return fileManager.list(location, packageName, kinds, recurse); |
|
78 |
} |
|
79 |
||
80 |
/** |
|
81 |
* @throws IllegalStateException {@inheritDoc} |
|
82 |
*/ |
|
83 |
public String inferBinaryName(Location location, JavaFileObject file) { |
|
84 |
return fileManager.inferBinaryName(location, file); |
|
85 |
} |
|
86 |
||
87 |
/** |
|
88 |
* @throws IllegalArgumentException {@inheritDoc} |
|
89 |
*/ |
|
90 |
public boolean isSameFile(FileObject a, FileObject b) { |
|
91 |
return fileManager.isSameFile(a, b); |
|
92 |
} |
|
93 |
||
94 |
/** |
|
95 |
* @throws IllegalArgumentException {@inheritDoc} |
|
96 |
* @throws IllegalStateException {@inheritDoc} |
|
97 |
*/ |
|
98 |
public boolean handleOption(String current, Iterator<String> remaining) { |
|
99 |
return fileManager.handleOption(current, remaining); |
|
100 |
} |
|
101 |
||
102 |
public boolean hasLocation(Location location) { |
|
103 |
return fileManager.hasLocation(location); |
|
104 |
} |
|
105 |
||
106 |
public int isSupportedOption(String option) { |
|
107 |
return fileManager.isSupportedOption(option); |
|
108 |
} |
|
109 |
||
110 |
/** |
|
111 |
* @throws IllegalArgumentException {@inheritDoc} |
|
112 |
* @throws IllegalStateException {@inheritDoc} |
|
113 |
*/ |
|
114 |
public JavaFileObject getJavaFileForInput(Location location, |
|
115 |
String className, |
|
116 |
Kind kind) |
|
117 |
throws IOException |
|
118 |
{ |
|
119 |
return fileManager.getJavaFileForInput(location, className, kind); |
|
120 |
} |
|
121 |
||
122 |
/** |
|
123 |
* @throws IllegalArgumentException {@inheritDoc} |
|
124 |
* @throws IllegalStateException {@inheritDoc} |
|
125 |
*/ |
|
126 |
public JavaFileObject getJavaFileForOutput(Location location, |
|
127 |
String className, |
|
128 |
Kind kind, |
|
129 |
FileObject sibling) |
|
130 |
throws IOException |
|
131 |
{ |
|
132 |
return fileManager.getJavaFileForOutput(location, className, kind, sibling); |
|
133 |
} |
|
134 |
||
135 |
/** |
|
136 |
* @throws IllegalArgumentException {@inheritDoc} |
|
137 |
* @throws IllegalStateException {@inheritDoc} |
|
138 |
*/ |
|
139 |
public FileObject getFileForInput(Location location, |
|
140 |
String packageName, |
|
141 |
String relativeName) |
|
142 |
throws IOException |
|
143 |
{ |
|
144 |
return fileManager.getFileForInput(location, packageName, relativeName); |
|
145 |
} |
|
146 |
||
147 |
/** |
|
148 |
* @throws IllegalArgumentException {@inheritDoc} |
|
149 |
* @throws IllegalStateException {@inheritDoc} |
|
150 |
*/ |
|
151 |
public FileObject getFileForOutput(Location location, |
|
152 |
String packageName, |
|
153 |
String relativeName, |
|
154 |
FileObject sibling) |
|
155 |
throws IOException |
|
156 |
{ |
|
157 |
return fileManager.getFileForOutput(location, packageName, relativeName, sibling); |
|
158 |
} |
|
159 |
||
160 |
public void flush() throws IOException { |
|
161 |
fileManager.flush(); |
|
162 |
} |
|
163 |
||
164 |
public void close() throws IOException { |
|
165 |
fileManager.close(); |
|
166 |
} |
|
36526 | 167 |
|
168 |
public Location getModuleLocation(Location location, String moduleName) throws IOException { |
|
169 |
return fileManager.getModuleLocation(location, moduleName); |
|
170 |
} |
|
171 |
||
172 |
public Location getModuleLocation(Location location, JavaFileObject fo, String pkgName) throws IOException { |
|
173 |
return fileManager.getModuleLocation(location, fo, pkgName); |
|
174 |
} |
|
175 |
||
176 |
public <S> ServiceLoader<S> getServiceLoader(Location location, Class<S> service) throws IOException { |
|
177 |
return fileManager.getServiceLoader(location, service); |
|
178 |
} |
|
179 |
||
180 |
public String inferModuleName(Location location) throws IOException { |
|
181 |
return fileManager.inferModuleName(location); |
|
182 |
} |
|
183 |
||
184 |
public Iterable<Set<Location>> listModuleLocations(Location location) throws IOException { |
|
185 |
return fileManager.listModuleLocations(location); |
|
186 |
} |
|
10 | 187 |
} |