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 javax.lang.model.element.NestingKind;
29 import javax.lang.model.element.Modifier;
31 /**
32 * File abstraction for tools operating on Java™ programming language
33 * source and class files.
34 *
35 * <p>All methods in this interface might throw a SecurityException if
36 * a security exception occurs.
37 *
38 * <p>Unless explicitly allowed, all methods in this interface might
39 * throw a NullPointerException if given a {@code null} argument.
40 *
41 * @author Peter von der Ahé
42 * @author Jonathan Gibbons
43 * @see JavaFileManager
44 * @since 1.6
45 */
46 public interface JavaFileObject extends FileObject {
48 /**
49 * Kinds of JavaFileObjects.
50 */
51 enum Kind {
52 /**
53 * Source files written in the Java programming language. For
54 * example, regular files ending with {@code .java}.
55 */
56 SOURCE(".java"),
58 /**
59 * Class files for the Java Virtual Machine. For example,
60 * regular files ending with {@code .class}.
61 */
62 CLASS(".class"),
64 /**
65 * HTML files. For example, regular files ending with {@code
66 * .html}.
67 */
68 HTML(".html"),
70 /**
71 * Any other kind.
72 */
73 OTHER("");
74 /**
75 * The extension which (by convention) is normally used for
76 * this kind of file object. If no convention exists, the
77 * empty string ({@code ""}) is used.
78 */
79 public final String extension;
80 private Kind(String extension) {
81 extension.getClass(); // null check
82 this.extension = extension;
83 }
84 };
86 /**
87 * Gets the kind of this file object.
88 *
89 * @return the kind
90 */
91 Kind getKind();
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);
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 */
118 NestingKind getNestingKind();
120 /**
121 * Provides a hint about the access level of the class represented
122 * by this file object. If the access level is not known or if
123 * this file object does not represent a class file this method
124 * returns {@code null}.
125 *
126 * @return the access level
127 */
128 Modifier getAccessLevel();
130 }