langtools/src/share/classes/javax/lang/model/element/TypeElement.java
author jjh
Wed, 13 Apr 2011 11:35:43 -0700
changeset 9303 eae35c201e19
parent 8233 fda68eae1504
child 11553 4389b722f8dc
permissions -rw-r--r--
7032975: API files in javax.annotation.processing need to be updated for references to JLS 7032972: API files in javax.tools need to updated for references to JVM Spec with editions/hyperlinks 7032978: API files in javax.tools need to be updated for references to JLS with editions/hyperlinks Summary: Removed URLs and 'edition' references Reviewed-by: jjg, darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
8233
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
     2
 * Copyright (c) 2005, 2011, 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: 3897
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: 3897
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: 3897
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 3897
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 3897
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.lang.model.element;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import java.util.List;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import javax.lang.model.type.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import javax.lang.model.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 * Represents a class or interface program element.  Provides access
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 * to information about the type and its members.  Note that an enum
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * type is a kind of class and an annotation type is a kind of
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * interface.
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * <p> <a name="ELEM_VS_TYPE"></a>
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * While a {@code TypeElement} represents a class or interface
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * <i>element</i>, a {@link DeclaredType} represents a class
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * or interface <i>type</i>, the latter being a use
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * (or <i>invocation</i>) of the former.
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 * The distinction is most apparent with generic types,
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * for which a single element can define a whole
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * family of types.  For example, the element
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 * {@code java.util.Set} corresponds to the parameterized types
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 * {@code java.util.Set<String>} and {@code java.util.Set<Number>}
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 * (and many others), and to the raw type {@code java.util.Set}.
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 * <p> Each method of this interface that returns a list of elements
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
 * will return them in the order that is natural for the underlying
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 * source of program information.  For example, if the underlying
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
 * source of information is Java source code, then the elements will be
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
 * returned in source code order.
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
 * @author Joseph D. Darcy
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
 * @author Scott Seligman
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
 * @author Peter von der Ah&eacute;
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
 * @see DeclaredType
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
 * @since 1.6
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
 */
2088
6e2c8594b2e5 6460529: Provide mixin interfaces for getQualifiedName and getTypeParameters
darcy
parents: 10
diff changeset
    62
public interface TypeElement extends Element, Parameterizable, QualifiedNameable {
3897
fe8cc7e3a505 6884227: Clarify ordering requirements of javax.lang.model.TypeElement.getEnclosedElements
darcy
parents: 2088
diff changeset
    63
    /**
fe8cc7e3a505 6884227: Clarify ordering requirements of javax.lang.model.TypeElement.getEnclosedElements
darcy
parents: 2088
diff changeset
    64
     * {@inheritDoc}
fe8cc7e3a505 6884227: Clarify ordering requirements of javax.lang.model.TypeElement.getEnclosedElements
darcy
parents: 2088
diff changeset
    65
     *
fe8cc7e3a505 6884227: Clarify ordering requirements of javax.lang.model.TypeElement.getEnclosedElements
darcy
parents: 2088
diff changeset
    66
     * <p> Note that as a particular instance of the {@linkplain
fe8cc7e3a505 6884227: Clarify ordering requirements of javax.lang.model.TypeElement.getEnclosedElements
darcy
parents: 2088
diff changeset
    67
     * javax.lang.model.element general accuracy requirements} and the
fe8cc7e3a505 6884227: Clarify ordering requirements of javax.lang.model.TypeElement.getEnclosedElements
darcy
parents: 2088
diff changeset
    68
     * ordering behavior required of this interface, the list of
fe8cc7e3a505 6884227: Clarify ordering requirements of javax.lang.model.TypeElement.getEnclosedElements
darcy
parents: 2088
diff changeset
    69
     * enclosed elements will be returned in the natural order for the
fe8cc7e3a505 6884227: Clarify ordering requirements of javax.lang.model.TypeElement.getEnclosedElements
darcy
parents: 2088
diff changeset
    70
     * originating source of information about the type.  For example,
fe8cc7e3a505 6884227: Clarify ordering requirements of javax.lang.model.TypeElement.getEnclosedElements
darcy
parents: 2088
diff changeset
    71
     * if the information about the type is originating from a source
fe8cc7e3a505 6884227: Clarify ordering requirements of javax.lang.model.TypeElement.getEnclosedElements
darcy
parents: 2088
diff changeset
    72
     * file, the elements will be returned in source code order.
fe8cc7e3a505 6884227: Clarify ordering requirements of javax.lang.model.TypeElement.getEnclosedElements
darcy
parents: 2088
diff changeset
    73
     * (However, in that case the the ordering of synthesized
fe8cc7e3a505 6884227: Clarify ordering requirements of javax.lang.model.TypeElement.getEnclosedElements
darcy
parents: 2088
diff changeset
    74
     * elements, such as a default constructor, is not specified.)
fe8cc7e3a505 6884227: Clarify ordering requirements of javax.lang.model.TypeElement.getEnclosedElements
darcy
parents: 2088
diff changeset
    75
     *
fe8cc7e3a505 6884227: Clarify ordering requirements of javax.lang.model.TypeElement.getEnclosedElements
darcy
parents: 2088
diff changeset
    76
     * @return the enclosed elements in proper order, or an empty list if none
fe8cc7e3a505 6884227: Clarify ordering requirements of javax.lang.model.TypeElement.getEnclosedElements
darcy
parents: 2088
diff changeset
    77
     */
fe8cc7e3a505 6884227: Clarify ordering requirements of javax.lang.model.TypeElement.getEnclosedElements
darcy
parents: 2088
diff changeset
    78
    List<? extends Element> getEnclosedElements();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
     * Returns the <i>nesting kind</i> of this type element.
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
     * @return the nesting kind of this type element
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
    NestingKind getNestingKind();
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
     * Returns the fully qualified name of this type element.
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
     * More precisely, it returns the <i>canonical</i> name.
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
     * For local and anonymous classes, which do not have canonical names,
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     * an empty name is returned.
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     * <p>The name of a generic type does not include any reference
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     * to its formal type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
     * For example, the fully qualified name of the interface
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
     * {@code java.util.Set<E>} is "{@code java.util.Set}".
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     * Nested types use "{@code .}" as a separator, as in
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
     * "{@code java.util.Map.Entry}".
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
     * @return the fully qualified name of this class or interface, or
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
     * an empty name if none
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
     * @see Elements#getBinaryName
9303
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 8233
diff changeset
   104
     * @jls 6.7 Fully Qualified Names and Canonical Names
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
    Name getQualifiedName();
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
8233
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   108
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   109
    /**
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   110
     * Returns the simple name of this type element.
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   111
     *
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   112
     * For an anonymous class, an empty name is returned.
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   113
     *
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   114
     * @return the simple name of this class or interface,
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   115
     * an empty name for an anonymous class
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   116
     *
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   117
     */
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   118
    @Override
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   119
    Name getSimpleName();
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   120
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     * Returns the direct superclass of this type element.
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
     * If this type element represents an interface or the class
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
     * {@code java.lang.Object}, then a {@link NoType}
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
     * with kind {@link TypeKind#NONE NONE} is returned.
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
     * @return the direct superclass, or a {@code NoType} if there is none
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
    TypeMirror getSuperclass();
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
     * Returns the interface types directly implemented by this class
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
     * or extended by this interface.
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
     * @return the interface types directly implemented by this class
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     * or extended by this interface, or an empty list if there are none
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
    List<? extends TypeMirror> getInterfaces();
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
     * Returns the formal type parameters of this type element
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
     * in declaration order.
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
     * @return the formal type parameters, or an empty list
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
     * if there are none
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
    List<? extends TypeParameterElement> getTypeParameters();
8233
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   148
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   149
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   150
    /**
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   151
     * Returns the package of a top-level type and returns the
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   152
     * immediately lexically enclosing element for a {@linkplain
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   153
     * NestingKind#isNested nested} type.
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   154
     *
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   155
     * @return the package of a top-level type, the immediately
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   156
     * lexically enclosing element for a nested type
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   157
     */
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   158
    @Override
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   159
    Element getEnclosingElement();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
}