author | poonam |
Tue, 26 Feb 2013 08:58:20 -0800 | |
changeset 15808 | c75f11af1033 |
parent 15714 | d9a83ab62853 |
child 22448 | a85fbad9d687 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
11553
4389b722f8dc
7130768: Clarify behavior of Element.getEnclosingElements in subtypes
darcy
parents:
9303
diff
changeset
|
2 |
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. |
10 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
10 | 24 |
*/ |
25 |
||
26 |
package javax.lang.model.element; |
|
27 |
||
28 |
import java.util.List; |
|
29 |
import javax.lang.model.type.*; |
|
30 |
import javax.lang.model.util.*; |
|
31 |
||
32 |
/** |
|
33 |
* Represents a class or interface program element. Provides access |
|
34 |
* to information about the type and its members. Note that an enum |
|
35 |
* type is a kind of class and an annotation type is a kind of |
|
36 |
* interface. |
|
37 |
* |
|
38 |
* <p> <a name="ELEM_VS_TYPE"></a> |
|
39 |
* While a {@code TypeElement} represents a class or interface |
|
40 |
* <i>element</i>, a {@link DeclaredType} represents a class |
|
41 |
* or interface <i>type</i>, the latter being a use |
|
42 |
* (or <i>invocation</i>) of the former. |
|
43 |
* The distinction is most apparent with generic types, |
|
44 |
* for which a single element can define a whole |
|
45 |
* family of types. For example, the element |
|
46 |
* {@code java.util.Set} corresponds to the parameterized types |
|
47 |
* {@code java.util.Set<String>} and {@code java.util.Set<Number>} |
|
48 |
* (and many others), and to the raw type {@code java.util.Set}. |
|
49 |
* |
|
50 |
* <p> Each method of this interface that returns a list of elements |
|
51 |
* will return them in the order that is natural for the underlying |
|
52 |
* source of program information. For example, if the underlying |
|
53 |
* source of information is Java source code, then the elements will be |
|
54 |
* returned in source code order. |
|
55 |
* |
|
56 |
* @author Joseph D. Darcy |
|
57 |
* @author Scott Seligman |
|
58 |
* @author Peter von der Ahé |
|
59 |
* @see DeclaredType |
|
60 |
* @since 1.6 |
|
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 |
/** |
11553
4389b722f8dc
7130768: Clarify behavior of Element.getEnclosingElements in subtypes
darcy
parents:
9303
diff
changeset
|
64 |
* Returns the fields, methods, constructors, and member types |
4389b722f8dc
7130768: Clarify behavior of Element.getEnclosingElements in subtypes
darcy
parents:
9303
diff
changeset
|
65 |
* that are directly declared in this class or interface. |
4389b722f8dc
7130768: Clarify behavior of Element.getEnclosingElements in subtypes
darcy
parents:
9303
diff
changeset
|
66 |
* |
4389b722f8dc
7130768: Clarify behavior of Element.getEnclosingElements in subtypes
darcy
parents:
9303
diff
changeset
|
67 |
* This includes any (implicit) default constructor and |
4389b722f8dc
7130768: Clarify behavior of Element.getEnclosingElements in subtypes
darcy
parents:
9303
diff
changeset
|
68 |
* the implicit {@code values} and {@code valueOf} methods of an |
4389b722f8dc
7130768: Clarify behavior of Element.getEnclosingElements in subtypes
darcy
parents:
9303
diff
changeset
|
69 |
* enum type. |
3897
fe8cc7e3a505
6884227: Clarify ordering requirements of javax.lang.model.TypeElement.getEnclosedElements
darcy
parents:
2088
diff
changeset
|
70 |
* |
fe8cc7e3a505
6884227: Clarify ordering requirements of javax.lang.model.TypeElement.getEnclosedElements
darcy
parents:
2088
diff
changeset
|
71 |
* <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
|
72 |
* 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
|
73 |
* 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
|
74 |
* 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
|
75 |
* 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
|
76 |
* 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
|
77 |
* 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
|
78 |
* (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
|
79 |
* 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
|
80 |
* |
fe8cc7e3a505
6884227: Clarify ordering requirements of javax.lang.model.TypeElement.getEnclosedElements
darcy
parents:
2088
diff
changeset
|
81 |
* @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
|
82 |
*/ |
11553
4389b722f8dc
7130768: Clarify behavior of Element.getEnclosingElements in subtypes
darcy
parents:
9303
diff
changeset
|
83 |
@Override |
3897
fe8cc7e3a505
6884227: Clarify ordering requirements of javax.lang.model.TypeElement.getEnclosedElements
darcy
parents:
2088
diff
changeset
|
84 |
List<? extends Element> getEnclosedElements(); |
10 | 85 |
|
86 |
/** |
|
87 |
* Returns the <i>nesting kind</i> of this type element. |
|
88 |
* |
|
89 |
* @return the nesting kind of this type element |
|
90 |
*/ |
|
91 |
NestingKind getNestingKind(); |
|
92 |
||
93 |
/** |
|
94 |
* Returns the fully qualified name of this type element. |
|
95 |
* More precisely, it returns the <i>canonical</i> name. |
|
96 |
* For local and anonymous classes, which do not have canonical names, |
|
97 |
* an empty name is returned. |
|
98 |
* |
|
99 |
* <p>The name of a generic type does not include any reference |
|
100 |
* to its formal type parameters. |
|
101 |
* For example, the fully qualified name of the interface |
|
102 |
* {@code java.util.Set<E>} is "{@code java.util.Set}". |
|
103 |
* Nested types use "{@code .}" as a separator, as in |
|
104 |
* "{@code java.util.Map.Entry}". |
|
105 |
* |
|
106 |
* @return the fully qualified name of this class or interface, or |
|
107 |
* an empty name if none |
|
108 |
* |
|
109 |
* @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
|
110 |
* @jls 6.7 Fully Qualified Names and Canonical Names |
10 | 111 |
*/ |
112 |
Name getQualifiedName(); |
|
113 |
||
8233
fda68eae1504
7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents:
5520
diff
changeset
|
114 |
/** |
fda68eae1504
7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents:
5520
diff
changeset
|
115 |
* Returns the simple name of this type element. |
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 |
* 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
|
118 |
* |
fda68eae1504
7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents:
5520
diff
changeset
|
119 |
* @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
|
120 |
* an empty name for an anonymous class |
fda68eae1504
7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents:
5520
diff
changeset
|
121 |
* |
fda68eae1504
7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents:
5520
diff
changeset
|
122 |
*/ |
fda68eae1504
7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents:
5520
diff
changeset
|
123 |
@Override |
fda68eae1504
7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents:
5520
diff
changeset
|
124 |
Name getSimpleName(); |
fda68eae1504
7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents:
5520
diff
changeset
|
125 |
|
10 | 126 |
/** |
127 |
* Returns the direct superclass of this type element. |
|
128 |
* If this type element represents an interface or the class |
|
129 |
* {@code java.lang.Object}, then a {@link NoType} |
|
130 |
* with kind {@link TypeKind#NONE NONE} is returned. |
|
131 |
* |
|
132 |
* @return the direct superclass, or a {@code NoType} if there is none |
|
133 |
*/ |
|
134 |
TypeMirror getSuperclass(); |
|
135 |
||
136 |
/** |
|
137 |
* Returns the interface types directly implemented by this class |
|
138 |
* or extended by this interface. |
|
139 |
* |
|
140 |
* @return the interface types directly implemented by this class |
|
141 |
* or extended by this interface, or an empty list if there are none |
|
142 |
*/ |
|
143 |
List<? extends TypeMirror> getInterfaces(); |
|
144 |
||
145 |
/** |
|
146 |
* Returns the formal type parameters of this type element |
|
147 |
* in declaration order. |
|
148 |
* |
|
149 |
* @return the formal type parameters, or an empty list |
|
150 |
* if there are none |
|
151 |
*/ |
|
152 |
List<? extends TypeParameterElement> getTypeParameters(); |
|
8233
fda68eae1504
7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents:
5520
diff
changeset
|
153 |
|
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 |
* 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
|
156 |
* immediately lexically enclosing element for a {@linkplain |
fda68eae1504
7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents:
5520
diff
changeset
|
157 |
* NestingKind#isNested nested} type. |
fda68eae1504
7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents:
5520
diff
changeset
|
158 |
* |
fda68eae1504
7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents:
5520
diff
changeset
|
159 |
* @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
|
160 |
* lexically enclosing element for a nested type |
fda68eae1504
7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents:
5520
diff
changeset
|
161 |
*/ |
fda68eae1504
7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents:
5520
diff
changeset
|
162 |
@Override |
fda68eae1504
7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents:
5520
diff
changeset
|
163 |
Element getEnclosingElement(); |
10 | 164 |
} |