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 */
25
26 package javax.tools;
27
28 import javax.lang.model.element.NestingKind;
29 import javax.lang.model.element.Modifier;
30 import java.util.Objects;
31
32 /**
33 * File abstraction for tools operating on Java™ programming language
34 * source and class files.
35 *
36 * <p>All methods in this interface might throw a SecurityException if
37 * a security exception occurs.
38 *
39 * <p>Unless explicitly allowed, all methods in this interface might
40 * throw a NullPointerException if given a {@code null} argument.
41 *
42 * @author Peter von der Ahé
43 * @author Jonathan Gibbons
44 * @see JavaFileManager
45 * @since 1.6
46 */
47 public interface JavaFileObject extends FileObject {
48
49 /**
50 * Kinds of JavaFileObjects.
51 */
52 enum Kind {
53 /**
77 * this kind of file object. If no convention exists, the
78 * empty string ({@code ""}) is used.
79 */
80 public final String extension;
81 private Kind(String extension) {
82 this.extension = Objects.requireNonNull(extension);
83 }
84 }
85
86 /**
87 * Returns the kind of this file object.
88 *
89 * @return the kind
90 */
91 Kind getKind();
92
93 /**
94 * Checks if this file object is compatible with the specified
95 * simple name and kind. A simple name is a single identifier
96 * (not qualified) as defined in
97 * <cite>The Java™ Language Specification</cite>,
98 * section 6.2 "Names and Identifiers".
99 *
100 * @param simpleName a simple name of a class
101 * @param kind a kind
102 * @return {@code true} if this file object is compatible; false
103 * otherwise
104 */
105 boolean isNameCompatible(String simpleName, Kind kind);
106
107 /**
108 * Provides a hint about the nesting level of the class
109 * represented by this file object. This method may return
110 * {@link NestingKind#MEMBER} to mean
111 * {@link NestingKind#LOCAL} or {@link NestingKind#ANONYMOUS}.
112 * If the nesting level is not known or this file object does not
113 * represent a class file this method returns {@code null}.
114 *
115 * @return the nesting kind, or {@code null} if the nesting kind
116 * is not known
117 */
|
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 */
25
26 package javax.tools;
27
28 import javax.lang.model.element.NestingKind;
29 import javax.lang.model.element.Modifier;
30 import java.util.Objects;
31
32 /**
33 * File abstraction for tools operating on Java programming language
34 * source and class files.
35 *
36 * <p>All methods in this interface might throw a SecurityException if
37 * a security exception occurs.
38 *
39 * <p>Unless explicitly allowed, all methods in this interface might
40 * throw a NullPointerException if given a {@code null} argument.
41 *
42 * @author Peter von der Ahé
43 * @author Jonathan Gibbons
44 * @see JavaFileManager
45 * @since 1.6
46 */
47 public interface JavaFileObject extends FileObject {
48
49 /**
50 * Kinds of JavaFileObjects.
51 */
52 enum Kind {
53 /**
77 * this kind of file object. If no convention exists, the
78 * empty string ({@code ""}) is used.
79 */
80 public final String extension;
81 private Kind(String extension) {
82 this.extension = Objects.requireNonNull(extension);
83 }
84 }
85
86 /**
87 * Returns the kind of this file object.
88 *
89 * @return the kind
90 */
91 Kind getKind();
92
93 /**
94 * Checks if this file object is compatible with the specified
95 * simple name and kind. A simple name is a single identifier
96 * (not qualified) as defined in
97 * <cite>The Java Language Specification</cite>,
98 * section 6.2 "Names and Identifiers".
99 *
100 * @param simpleName a simple name of a class
101 * @param kind a kind
102 * @return {@code true} if this file object is compatible; false
103 * otherwise
104 */
105 boolean isNameCompatible(String simpleName, Kind kind);
106
107 /**
108 * Provides a hint about the nesting level of the class
109 * represented by this file object. This method may return
110 * {@link NestingKind#MEMBER} to mean
111 * {@link NestingKind#LOCAL} or {@link NestingKind#ANONYMOUS}.
112 * If the nesting level is not known or this file object does not
113 * represent a class file this method returns {@code null}.
114 *
115 * @return the nesting kind, or {@code null} if the nesting kind
116 * is not known
117 */
|