KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.lang.reflect.Field JavaDoc;
15 import java.lang.reflect.Type JavaDoc;
16
17 import org.aspectj.lang.reflect.AjType;
18 import org.aspectj.lang.reflect.AjTypeSystem;
19 import org.aspectj.lang.reflect.InterTypeFieldDeclaration;
20
21 /**
22  * @author colyer
23  *
24  */

25 public class InterTypeFieldDeclarationImpl extends InterTypeDeclarationImpl
26         implements InterTypeFieldDeclaration {
27
28     private String JavaDoc name;
29     private AjType<?> type;
30     private Type JavaDoc genericType;
31     
32     /**
33      * @param decType
34      * @param target
35      * @param mods
36      */

37     public InterTypeFieldDeclarationImpl(AjType<?> decType, String JavaDoc target,
38             int mods, String JavaDoc name, AjType<?> type, Type JavaDoc genericType) {
39         super(decType, target, mods);
40         this.name = name;
41         this.type = type;
42         this.genericType = genericType;
43     }
44     
45     public InterTypeFieldDeclarationImpl(AjType<?> decType, AjType<?> targetType, Field JavaDoc base) {
46         super(decType,targetType,base.getModifiers());
47         this.name = base.getName();
48         this.type = AjTypeSystem.getAjType(base.getType());
49         Type JavaDoc gt = base.getGenericType();
50         if (gt instanceof Class JavaDoc) {
51             this.genericType = AjTypeSystem.getAjType((Class JavaDoc<?>)gt);
52         } else {
53             this.genericType = gt;
54         }
55     }
56
57     /* (non-Javadoc)
58      * @see org.aspectj.lang.reflect.InterTypeFieldDeclaration#getName()
59      */

60     public String JavaDoc getName() {
61         return this.name;
62     }
63
64     /* (non-Javadoc)
65      * @see org.aspectj.lang.reflect.InterTypeFieldDeclaration#getType()
66      */

67     public AjType<?> getType() {
68         return this.type;
69     }
70
71     /* (non-Javadoc)
72      * @see org.aspectj.lang.reflect.InterTypeFieldDeclaration#getGenericType()
73      */

74     public Type JavaDoc getGenericType() {
75         return this.genericType;
76     }
77     
78     public String JavaDoc toString() {
79         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
80         sb.append(java.lang.reflect.Modifier.toString(getModifiers()));
81         sb.append(" ");
82         sb.append(getType().toString());
83         sb.append(" ");
84         sb.append(this.targetTypeName);
85         sb.append(".");
86         sb.append(getName());
87         return sb.toString();
88     }
89
90 }
91
Popular Tags