KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > spoon > support > reflect > reference > CtArrayTypeReferenceImpl


1 package spoon.support.reflect.reference;
2
3 import java.lang.reflect.Array JavaDoc;
4
5 import spoon.reflect.declaration.CtPackage;
6 import spoon.reflect.declaration.CtType;
7 import spoon.reflect.reference.CtArrayTypeReference;
8 import spoon.reflect.reference.CtTypeReference;
9 import spoon.reflect.visitor.CtVisitor;
10
11 public class CtArrayTypeReferenceImpl<T> extends CtTypeReferenceImpl<T>
12         implements CtArrayTypeReference<T> {
13     private static final long serialVersionUID = 1L;
14
15     CtTypeReference<?> componentType;
16
17     public CtArrayTypeReferenceImpl() {
18         super();
19     }
20
21     public CtTypeReference<?> getComponentType() {
22         return componentType;
23     }
24
25     public void setComponentType(CtTypeReference<?> componentType) {
26         this.componentType = componentType;
27     }
28
29     @Override JavaDoc
30     public String JavaDoc getSimpleName() {
31         return componentType.getSimpleName();
32     }
33
34     public void accept(CtVisitor visitor) {
35         visitor.visitCtArrayTypeReference(this);
36     }
37
38     @Override JavaDoc
39     public String JavaDoc getQualifiedName() {
40         if (getComponentType().getDeclaringType() != null) {
41             return getComponentType().getDeclaringType().getQualifiedName()
42                     + CtType.INNERTTYPE_SEPARATOR + getSimpleName();
43         } else if (getComponentType().getPackage() != null) {
44             return getComponentType().getPackage().getSimpleName()
45                     + CtPackage.PACKAGE_SEPARATOR + getSimpleName();
46         } else {
47             return getSimpleName();
48         }
49     }
50
51     @SuppressWarnings JavaDoc("unchecked")
52     @Override JavaDoc
53     public Class JavaDoc<T> getActualClass() {
54         Class JavaDoc c = getComponentType().getActualClass();
55         if (c == null)
56             return null;
57         return (Class JavaDoc) Array.newInstance(c, 0).getClass();
58     }
59
60 }
61
Popular Tags