KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > compiler > typesystem > impl > declaration > TypeDeclarationImpl


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * $Header:$
17  */

18 package org.apache.beehive.netui.compiler.typesystem.impl.declaration;
19
20 import org.apache.beehive.netui.compiler.typesystem.declaration.FieldDeclaration;
21 import org.apache.beehive.netui.compiler.typesystem.declaration.MethodDeclaration;
22 import org.apache.beehive.netui.compiler.typesystem.declaration.PackageDeclaration;
23 import org.apache.beehive.netui.compiler.typesystem.declaration.TypeDeclaration;
24 import org.apache.beehive.netui.compiler.typesystem.impl.WrapperFactory;
25 import org.apache.beehive.netui.compiler.typesystem.type.InterfaceType;
26
27 import java.util.Collection JavaDoc;
28
29 public class TypeDeclarationImpl
30         extends MemberDeclarationImpl
31         implements TypeDeclaration
32 {
33     private InterfaceType[] _superInterfaces;
34     private MethodDeclaration[] _methods;
35     private TypeDeclaration[] _nestedTypes;
36     private FieldDeclaration[] _fields;
37     
38     public TypeDeclarationImpl( com.sun.mirror.declaration.TypeDeclaration delegate )
39     {
40         super( delegate );
41     }
42     
43     public PackageDeclaration getPackage()
44     {
45         return WrapperFactory.get().getPackageDeclaration( getDelegate().getPackage() );
46     }
47
48     public String JavaDoc getQualifiedName()
49     {
50         return getDelegate().getQualifiedName();
51     }
52
53     /*
54     public TypeParameterDeclaration[] getFormalTypeParameters()
55     {
56     }
57     */

58
59     public InterfaceType[] getSuperinterfaces()
60     {
61         if ( _superInterfaces == null )
62         {
63             Collection JavaDoc<com.sun.mirror.type.InterfaceType> delegateCollection = getDelegate().getSuperinterfaces();
64             InterfaceType[] array = new InterfaceType[delegateCollection.size()];
65             int j = 0;
66             for ( com.sun.mirror.type.InterfaceType i : delegateCollection )
67             {
68                 array[j++] = WrapperFactory.get().getInterfaceType( i );
69             }
70             _superInterfaces = array;
71         }
72
73         return _superInterfaces;
74     }
75
76     public FieldDeclaration[] getFields()
77     {
78         if ( _fields == null )
79         {
80             Collection JavaDoc<com.sun.mirror.declaration.FieldDeclaration> delegateCollection = getDelegate().getFields();
81             FieldDeclaration[] array = new FieldDeclaration[delegateCollection.size()];
82             int j = 0;
83             for ( com.sun.mirror.declaration.FieldDeclaration i : delegateCollection )
84             {
85                 array[j++] = WrapperFactory.get().getFieldDeclaration( i );
86             }
87             _fields = array;
88         }
89
90         return _fields;
91     }
92
93     public MethodDeclaration[] getMethods()
94     {
95         if ( _methods == null )
96         {
97             Collection JavaDoc< ? extends com.sun.mirror.declaration.MethodDeclaration > delegateCollection =
98                     getDelegate().getMethods();
99             MethodDeclaration[] array = new MethodDeclaration[delegateCollection.size()];
100             int j = 0;
101             for ( com.sun.mirror.declaration.MethodDeclaration i : delegateCollection )
102             {
103                 array[j++] = WrapperFactory.get().getMethodDeclaration( i );
104             }
105             _methods = array;
106         }
107
108         return _methods;
109     }
110
111     public TypeDeclaration[] getNestedTypes()
112     {
113         if ( _nestedTypes == null )
114         {
115             Collection JavaDoc<com.sun.mirror.declaration.TypeDeclaration> delegateCollection = getDelegate().getNestedTypes();
116             TypeDeclaration[] array = new TypeDeclaration[delegateCollection.size()];
117             int j = 0;
118             for ( com.sun.mirror.declaration.TypeDeclaration i : delegateCollection )
119             {
120                 array[j++] = WrapperFactory.get().getTypeDeclaration( i );
121             }
122             _nestedTypes = array;
123         }
124
125         return _nestedTypes;
126     }
127     
128     protected com.sun.mirror.declaration.TypeDeclaration getDelegate()
129     {
130         return ( com.sun.mirror.declaration.TypeDeclaration ) super.getDelegate();
131     }
132 }
133
Popular Tags