KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > tools > JavaFileObject


1 /*
2  * @(#)JavaFileObject.java 1.8 06/09/25
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.io.InputStream JavaDoc;
12 import java.io.OutputStream JavaDoc;
13 import java.io.Reader JavaDoc;
14 import java.io.Writer JavaDoc;
15 import java.nio.CharBuffer JavaDoc;
16 import javax.lang.model.element.NestingKind;
17 import javax.lang.model.element.Modifier;
18
19 /**
20  * File abstraction for tools operating on Java™ programming language
21  * source and class files.
22  *
23  * <p>All methods in this interface might throw a SecurityException if
24  * a security exception occurs.
25  *
26  * <p>Unless explicitly allowed, all methods in this interface might
27  * throw a NullPointerException if given a {@code null} argument.
28  *
29  * @author Peter von der Ah&eacute;
30  * @author Jonathan Gibbons
31  * @see JavaFileManager
32  * @since 1.6
33  */

34 public interface JavaFileObject extends FileObject {
35
36     /**
37      * Kinds of JavaFileObjects.
38      */

39     enum Kind {
40         /**
41          * Source files written in the Java programming language. For
42          * example, regular files ending with {@code .java}.
43          */

44         SOURCE(".java"),
45
46         /**
47          * Class files for the Java Virtual Machine. For example,
48          * regular files ending with {@code .class}.
49          */

50         CLASS(".class"),
51
52         /**
53          * HTML files. For example, regular files ending with {@code
54          * .html}.
55          */

56         HTML(".html"),
57
58         /**
59          * Any other kind.
60          */

61         OTHER("");
62         /**
63          * The extension which (by convention) is normally used for
64          * this kind of file object. If no convention exists, the
65          * empty string ({@code ""}) is used.
66          */

67         public final String JavaDoc extension;
68         private Kind(String JavaDoc extension) {
69             extension.getClass(); // null check
70
this.extension = extension;
71         }
72     };
73
74     /**
75      * Gets the kind of this file object.
76      *
77      * @return the kind
78      */

79     Kind getKind();
80
81     /**
82      * Checks if this file object is compatible with the specified
83      * simple name and kind. A simple name is a single identifier
84      * (not qualified) as defined in the <a
85      * HREF="http://java.sun.com/docs/books/jls/">Java Language
86      * Specification</a> 3rd ed., section 6.2 "Names and Identifiers".
87      *
88      * @param simpleName a simple name of a class
89      * @param kind a kind
90      * @return {@code true} if this file object is compatible; false
91      * otherwise
92      */

93     boolean isNameCompatible(String JavaDoc simpleName, Kind kind);
94
95     /**
96      * Provides a hint about the nesting level of the class
97      * represented by this file object. This method may return
98      * {@link NestingKind#MEMBER} to mean
99      * {@link NestingKind#LOCAL} or {@link NestingKind#ANONYMOUS}.
100      * If the nesting level is not known or this file object does not
101      * represent a class file this method returns {@code null}.
102      *
103      * @return the nesting kind, or {@code null} if the nesting kind
104      * is not known
105      */

106     NestingKind getNestingKind();
107
108     /**
109      * Provides a hint about the access level of the class represented
110      * by this file object. If the access level is not known or if
111      * this file object does not represent a class file this method
112      * returns {@code null}.
113      *
114      * @return the access level
115      */

116     Modifier getAccessLevel();
117
118 }
119
Popular Tags