Path: blob/master/src/java.compiler/share/classes/javax/tools/JavaFileObject.java
41152 views
/*1* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.tools;2627import javax.lang.model.element.NestingKind;28import javax.lang.model.element.Modifier;29import java.util.Objects;3031/**32* File abstraction for tools operating on Java programming language33* source and class files.34*35* <p>All methods in this interface might throw a SecurityException if36* a security exception occurs.37*38* <p>Unless explicitly allowed, all methods in this interface might39* throw a NullPointerException if given a {@code null} argument.40*41* @author Peter von der Ahé42* @author Jonathan Gibbons43* @see JavaFileManager44* @since 1.645*/46public interface JavaFileObject extends FileObject {4748/**49* Kinds of JavaFileObjects.50*/51enum Kind {52/**53* Source files written in the Java programming language. For54* example, regular files ending with {@code .java}.55*/56SOURCE(".java"),5758/**59* Class files for the Java Virtual Machine. For example,60* regular files ending with {@code .class}.61*/62CLASS(".class"),6364/**65* HTML files. For example, regular files ending with {@code .html}.66*/67HTML(".html"),6869/**70* Any other kind.71*/72OTHER("");73/**74* The extension which (by convention) is normally used for75* this kind of file object. If no convention exists, the76* empty string ({@code ""}) is used.77*/78public final String extension;79Kind(String extension) {80this.extension = Objects.requireNonNull(extension);81}82}8384/**85* Returns the kind of this file object.86*87* @return the kind88*/89Kind getKind();9091/**92* Checks if this file object is compatible with the specified93* simple name and kind. A simple name is a single identifier94* (not qualified) as defined in95* <cite>The Java Language Specification</cite>, section {@jls 6.2}.96*97* @param simpleName a simple name of a class98* @param kind a kind99* @return {@code true} if this file object is compatible; {@code false}100* otherwise101*/102boolean isNameCompatible(String simpleName, Kind kind);103104/**105* Provides a hint about the nesting level of the class106* represented by this file object. This method may return107* {@link NestingKind#MEMBER} to mean108* {@link NestingKind#LOCAL} or {@link NestingKind#ANONYMOUS}.109* If the nesting level is not known or this file object does not110* represent a class file this method returns {@code null}.111*112* @return the nesting kind, or {@code null} if the nesting kind113* is not known114*/115NestingKind getNestingKind();116117/**118* Provides a hint about the access level of the class represented119* by this file object. If the access level is not known or120* this file object does not represent a class file this method121* returns {@code null}.122*123* @return the access level124*/125Modifier getAccessLevel();126127}128129130