KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > lang > reflect > AjType


1 /* *******************************************************************
2  * Copyright (c) 2005 Contributors.
3  * All rights reserved.
4  * This program and the accompanying materials are made available
5  * under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution and is available at
7  * http://eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Adrian Colyer Initial implementation
11  * ******************************************************************/

12 package org.aspectj.lang.reflect;
13
14 import java.lang.reflect.AnnotatedElement JavaDoc;
15 import java.lang.reflect.Constructor JavaDoc;
16 import java.lang.reflect.Field JavaDoc;
17 import java.lang.reflect.Method JavaDoc;
18 import java.lang.reflect.Type JavaDoc;
19 import java.lang.reflect.TypeVariable JavaDoc;
20
21 /**
22  * The runtime representation of a type (Aspect, Class, Interface, Annotation, Enum, or Array) in an AspectJ
23  * program.
24  */

25 public interface AjType<T> extends Type JavaDoc, AnnotatedElement JavaDoc {
26     
27     /**
28      * The name of this type, in the same format as returned by Class.getName()
29      */

30     public String JavaDoc getName();
31     
32     /**
33      * The package in which this type is declared
34      */

35     public Package JavaDoc getPackage();
36     
37     /**
38      * The interfaces implemented by this type
39      */

40     public AjType<?>[] getInterfaces();
41         
42     /**
43      * The modifiers declared for this type. The return value can be interpreted
44      * using java.lang.reflect.Modifier
45      */

46     public int getModifiers();
47     
48     /**
49      * The java.lang.Class that corresponds to this AjType
50      */

51     public Class JavaDoc<T> getJavaClass();
52
53     // scope
54

55     /**
56      * The supertype of this type. If this type represents Object or a primitive type
57      * then null is returned.
58      */

59     public AjType<?> getSupertype();
60
61     /**
62      * The generic supertype of this type, as defined by Class.getGenericSupertype
63      */

64     public Type JavaDoc getGenericSupertype();
65
66     /**
67      * If this type represents a local or anonymous type declared within a method, return
68      * then enclosing Method object.
69      */

70     public Method JavaDoc getEnclosingMethod();
71     
72     /**
73      * If this type represents a local or anonymous type declared within a constructor, return
74      * then enclosing Method object.
75      */

76     public Constructor JavaDoc getEnclosingConstructor();
77
78     /**
79      * Returns the immediately enclosing type of this type.
80      */

81     public AjType<?> getEnclosingType();
82     
83     /**
84      * If this type is a member of another type, return the AjType representing the type
85      * in which it was declared.
86      */

87     public AjType<?> getDeclaringType();
88
89     /**
90      * If this type represents an aspect, returns the associated per-clause.
91      * Returns null for non-aspect types.
92      */

93     public PerClause getPerClause();
94     
95     // inner types
96
/**
97      * Returns an array containing all the public types that are members of this type
98      */

99     public AjType<?>[] getAjTypes();
100     
101     /**
102      * Returns an array containing all the types declared by this type
103      */

104     public AjType<?>[] getDeclaredAjTypes();
105     
106     // constructors
107

108     /**
109      * Returns the constructor object for the specified public constructor of this type
110      */

111     public Constructor JavaDoc getConstructor(AjType<?>... parameterTypes) throws NoSuchMethodException JavaDoc;
112     
113     /**
114      * Returns all of the public constructors of this type
115      */

116     public Constructor JavaDoc[] getConstructors();
117     
118     /**
119      * Returns the constructor object for the specified constructor of this type
120      */

121     public Constructor JavaDoc getDeclaredConstructor(AjType<?>... parameterTypes) throws NoSuchMethodException JavaDoc;
122
123     /**
124      * Returns all the constructors declared in this type
125      */

126     public Constructor JavaDoc[] getDeclaredConstructors();
127     
128     // fields
129

130     /**
131      * Return the field declared in this type with the given name
132      */

133     public Field JavaDoc getDeclaredField(String JavaDoc name) throws NoSuchFieldException JavaDoc;
134     
135     /**
136      * Returns all the fields declared in this type
137      */

138     public Field JavaDoc[] getDeclaredFields();
139     
140     /**
141      * Return the public field with the given name
142      */

143     public Field JavaDoc getField(String JavaDoc name) throws NoSuchFieldException JavaDoc;
144     
145     /**
146      * Return the public fields declared by this type
147      */

148     public Field JavaDoc[] getFields();
149     
150     // methods
151

152     /**
153      * Return the method object for the specified method declared in this type
154      */

155     public Method JavaDoc getDeclaredMethod(String JavaDoc name, AjType<?>... parameterTypes) throws NoSuchMethodException JavaDoc;
156     
157     /**
158      * Return the method object for the specified public method declared in this type
159      */

160     public Method JavaDoc getMethod(String JavaDoc name, AjType<?>... parameterTypes) throws NoSuchMethodException JavaDoc;
161     
162     /**
163      * Return all the methods declared by this type
164      */

165     public Method JavaDoc[] getDeclaredMethods();
166     
167     /**
168      * Returns all the public methods of this type
169      */

170     public Method JavaDoc[] getMethods();
171     
172     // pointcuts
173

174     /**
175      * Return the pointcut object representing the specified pointcut declared by this type
176      */

177     public Pointcut getDeclaredPointcut(String JavaDoc name) throws NoSuchPointcutException;
178     
179     /**
180      * Return the pointcut object representing the specified public pointcut
181      */

182     public Pointcut getPointcut(String JavaDoc name) throws NoSuchPointcutException;
183
184     /**
185      * Returns all of the pointcuts declared by this type
186      */

187     public Pointcut[] getDeclaredPointcuts();
188
189     /**
190      * Returns all of the public pointcuts of this type
191      */

192     public Pointcut[] getPointcuts();
193     
194     // advice
195

196     /**
197      * Returns all of the advice declared by this type, of an advice kind contained in the
198      * parameter list.
199      */

200     public Advice[] getDeclaredAdvice(AdviceKind... ofTypes);
201     
202     /**
203      * Returns all of the advice for this type, of an advice kind contained in the parameter
204      * list.
205      */

206     public Advice[] getAdvice(AdviceKind... ofTypes);
207     
208     /**
209      * Returns the advice with the given name. For an @AspectJ declared advice member,
210      * this is the name of the annotated method. For a code-style advice declaration, this
211      * is the name given in the @AdviceName annotation if present.
212      */

213     public Advice getAdvice(String JavaDoc name) throws NoSuchAdviceException;
214     
215     /**
216      * Returns the advice declared in this type with the given name. For an @AspectJ declared advice member,
217      * this is the name of the annotated method. For a code-style advice declaration, this
218      * is the name given in the @AdviceName annotation if present.
219      */

220     public Advice getDeclaredAdvice(String JavaDoc name) throws NoSuchAdviceException;
221         
222     // inter-type declarations
223

224     /**
225      * Return the inter-type method declared by this type matching the given specification
226      */

227     public InterTypeMethodDeclaration getDeclaredITDMethod(String JavaDoc name, AjType<?> target, AjType<?>... parameterTypes) throws NoSuchMethodException JavaDoc;
228     
229     /**
230      * Return all of the inter-type methods declared by this type
231      */

232     public InterTypeMethodDeclaration[] getDeclaredITDMethods();
233
234     /**
235      * Return the public inter-type method of this type matching the given specification
236      */

237     public InterTypeMethodDeclaration getITDMethod(String JavaDoc name, AjType<?> target, AjType<?>... parameterTypes) throws NoSuchMethodException JavaDoc;
238     
239     /**
240      * Return all of the public inter-type declared methods of this type
241      */

242     public InterTypeMethodDeclaration[] getITDMethods();
243         
244     /**
245      * Return the inter-type constructor declared by this type matching the given specification
246      */

247     public InterTypeConstructorDeclaration getDeclaredITDConstructor(AjType<?> target, AjType<?>... parameterTypes) throws NoSuchMethodException JavaDoc;
248     
249     /**
250      * Returns all of the inter-type constructors declared by this type
251      */

252     public InterTypeConstructorDeclaration[] getDeclaredITDConstructors();
253
254     /**
255      * Return the public inter-type constructor matching the given specification
256      */

257     public InterTypeConstructorDeclaration getITDConstructor(AjType<?> target, AjType<?>... parameterTypes) throws NoSuchMethodException JavaDoc;
258
259     /**
260      * Return all of the public inter-type constructors of this type
261      */

262     public InterTypeConstructorDeclaration[] getITDConstructors();
263
264     /**
265      * Return the inter-type field declared in this type with the given specification
266      */

267     public InterTypeFieldDeclaration getDeclaredITDField(String JavaDoc name, AjType<?> target) throws NoSuchFieldException JavaDoc;
268
269     /**
270      * Return all of the inter-type fields declared in this type
271      */

272     public InterTypeFieldDeclaration[] getDeclaredITDFields();
273
274     /**
275      * Return the public inter-type field matching the given specification
276      */

277     public InterTypeFieldDeclaration getITDField(String JavaDoc name, AjType<?> target) throws NoSuchFieldException JavaDoc;
278
279     /**
280      * Return all of the public inter-type fields for this type
281      */

282     public InterTypeFieldDeclaration[] getITDFields();
283         
284     // declare statements
285
/**
286      * Returns all of the declare error and declare warning members of this type,
287      * including declare error/warning members inherited from super-types
288      */

289     public DeclareErrorOrWarning[] getDeclareErrorOrWarnings();
290     
291     /**
292      * Returns all of the declare parents members of this type, including
293      * declare parent members inherited from super-types
294      */

295     public DeclareParents[] getDeclareParents();
296     
297     /**
298      * Return all of the declare soft members of this type, including declare
299      * soft members inherited from super-types
300      */

301     public DeclareSoft[] getDeclareSofts();
302
303     /**
304      * Return all of the declare annotation members of this type, including declare
305      * annotation members inherited from super-types
306      */

307     public DeclareAnnotation[] getDeclareAnnotations();
308     
309     /**
310      * Return all of the declare precedence members of this type, including declare
311      * precedence members inherited from super-types
312      */

313     public DeclarePrecedence[] getDeclarePrecedence();
314     
315     // misc
316

317     /**
318      * Returns the elements of this enum class, or null if this type does not represent
319      * an enum type.
320      */

321     public T[] getEnumConstants();
322     
323     /**
324      * Returns an array of TypeVariable objects that represent the type variables declared by
325      * this type (if any)
326      */

327     public TypeVariable JavaDoc<Class JavaDoc<T>>[] getTypeParameters();
328
329     /**
330      * True if this is an enum type
331      */

332     public boolean isEnum();
333
334     /**
335      * True if the given object is assignment-compatible with an object of the type represented
336      * by this AjType
337      */

338     public boolean isInstance(Object JavaDoc o);
339
340     /**
341      * True if this is an interface type
342      */

343     public boolean isInterface();
344
345     /**
346      * Returns true if and only if the underlying type is a local class
347      */

348     public boolean isLocalClass();
349     
350     /**
351      * Returns true if and only if the underlying type is a member class
352      */

353     public boolean isMemberClass();
354     
355     /**
356      * Return true if this is an array type
357      */

358     public boolean isArray();
359
360     /**
361      * Return true if this object represents a primitive type
362      */

363     public boolean isPrimitive();
364
365     /**
366      * Return true if this is an aspect type
367      */

368     public boolean isAspect();
369     
370     /**
371      * Returns true if and only if the underlying type is a member aspect
372      */

373     public boolean isMemberAspect();
374
375     /**
376      * Returns true if and only if the underlying type is a privileged aspect
377      */

378     public boolean isPrivileged();
379     
380 }
381
Popular Tags