KickJava   Java API By Example, From Geeks To Geeks.

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


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.Declaration;
21 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance;
22 import org.apache.beehive.netui.compiler.typesystem.declaration.Modifier;
23 import org.apache.beehive.netui.compiler.typesystem.util.SourcePosition;
24 import org.apache.beehive.netui.compiler.typesystem.impl.env.SourcePositionImpl;
25 import org.apache.beehive.netui.compiler.typesystem.impl.DelegatingImpl;
26 import org.apache.beehive.netui.compiler.typesystem.impl.WrapperFactory;
27
28 import java.util.Collection JavaDoc;
29 import java.util.Set JavaDoc;
30 import java.util.HashSet JavaDoc;
31
32 public class DeclarationImpl
33         extends DelegatingImpl
34         implements Declaration
35 {
36     private AnnotationInstance[] _annotations;
37     private Set JavaDoc _modifiers;
38     
39     public DeclarationImpl( com.sun.mirror.declaration.Declaration delegate )
40     {
41         super( delegate );
42     }
43
44     public String JavaDoc getDocComment()
45     {
46         return getDelegate().getDocComment();
47     }
48
49     public AnnotationInstance[] getAnnotationInstances()
50     {
51         if ( _annotations == null )
52         {
53             Collection JavaDoc<com.sun.mirror.declaration.AnnotationMirror> delegateCollection = getDelegate().getAnnotationMirrors();
54             AnnotationInstance[] array = new AnnotationInstance[delegateCollection.size()];
55             int j = 0;
56             for ( com.sun.mirror.declaration.AnnotationMirror i : delegateCollection )
57             {
58                 array[j++] = WrapperFactory.get().getAnnotationInstance( i );
59             }
60             _annotations = array;
61         }
62
63         return _annotations;
64     }
65
66     public Set JavaDoc getModifiers()
67     {
68         if ( _modifiers == null )
69         {
70             Collection JavaDoc<com.sun.mirror.declaration.Modifier> delegateCollection = getDelegate().getModifiers();
71             Set JavaDoc modifiers = new HashSet JavaDoc();
72             for ( com.sun.mirror.declaration.Modifier i : delegateCollection )
73             {
74                 modifiers.add( ModifierImpl.get( i ) );
75             }
76             _modifiers = modifiers;
77         }
78
79         return _modifiers;
80     }
81
82     public String JavaDoc getSimpleName()
83     {
84         return getDelegate().getSimpleName();
85     }
86
87     public SourcePosition getPosition()
88     {
89         return SourcePositionImpl.get( getDelegate().getPosition() );
90     }
91
92     public boolean hasModifier( Modifier modifier )
93     {
94         return getModifiers().contains( modifier );
95     }
96
97     protected com.sun.mirror.declaration.Declaration getDelegate()
98     {
99         return ( com.sun.mirror.declaration.Declaration ) super.getDelegate();
100     }
101 }
102
Popular Tags