langtools/src/share/classes/javax/tools/JavaFileObject.java
author poonam
Tue, 26 Feb 2013 08:58:20 -0800
changeset 15808 c75f11af1033
parent 14258 8d2148961366
child 22163 3651128c74eb
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 9303
diff changeset
     2
 * Copyright (c) 2005, 2012, 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;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
 * File abstraction for tools operating on Java™ programming language
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 * source and class files.
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * <p>All methods in this interface might throw a SecurityException if
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * a security exception occurs.
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * <p>Unless explicitly allowed, all methods in this interface might
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * throw a NullPointerException if given a {@code null} argument.
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * @author Peter von der Ah&eacute;
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * @author Jonathan Gibbons
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 * @see JavaFileManager
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * @since 1.6
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
public interface JavaFileObject extends FileObject {
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
     * Kinds of JavaFileObjects.
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
    enum Kind {
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
         * Source files written in the Java programming language.  For
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
         * example, regular files ending with {@code .java}.
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
        SOURCE(".java"),
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
         * Class files for the Java Virtual Machine.  For example,
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
         * regular files ending with {@code .class}.
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
        CLASS(".class"),
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
         * HTML files.  For example, regular files ending with {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
         * .html}.
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
        HTML(".html"),
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
         * Any other kind.
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
        OTHER("");
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
         * The extension which (by convention) is normally used for
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
         * this kind of file object.  If no convention exists, the
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
         * empty string ({@code ""}) is used.
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
        public final String extension;
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
        private Kind(String extension) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
            extension.getClass(); // null check
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
            this.extension = extension;
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
    };
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
     * Gets the kind of this file object.
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
}