Wed, 08 Oct 2014 14:16:40 -0700
Merge
1 /*
2 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle 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 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.
24 */
26 package javax.tools;
28 import java.io.IOException;
29 import java.util.Iterator;
30 import java.util.Set;
31 import javax.tools.JavaFileObject.Kind;
33 /**
34 * Forwards calls to a given file manager. Subclasses of this class
35 * might override some of these methods and might also provide
36 * additional fields and methods.
37 *
38 * @param <M> the kind of file manager forwarded to by this object
39 * @author Peter von der Ahé
40 * @since 1.6
41 */
42 public class ForwardingJavaFileManager<M extends JavaFileManager> implements JavaFileManager {
44 /**
45 * The file manager which all methods are delegated to.
46 */
47 protected final M fileManager;
49 /**
50 * Creates a new instance of ForwardingJavaFileManager.
51 * @param fileManager delegate to this file manager
52 */
53 protected ForwardingJavaFileManager(M fileManager) {
54 fileManager.getClass(); // null check
55 this.fileManager = fileManager;
56 }
58 /**
59 * @throws SecurityException {@inheritDoc}
60 * @throws IllegalStateException {@inheritDoc}
61 */
62 public ClassLoader getClassLoader(Location location) {
63 return fileManager.getClassLoader(location);
64 }
66 /**
67 * @throws IOException {@inheritDoc}
68 * @throws IllegalStateException {@inheritDoc}
69 */
70 public Iterable<JavaFileObject> list(Location location,
71 String packageName,
72 Set<Kind> kinds,
73 boolean recurse)
74 throws IOException
75 {
76 return fileManager.list(location, packageName, kinds, recurse);
77 }
79 /**
80 * @throws IllegalStateException {@inheritDoc}
81 */
82 public String inferBinaryName(Location location, JavaFileObject file) {
83 return fileManager.inferBinaryName(location, file);
84 }
86 /**
87 * @throws IllegalArgumentException {@inheritDoc}
88 */
89 public boolean isSameFile(FileObject a, FileObject b) {
90 return fileManager.isSameFile(a, b);
91 }
93 /**
94 * @throws IllegalArgumentException {@inheritDoc}
95 * @throws IllegalStateException {@inheritDoc}
96 */
97 public boolean handleOption(String current, Iterator<String> remaining) {
98 return fileManager.handleOption(current, remaining);
99 }
101 public boolean hasLocation(Location location) {
102 return fileManager.hasLocation(location);
103 }
105 public int isSupportedOption(String option) {
106 return fileManager.isSupportedOption(option);
107 }
109 /**
110 * @throws IllegalArgumentException {@inheritDoc}
111 * @throws IllegalStateException {@inheritDoc}
112 */
113 public JavaFileObject getJavaFileForInput(Location location,
114 String className,
115 Kind kind)
116 throws IOException
117 {
118 return fileManager.getJavaFileForInput(location, className, kind);
119 }
121 /**
122 * @throws IllegalArgumentException {@inheritDoc}
123 * @throws IllegalStateException {@inheritDoc}
124 */
125 public JavaFileObject getJavaFileForOutput(Location location,
126 String className,
127 Kind kind,
128 FileObject sibling)
129 throws IOException
130 {
131 return fileManager.getJavaFileForOutput(location, className, kind, sibling);
132 }
134 /**
135 * @throws IllegalArgumentException {@inheritDoc}
136 * @throws IllegalStateException {@inheritDoc}
137 */
138 public FileObject getFileForInput(Location location,
139 String packageName,
140 String relativeName)
141 throws IOException
142 {
143 return fileManager.getFileForInput(location, packageName, relativeName);
144 }
146 /**
147 * @throws IllegalArgumentException {@inheritDoc}
148 * @throws IllegalStateException {@inheritDoc}
149 */
150 public FileObject getFileForOutput(Location location,
151 String packageName,
152 String relativeName,
153 FileObject sibling)
154 throws IOException
155 {
156 return fileManager.getFileForOutput(location, packageName, relativeName, sibling);
157 }
159 public void flush() throws IOException {
160 fileManager.flush();
161 }
163 public void close() throws IOException {
164 fileManager.close();
165 }
166 }