src/share/classes/javax/tools/JavaFileObject.java

Tue, 09 Oct 2012 19:10:00 -0700

author
jjg
date
Tue, 09 Oct 2012 19:10:00 -0700
changeset 1357
c75be5bc5283
parent 972
694ff82ca68e
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8000663: clean up langtools imports
Reviewed-by: darcy

duke@1 1 /*
jjg@1357 2 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
ohair@554 7 * published by the Free Software Foundation. Oracle designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
ohair@554 9 * by Oracle in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
ohair@554 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 22 * or visit www.oracle.com if you need additional information or have any
ohair@554 23 * questions.
duke@1 24 */
duke@1 25
duke@1 26 package javax.tools;
duke@1 27
duke@1 28 import javax.lang.model.element.NestingKind;
duke@1 29 import javax.lang.model.element.Modifier;
duke@1 30
duke@1 31 /**
duke@1 32 * File abstraction for tools operating on Java™ programming language
duke@1 33 * source and class files.
duke@1 34 *
duke@1 35 * <p>All methods in this interface might throw a SecurityException if
duke@1 36 * a security exception occurs.
duke@1 37 *
duke@1 38 * <p>Unless explicitly allowed, all methods in this interface might
duke@1 39 * throw a NullPointerException if given a {@code null} argument.
duke@1 40 *
duke@1 41 * @author Peter von der Ah&eacute;
duke@1 42 * @author Jonathan Gibbons
duke@1 43 * @see JavaFileManager
duke@1 44 * @since 1.6
duke@1 45 */
duke@1 46 public interface JavaFileObject extends FileObject {
duke@1 47
duke@1 48 /**
duke@1 49 * Kinds of JavaFileObjects.
duke@1 50 */
duke@1 51 enum Kind {
duke@1 52 /**
duke@1 53 * Source files written in the Java programming language. For
duke@1 54 * example, regular files ending with {@code .java}.
duke@1 55 */
duke@1 56 SOURCE(".java"),
duke@1 57
duke@1 58 /**
duke@1 59 * Class files for the Java Virtual Machine. For example,
duke@1 60 * regular files ending with {@code .class}.
duke@1 61 */
duke@1 62 CLASS(".class"),
duke@1 63
duke@1 64 /**
duke@1 65 * HTML files. For example, regular files ending with {@code
duke@1 66 * .html}.
duke@1 67 */
duke@1 68 HTML(".html"),
duke@1 69
duke@1 70 /**
duke@1 71 * Any other kind.
duke@1 72 */
duke@1 73 OTHER("");
duke@1 74 /**
duke@1 75 * The extension which (by convention) is normally used for
duke@1 76 * this kind of file object. If no convention exists, the
duke@1 77 * empty string ({@code ""}) is used.
duke@1 78 */
duke@1 79 public final String extension;
duke@1 80 private Kind(String extension) {
duke@1 81 extension.getClass(); // null check
duke@1 82 this.extension = extension;
duke@1 83 }
duke@1 84 };
duke@1 85
duke@1 86 /**
duke@1 87 * Gets the kind of this file object.
duke@1 88 *
duke@1 89 * @return the kind
duke@1 90 */
duke@1 91 Kind getKind();
duke@1 92
duke@1 93 /**
duke@1 94 * Checks if this file object is compatible with the specified
duke@1 95 * simple name and kind. A simple name is a single identifier
jjh@972 96 * (not qualified) as defined in
jjh@972 97 * <cite>The Java&trade; Language Specification</cite>,
jjh@972 98 * section 6.2 "Names and Identifiers".
duke@1 99 *
duke@1 100 * @param simpleName a simple name of a class
duke@1 101 * @param kind a kind
duke@1 102 * @return {@code true} if this file object is compatible; false
duke@1 103 * otherwise
duke@1 104 */
duke@1 105 boolean isNameCompatible(String simpleName, Kind kind);
duke@1 106
duke@1 107 /**
duke@1 108 * Provides a hint about the nesting level of the class
duke@1 109 * represented by this file object. This method may return
duke@1 110 * {@link NestingKind#MEMBER} to mean
duke@1 111 * {@link NestingKind#LOCAL} or {@link NestingKind#ANONYMOUS}.
duke@1 112 * If the nesting level is not known or this file object does not
duke@1 113 * represent a class file this method returns {@code null}.
duke@1 114 *
duke@1 115 * @return the nesting kind, or {@code null} if the nesting kind
duke@1 116 * is not known
duke@1 117 */
duke@1 118 NestingKind getNestingKind();
duke@1 119
duke@1 120 /**
duke@1 121 * Provides a hint about the access level of the class represented
duke@1 122 * by this file object. If the access level is not known or if
duke@1 123 * this file object does not represent a class file this method
duke@1 124 * returns {@code null}.
duke@1 125 *
duke@1 126 * @return the access level
duke@1 127 */
duke@1 128 Modifier getAccessLevel();
duke@1 129
duke@1 130 }

mercurial