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