KickJava   Java API By Example, From Geeks To Geeks.

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


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.xdoclet.typesystem.impl.declaration;
19
20 import org.apache.beehive.netui.compiler.typesystem.declaration.ClassDeclaration;
21 import org.apache.beehive.netui.compiler.typesystem.declaration.ConstructorDeclaration;
22 import org.apache.beehive.netui.compiler.xdoclet.typesystem.impl.WrapperFactory;
23 import org.apache.beehive.netui.compiler.typesystem.type.ClassType;
24
25 import java.util.Collection JavaDoc;
26 import java.util.Iterator JavaDoc;
27 import java.util.List JavaDoc;
28 import java.util.Collections JavaDoc;
29
30 import xjavadoc.XClass;
31 import xjavadoc.XConstructor;
32 import xjavadoc.XPackage;
33 import xjavadoc.XDoc;
34 import xjavadoc.XProgramElement;
35 import xjavadoc.XJavaDoc;
36
37 public class ClassDeclarationImpl
38         extends TypeDeclarationImpl
39         implements ClassDeclaration
40 {
41     private ConstructorDeclaration[] _constructors;
42     
43     public ClassDeclarationImpl( XClass delegate )
44     {
45         super( delegate );
46     }
47
48     public ClassType getSuperclass()
49     {
50         return WrapperFactory.get().getClassType( getDelegateXClass().getSuperclass() );
51     }
52
53     public ConstructorDeclaration[] getConstructors()
54     {
55         if ( _constructors == null )
56         {
57             Collection JavaDoc delegateCollection = getDelegateXClass().getConstructors();
58             ConstructorDeclaration[] array = new ConstructorDeclaration[delegateCollection.size()];
59             int j = 0;
60             for ( Iterator JavaDoc i = delegateCollection.iterator(); i.hasNext(); )
61             {
62                 array[j++] = WrapperFactory.get().getConstructorDeclaration( ( XConstructor ) i.next() );
63             }
64             
65             if ( array.length == 0 )
66             {
67                 XConstructor ctor = new DefaultConstructor( getDelegateXClass() );
68                 ConstructorDeclaration decl = WrapperFactory.get().getConstructorDeclaration( ctor );
69                 _constructors = new ConstructorDeclaration[]{ decl };
70             }
71             else
72             {
73                 _constructors = array;
74             }
75         }
76
77         return _constructors;
78     }
79     
80     protected XClass getDelegateXClass()
81     {
82         return ( XClass ) super.getDelegate();
83     }
84     
85     private static class DefaultConstructor
86         implements XConstructor
87     {
88         private XClass _containingClass;
89         
90         public DefaultConstructor( XClass containingClass )
91         {
92             _containingClass = containingClass;
93         }
94         
95         public boolean isNative()
96         {
97             return false;
98         }
99
100         public boolean isSynchronized()
101         {
102             return false;
103         }
104
105         public List JavaDoc getParameters()
106         {
107             return Collections.EMPTY_LIST;
108         }
109
110         public List JavaDoc getThrownExceptions()
111         {
112             assert false : "NYI";
113             throw new UnsupportedOperationException JavaDoc( "NYI" );
114         }
115
116         public boolean throwsException( String JavaDoc s )
117         {
118             return false;
119         }
120
121         public boolean isConstructor()
122         {
123             return true;
124         }
125
126         public String JavaDoc getSignature( boolean b )
127         {
128             assert false : "NYI";
129             throw new UnsupportedOperationException JavaDoc( "NYI" );
130         }
131
132         public String JavaDoc getNameWithSignature( boolean b )
133         {
134             assert false : "NYI";
135             throw new UnsupportedOperationException JavaDoc( "NYI" );
136         }
137
138         public String JavaDoc getParameterTypes()
139         {
140             assert false : "NYI";
141             throw new UnsupportedOperationException JavaDoc( "NYI" );
142         }
143
144         public XClass getContainingClass()
145         {
146             return _containingClass;
147         }
148
149         public XPackage getContainingPackage()
150         {
151             return _containingClass.getContainingPackage();
152         }
153
154         public boolean isFinal()
155         {
156             return false;
157         }
158
159         public boolean isPackagePrivate()
160         {
161             return false;
162         }
163
164         public boolean isPrivate()
165         {
166             return false;
167         }
168
169         public boolean isProtected()
170         {
171             return false;
172         }
173
174         public boolean isAbstract()
175         {
176             return false;
177         }
178
179         public boolean isPublic()
180         {
181             return true;
182         }
183
184         public boolean isStatic()
185         {
186             return false;
187         }
188
189         public String JavaDoc getModifiers()
190         {
191             return "public";
192         }
193
194         public int getModifierSpecifier()
195         {
196             assert false : "NYI";
197             throw new UnsupportedOperationException JavaDoc( "NYI" );
198         }
199
200         public XDoc getDoc()
201         {
202             return null;
203         }
204
205         public XProgramElement getSuperElement()
206         {
207             assert false : "NYI";
208             throw new UnsupportedOperationException JavaDoc( "NYI" );
209         }
210
211         public List JavaDoc getSuperInterfaceElements()
212         {
213             assert false : "NYI";
214             throw new UnsupportedOperationException JavaDoc( "NYI" );
215         }
216
217         public XJavaDoc getXJavaDoc()
218         {
219             assert false : "NYI";
220             throw new UnsupportedOperationException JavaDoc( "NYI" );
221         }
222
223         public void updateDoc()
224         {
225             assert false : "NYI";
226             throw new UnsupportedOperationException JavaDoc( "NYI" );
227         }
228
229         public int compareTo( Object JavaDoc o )
230         {
231             assert false : "NYI";
232             throw new UnsupportedOperationException JavaDoc( "NYI" );
233         }
234
235         public String JavaDoc getName()
236         {
237             assert false : "NYI";
238             throw new UnsupportedOperationException JavaDoc( "NYI" );
239         }
240     }
241 }
242
Popular Tags