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.io.InputStream; |
30 | import java.io.OutputStream; |
31 | import java.io.Reader; |
32 | import java.io.Writer; |
33 | import java.nio.CharBuffer; |
34 | import javax.lang.model.element.NestingKind; |
35 | import javax.lang.model.element.Modifier; |
36 | |
37 | /** |
38 | * File abstraction for tools operating on Java™ programming language |
39 | * source and class files. |
40 | * |
41 | * <p>All methods in this interface might throw a SecurityException if |
42 | * a security exception occurs. |
43 | * |
44 | * <p>Unless explicitly allowed, all methods in this interface might |
45 | * throw a NullPointerException if given a {@code null} argument. |
46 | * |
47 | * @author Peter von der Ahé |
48 | * @author Jonathan Gibbons |
49 | * @see JavaFileManager |
50 | * @since 1.6 |
51 | */ |
52 | public interface JavaFileObject extends FileObject { |
53 | |
54 | /** |
55 | * Kinds of JavaFileObjects. |
56 | */ |
57 | enum Kind { |
58 | /** |
59 | * Source files written in the Java programming language. For |
60 | * example, regular files ending with {@code .java}. |
61 | */ |
62 | SOURCE(".java"), |
63 | |
64 | /** |
65 | * Class files for the Java Virtual Machine. For example, |
66 | * regular files ending with {@code .class}. |
67 | */ |
68 | CLASS(".class"), |
69 | |
70 | /** |
71 | * HTML files. For example, regular files ending with {@code |
72 | * .html}. |
73 | */ |
74 | HTML(".html"), |
75 | |
76 | /** |
77 | * Any other kind. |
78 | */ |
79 | OTHER(""); |
80 | /** |
81 | * The extension which (by convention) is normally used for |
82 | * this kind of file object. If no convention exists, the |
83 | * empty string ({@code ""}) is used. |
84 | */ |
85 | public final String extension; |
86 | private Kind(String extension) { |
87 | extension.getClass(); // null check |
88 | this.extension = extension; |
89 | } |
90 | }; |
91 | |
92 | /** |
93 | * Gets the kind of this file object. |
94 | * |
95 | * @return the kind |
96 | */ |
97 | Kind getKind(); |
98 | |
99 | /** |
100 | * Checks if this file object is compatible with the specified |
101 | * simple name and kind. A simple name is a single identifier |
102 | * (not qualified) as defined in the <a |
103 | * href="http://java.sun.com/docs/books/jls/">Java Language |
104 | * Specification</a> 3rd ed., section 6.2 "Names and Identifiers". |
105 | * |
106 | * @param simpleName a simple name of a class |
107 | * @param kind a kind |
108 | * @return {@code true} if this file object is compatible; false |
109 | * otherwise |
110 | */ |
111 | boolean isNameCompatible(String simpleName, Kind kind); |
112 | |
113 | /** |
114 | * Provides a hint about the nesting level of the class |
115 | * represented by this file object. This method may return |
116 | * {@link NestingKind#MEMBER} to mean |
117 | * {@link NestingKind#LOCAL} or {@link NestingKind#ANONYMOUS}. |
118 | * If the nesting level is not known or this file object does not |
119 | * represent a class file this method returns {@code null}. |
120 | * |
121 | * @return the nesting kind, or {@code null} if the nesting kind |
122 | * is not known |
123 | */ |
124 | NestingKind getNestingKind(); |
125 | |
126 | /** |
127 | * Provides a hint about the access level of the class represented |
128 | * by this file object. If the access level is not known or if |
129 | * this file object does not represent a class file this method |
130 | * returns {@code null}. |
131 | * |
132 | * @return the access level |
133 | */ |
134 | Modifier getAccessLevel(); |
135 | |
136 | } |