KickJava   Java API By Example, From Geeks To Geeks.

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


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.AnnotationInstance;
21 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationTypeElementDeclaration;
22 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationValue;
23 import org.apache.beehive.netui.compiler.typesystem.impl.DelegatingImpl;
24 import org.apache.beehive.netui.compiler.typesystem.impl.WrapperFactory;
25 import org.apache.beehive.netui.compiler.typesystem.impl.env.SourcePositionImpl;
26 import org.apache.beehive.netui.compiler.typesystem.type.AnnotationType;
27 import org.apache.beehive.netui.compiler.typesystem.util.SourcePosition;
28
29 import java.util.HashMap JavaDoc;
30 import java.util.Map JavaDoc;
31 import java.util.Set JavaDoc;
32
33 public class AnnotationInstanceImpl
34         extends DelegatingImpl
35         implements AnnotationInstance
36 {
37     private Map JavaDoc< AnnotationTypeElementDeclaration, AnnotationValue > _elementValues;
38     
39     public AnnotationInstanceImpl( com.sun.mirror.declaration.AnnotationMirror delegate )
40     {
41         super( delegate );
42     }
43
44     public AnnotationType getAnnotationType()
45     {
46         return WrapperFactory.get().getAnnotationType( getDelegate().getAnnotationType() );
47     }
48
49     public SourcePosition getPosition()
50     {
51         return SourcePositionImpl.get( getDelegate().getPosition() );
52     }
53
54     // Map<AnnotationTypeElementDeclaration, AnnotationValue> getElementValues();
55
public Map JavaDoc getElementValues()
56     {
57         if ( _elementValues == null )
58         {
59             Set JavaDoc< Map.Entry JavaDoc< com.sun.mirror.declaration.AnnotationTypeElementDeclaration, com.sun.mirror.declaration.AnnotationValue > >
60                     entries = getDelegate().getElementValues().entrySet();
61             Map JavaDoc< AnnotationTypeElementDeclaration, AnnotationValue > elementValues =
62                     new HashMap JavaDoc< AnnotationTypeElementDeclaration, AnnotationValue >();
63             for ( Map.Entry JavaDoc< com.sun.mirror.declaration.AnnotationTypeElementDeclaration, com.sun.mirror.declaration.AnnotationValue > i : entries )
64             {
65                 elementValues.put( WrapperFactory.get().getAnnotationTypeElementDeclaration( i.getKey() ), WrapperFactory.get().getAnnotationValue( i.getValue() ) );
66             }
67             _elementValues = elementValues;
68         }
69
70         return _elementValues;
71     }
72
73     protected com.sun.mirror.declaration.AnnotationMirror getDelegate()
74     {
75         return ( com.sun.mirror.declaration.AnnotationMirror ) super.getDelegate();
76     }
77 }
78
Popular Tags