KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > tools > ForwardingJavaFileManager


1 /*
2  * @(#)ForwardingJavaFileManager.java 1.11 06/07/17
3  *
4  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.tools;
9
10 import java.io.IOException JavaDoc;
11 import java.net.URI JavaDoc;
12 import java.util.Iterator JavaDoc;
13 import java.util.Set JavaDoc;
14 import javax.tools.JavaFileObject.Kind;
15
16 /**
17  * Forwards calls to a given file manager. Subclasses of this class
18  * might override some of these methods and might also provide
19  * additional fields and methods.
20  *
21  * @param <M> the kind of file manager forwarded to by this object
22  * @author Peter von der Ah&eacute;
23  * @since 1.6
24  */

25 public class ForwardingJavaFileManager<M extends JavaFileManager> implements JavaFileManager {
26
27     /**
28      * The file manager which all methods are delegated to.
29      */

30     protected final M fileManager;
31
32     /**
33      * Creates a new instance of ForwardingJavaFileManager.
34      * @param fileManager delegate to this file manager
35      */

36     protected ForwardingJavaFileManager(M fileManager) {
37         fileManager.getClass(); // null check
38
this.fileManager = fileManager;
39     }
40
41     /**
42      * @throws SecurityException {@inheritDoc}
43      * @throws IllegalStateException {@inheritDoc}
44      */

45     public ClassLoader JavaDoc getClassLoader(Location location) {
46         return fileManager.getClassLoader(location);
47     }
48
49     /**
50      * @throws IOException {@inheritDoc}
51      * @throws IllegalStateException {@inheritDoc}
52      */

53     public Iterable JavaDoc<JavaFileObject> list(Location location,
54                                          String JavaDoc packageName,
55                                          Set JavaDoc<Kind> kinds,
56                                          boolean recurse)
57         throws IOException JavaDoc
58     {
59         return fileManager.list(location, packageName, kinds, recurse);
60     }
61
62     /**
63      * @throws IllegalStateException {@inheritDoc}
64      */

65     public String JavaDoc inferBinaryName(Location location, JavaFileObject file) {
66         return fileManager.inferBinaryName(location, file);
67     }
68
69     /**
70      * @throws IllegalArgumentException {@inheritDoc}
71      */

72     public boolean isSameFile(FileObject a, FileObject b) {
73         return fileManager.isSameFile(a, b);
74     }
75
76     /**
77      * @throws IllegalArgumentException {@inheritDoc}
78      * @throws IllegalStateException {@inheritDoc}
79      */

80     public boolean handleOption(String JavaDoc current, Iterator JavaDoc<String JavaDoc> remaining) {
81         return fileManager.handleOption(current, remaining);
82     }
83
84     public boolean hasLocation(Location location) {
85         return fileManager.hasLocation(location);
86     }
87
88     public int isSupportedOption(String JavaDoc option) {
89         return fileManager.isSupportedOption(option);
90     }
91
92     /**
93      * @throws IllegalArgumentException {@inheritDoc}
94      * @throws IllegalStateException {@inheritDoc}
95      */

96     public JavaFileObject getJavaFileForInput(Location location,
97                                               String JavaDoc className,
98                                               Kind kind)
99         throws IOException JavaDoc
100     {
101         return fileManager.getJavaFileForInput(location, className, kind);
102     }
103
104     /**
105      * @throws IllegalArgumentException {@inheritDoc}
106      * @throws IllegalStateException {@inheritDoc}
107      */

108     public JavaFileObject getJavaFileForOutput(Location location,
109                                                String JavaDoc className,
110                                                Kind kind,
111                                                FileObject sibling)
112         throws IOException JavaDoc
113     {
114         return fileManager.getJavaFileForOutput(location, className, kind, sibling);
115     }
116
117     /**
118      * @throws IllegalArgumentException {@inheritDoc}
119      * @throws IllegalStateException {@inheritDoc}
120      */

121     public FileObject getFileForInput(Location location,
122                                       String JavaDoc packageName,
123                                       String JavaDoc relativeName)
124         throws IOException JavaDoc
125     {
126         return fileManager.getFileForInput(location, packageName, relativeName);
127     }
128
129     /**
130      * @throws IllegalArgumentException {@inheritDoc}
131      * @throws IllegalStateException {@inheritDoc}
132      */

133     public FileObject getFileForOutput(Location location,
134                                        String JavaDoc packageName,
135                                        String JavaDoc relativeName,
136                                        FileObject sibling)
137         throws IOException JavaDoc
138     {
139         return fileManager.getFileForOutput(location, packageName, relativeName, sibling);
140     }
141
142     public void flush() throws IOException JavaDoc {
143         fileManager.flush();
144     }
145
146     public void close() throws IOException JavaDoc {
147         fileManager.close();
148     }
149 }
150
Popular Tags