KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > internal > lang > reflect > InterTypeDeclarationImpl


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.internal.lang.reflect;
13
14 import org.aspectj.lang.reflect.AjType;
15 import org.aspectj.lang.reflect.InterTypeDeclaration;
16
17 /**
18  * @author colyer
19  *
20  */

21 public class InterTypeDeclarationImpl implements InterTypeDeclaration {
22
23     private AjType<?> declaringType;
24     protected String JavaDoc targetTypeName;
25     private AjType<?> targetType;
26     private int modifiers;
27     
28     public InterTypeDeclarationImpl(AjType<?> decType, String JavaDoc target, int mods) {
29         this.declaringType = decType;
30         this.targetTypeName = target;
31         this.modifiers = mods;
32         try {
33             this.targetType = (AjType<?>) StringToType.stringToType(target, decType.getJavaClass());
34         } catch (ClassNotFoundException JavaDoc cnf) {
35             // we'll only report this later if the user asks for the target type.
36
}
37     }
38     
39     public InterTypeDeclarationImpl(AjType<?> decType, AjType<?> targetType, int mods) {
40         this.declaringType = decType;
41         this.targetType = targetType;
42         this.targetTypeName = targetType.getName();
43         this.modifiers = mods;
44     }
45
46     /* (non-Javadoc)
47      * @see org.aspectj.lang.reflect.InterTypeDeclaration#getDeclaringType()
48      */

49     public AjType<?> getDeclaringType() {
50         return this.declaringType;
51     }
52
53     /* (non-Javadoc)
54      * @see org.aspectj.lang.reflect.InterTypeDeclaration#getTargetType()
55      */

56     public AjType<?> getTargetType() throws ClassNotFoundException JavaDoc {
57         if (this.targetType == null) throw new ClassNotFoundException JavaDoc(this.targetTypeName);
58         return this.targetType;
59     }
60
61     /* (non-Javadoc)
62      * @see org.aspectj.lang.reflect.InterTypeDeclaration#getModifiers()
63      */

64     public int getModifiers() {
65         return this.modifiers;
66     }
67
68 }
69
Popular Tags