KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > compiler > typesystem > impl > env > AnnotationProcessorEnvironmentImpl


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.env;
19
20 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationTypeDeclaration;
21 import org.apache.beehive.netui.compiler.typesystem.declaration.Declaration;
22 import org.apache.beehive.netui.compiler.typesystem.declaration.TypeDeclaration;
23 import org.apache.beehive.netui.compiler.typesystem.env.AnnotationProcessorEnvironment;
24 import org.apache.beehive.netui.compiler.typesystem.env.Filer;
25 import org.apache.beehive.netui.compiler.typesystem.env.Messager;
26 import org.apache.beehive.netui.compiler.typesystem.impl.DelegatingImpl;
27 import org.apache.beehive.netui.compiler.typesystem.impl.WrapperFactory;
28 import org.apache.beehive.netui.compiler.typesystem.impl.declaration.AnnotationTypeDeclarationImpl;
29 import org.apache.beehive.netui.compiler.Diagnostics;
30
31 import java.util.Collection JavaDoc;
32 import java.util.Map JavaDoc;
33 import java.util.HashMap JavaDoc;
34
35 public class AnnotationProcessorEnvironmentImpl
36         extends DelegatingImpl
37         implements AnnotationProcessorEnvironment
38 {
39     private TypeDeclaration[] _specifiedTypeDeclarations;
40     private Map JavaDoc _attributes;
41     private Diagnostics _diagnostics;
42     
43     protected AnnotationProcessorEnvironmentImpl( com.sun.mirror.apt.AnnotationProcessorEnvironment delegate )
44     {
45         super( delegate );
46     }
47     
48     public static AnnotationProcessorEnvironment get( com.sun.mirror.apt.AnnotationProcessorEnvironment delegate )
49     {
50         return delegate != null ? new AnnotationProcessorEnvironmentImpl( delegate ) : null;
51     }
52
53     public Map JavaDoc getOptions()
54     {
55         return getDelegate().getOptions();
56     }
57
58     public Messager getMessager()
59     {
60         return MessagerImpl.get( getDelegate().getMessager() );
61     }
62
63     public Filer getFiler()
64     {
65         assert false : "NYI";
66         throw new UnsupportedOperationException JavaDoc( "not implemented" );
67     }
68
69     public TypeDeclaration[] getSpecifiedTypeDeclarations()
70     {
71         if ( _specifiedTypeDeclarations == null )
72         {
73             Collection JavaDoc<com.sun.mirror.declaration.TypeDeclaration> delegateCollection = getDelegate().getSpecifiedTypeDeclarations();
74             TypeDeclaration[] array = new TypeDeclaration[delegateCollection.size()];
75             int j = 0;
76             for ( com.sun.mirror.declaration.TypeDeclaration i : delegateCollection )
77             {
78                 array[j++] = WrapperFactory.get().getTypeDeclaration( i );
79             }
80             _specifiedTypeDeclarations = array;
81         }
82
83         return _specifiedTypeDeclarations;
84     }
85
86     public TypeDeclaration getTypeDeclaration( String JavaDoc s )
87     {
88         return WrapperFactory.get().getTypeDeclaration( getDelegate().getTypeDeclaration( s ) );
89     }
90
91     public Declaration[] getDeclarationsAnnotatedWith( AnnotationTypeDeclaration decl )
92     {
93         assert decl instanceof AnnotationTypeDeclarationImpl : decl.getClass().getName();
94         Collection JavaDoc< com.sun.mirror.declaration.Declaration > delegateCollection =
95                 getDelegate().getDeclarationsAnnotatedWith( ( ( AnnotationTypeDeclarationImpl ) decl ).getDelegate() );
96         Declaration[] array = new Declaration[ delegateCollection.size() ];
97         int j = 0;
98         for ( com.sun.mirror.declaration.Declaration i : delegateCollection )
99         {
100             array[ j++ ] = WrapperFactory.get().getDeclaration( i );
101         }
102         return array;
103     }
104
105     protected com.sun.mirror.apt.AnnotationProcessorEnvironment getDelegate()
106     {
107         return ( com.sun.mirror.apt.AnnotationProcessorEnvironment ) super.getDelegate();
108     }
109
110     public void setAttribute( String JavaDoc propertyName, Object JavaDoc value )
111     {
112         if ( _attributes == null ) _attributes = new HashMap JavaDoc();
113         _attributes.put( propertyName, value );
114     }
115
116     public Object JavaDoc getAttribute( String JavaDoc propertyName )
117     {
118         return _attributes != null ? _attributes.get( propertyName ) : null;
119     }
120 }
121
Popular Tags