src/share/classes/javax/tools/ForwardingJavaFileManager.java

changeset 1
9a66ca7c79fa
child 554
9d9f26857129
equal deleted inserted replaced
-1:000000000000 1:9a66ca7c79fa
1 /*
2 * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
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
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
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 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26 package javax.tools;
27
28 import java.io.IOException;
29 import java.net.URI;
30 import java.util.Iterator;
31 import java.util.Set;
32 import javax.tools.JavaFileObject.Kind;
33
34 /**
35 * Forwards calls to a given file manager. Subclasses of this class
36 * might override some of these methods and might also provide
37 * additional fields and methods.
38 *
39 * @param <M> the kind of file manager forwarded to by this object
40 * @author Peter von der Ah&eacute;
41 * @since 1.6
42 */
43 public class ForwardingJavaFileManager<M extends JavaFileManager> implements JavaFileManager {
44
45 /**
46 * The file manager which all methods are delegated to.
47 */
48 protected final M fileManager;
49
50 /**
51 * Creates a new instance of ForwardingJavaFileManager.
52 * @param fileManager delegate to this file manager
53 */
54 protected ForwardingJavaFileManager(M fileManager) {
55 fileManager.getClass(); // null check
56 this.fileManager = fileManager;
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 }
167 }

mercurial