KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > compiler > AnnotationMemberType


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;
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.declaration.Declaration;
24 import org.apache.beehive.netui.compiler.typesystem.declaration.MemberDeclaration;
25 import org.apache.beehive.netui.compiler.typesystem.env.AnnotationProcessorEnvironment;
26
27
28 public class AnnotationMemberType
29         implements JpfLanguageConstants
30 {
31     /** set if this entire attribute type requires a particular runtime version. */
32     private String JavaDoc _requiredRuntimeVersion = null;
33     private AnnotationGrammar _parentGrammar;
34     private AnnotationMemberType _nextInChain;
35     
36
37     public AnnotationMemberType( String JavaDoc requiredRuntimeVersion, AnnotationGrammar parentGrammar )
38     {
39         _requiredRuntimeVersion = requiredRuntimeVersion;
40         _parentGrammar = parentGrammar;
41     }
42     
43     public AnnotationMemberType( String JavaDoc requiredRuntimeVersion, AnnotationGrammar parentGrammar,
44                                  AnnotationMemberType nextInChain )
45     {
46         this( requiredRuntimeVersion, parentGrammar );
47         _nextInChain = nextInChain;
48     }
49     
50     /**
51      * @return a result (any Object) that will be passed back to the parent checker. May be null</code>.
52      */

53     public final Object JavaDoc check( AnnotationTypeElementDeclaration valueDecl, AnnotationValue value,
54                                AnnotationInstance[] parentAnnotations, MemberDeclaration classMember,
55                                int annotationArrayIndex )
56             throws FatalCompileTimeException
57     {
58         //
59
// First check to see if this attribute requires a particular runtime version.
60
//
61
String JavaDoc valueName = valueDecl.getSimpleName();
62         Diagnostics diags = _parentGrammar.getDiagnostics();
63         _parentGrammar.getRuntimeVersionChecker().checkRuntimeVersion(
64                 _requiredRuntimeVersion, value, diags, "error.required-runtime-version-attribute",
65                 new Object JavaDoc[]{ valueName, PAGEFLOW_RUNTIME_JAR } );
66         
67         // for derived classes
68
Object JavaDoc retVal = onCheck( valueDecl, value, parentAnnotations, classMember, annotationArrayIndex );
69         if ( _nextInChain != null )
70         {
71             return _nextInChain.check( valueDecl, value, parentAnnotations, classMember, annotationArrayIndex );
72         }
73         return retVal;
74     }
75
76     /**
77      * @return a result (any Object) that will be passed back to the parent checker. May be null</code>.
78      */

79     public Object JavaDoc onCheck( AnnotationTypeElementDeclaration valueDecl, AnnotationValue member,
80                            AnnotationInstance[] parentAnnotations, MemberDeclaration classMember,
81                            int annotationArrayIndex )
82             throws FatalCompileTimeException
83     {
84         return null;
85     }
86     
87     protected void addError( Declaration element, String JavaDoc key )
88     {
89         _parentGrammar.addError( element, key, null );
90     }
91     
92     protected void addError( Declaration element, String JavaDoc key, Object JavaDoc[] args )
93     {
94         _parentGrammar.addError( element, key, args );
95     }
96     
97     protected void addError( Declaration element, String JavaDoc key, Object JavaDoc arg )
98     {
99         _parentGrammar.addError( element, key, new Object JavaDoc[]{ arg } );
100     }
101     
102     protected void addError( Declaration element, String JavaDoc key, Object JavaDoc arg1, Object JavaDoc arg2 )
103     {
104         _parentGrammar.addError( element, key, new Object JavaDoc[]{ arg1, arg2 } );
105     }
106     
107     protected void addError( Declaration element, String JavaDoc key, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3 )
108     {
109         _parentGrammar.addError( element, key, new Object JavaDoc[]{ arg1, arg2, arg3 } );
110     }
111     
112     protected void addError( AnnotationValue element, String JavaDoc key )
113     {
114         _parentGrammar.addError( element, key, null );
115     }
116     
117     protected void addError( AnnotationValue element, String JavaDoc key, Object JavaDoc[] args )
118     {
119         _parentGrammar.addError( element, key, args );
120     }
121     
122     protected void addError( AnnotationValue element, String JavaDoc key, Object JavaDoc arg1 )
123     {
124         _parentGrammar.addError( element, key, new Object JavaDoc[]{ arg1 } );
125     }
126     
127     protected void addError( AnnotationValue element, String JavaDoc key, Object JavaDoc arg1, Object JavaDoc arg2 )
128     {
129         _parentGrammar.addError( element, key, new Object JavaDoc[]{ arg1, arg2 } );
130     }
131     
132     protected void addError( AnnotationValue element, String JavaDoc key, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3 )
133     {
134         _parentGrammar.addError( element, key, new Object JavaDoc[]{ arg1, arg2, arg3 } );
135     }
136     
137     protected void addError( AnnotationInstance element, String JavaDoc key )
138     {
139         _parentGrammar.addError( element, key, null );
140     }
141     
142     protected void addError( AnnotationInstance element, String JavaDoc key, Object JavaDoc[] args )
143     {
144         _parentGrammar.addError( element, key, args );
145     }
146     
147     protected void addError( AnnotationInstance element, String JavaDoc key, Object JavaDoc arg1 )
148     {
149         _parentGrammar.addError( element, key, new Object JavaDoc[]{ arg1 } );
150     }
151     
152     protected void addError( AnnotationInstance element, String JavaDoc key, Object JavaDoc arg1, Object JavaDoc arg2 )
153     {
154         _parentGrammar.addError( element, key, new Object JavaDoc[]{ arg1, arg2 } );
155     }
156     
157     protected void addError( AnnotationInstance element, String JavaDoc key, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3 )
158     {
159         _parentGrammar.addError( element, key, new Object JavaDoc[]{ arg1, arg2, arg3 } );
160     }
161     
162     protected void addWarning( Declaration element, String JavaDoc key )
163     {
164         _parentGrammar.addWarning( element, key, null );
165     }
166     
167     protected void addWarning( Declaration element, String JavaDoc key, Object JavaDoc[] args )
168     {
169         _parentGrammar.addWarning( element, key, args );
170     }
171     
172     protected void addWarning( Declaration element, String JavaDoc key, Object JavaDoc arg )
173     {
174         _parentGrammar.addWarning( element, key, new Object JavaDoc[]{ arg } );
175     }
176     
177     protected void addWarning( Declaration element, String JavaDoc key, Object JavaDoc arg1, Object JavaDoc arg2 )
178     {
179         _parentGrammar.addWarning( element, key, new Object JavaDoc[]{ arg1, arg2 } );
180     }
181     
182     protected void addWarning( Declaration element, String JavaDoc key, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3 )
183     {
184         _parentGrammar.addWarning( element, key, new Object JavaDoc[]{ arg1, arg2, arg3 } );
185     }
186     
187     protected void addWarning( AnnotationValue element, String JavaDoc key )
188     {
189         _parentGrammar.addWarning( element, key, null );
190     }
191     
192     protected void addWarning( AnnotationValue element, String JavaDoc key, Object JavaDoc[] args )
193     {
194         _parentGrammar.addWarning( element, key, args );
195     }
196     
197     protected void addWarning( AnnotationValue element, String JavaDoc key, Object JavaDoc arg1 )
198     {
199         _parentGrammar.addWarning( element, key, new Object JavaDoc[]{ arg1 } );
200     }
201     
202     protected void addWarning( AnnotationValue element, String JavaDoc key, Object JavaDoc arg1, Object JavaDoc arg2 )
203     {
204         _parentGrammar.addWarning( element, key, new Object JavaDoc[]{ arg1, arg2 } );
205     }
206     
207     protected void addWarning( AnnotationValue element, String JavaDoc key, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3 )
208     {
209         _parentGrammar.addWarning( element, key, new Object JavaDoc[]{ arg1, arg2, arg3 } );
210     }
211     
212     protected void addWarning( AnnotationInstance element, String JavaDoc key )
213     {
214         _parentGrammar.addWarning( element, key, null );
215     }
216     
217     protected void addWarning( AnnotationInstance element, String JavaDoc key, Object JavaDoc[] args )
218     {
219         _parentGrammar.addWarning( element, key, args );
220     }
221     
222     protected void addWarning( AnnotationInstance element, String JavaDoc key, Object JavaDoc arg1 )
223     {
224         _parentGrammar.addWarning( element, key, new Object JavaDoc[]{ arg1 } );
225     }
226     
227     protected void addWarning( AnnotationInstance element, String JavaDoc key, Object JavaDoc arg1, Object JavaDoc arg2 )
228     {
229         _parentGrammar.addWarning( element, key, new Object JavaDoc[]{ arg1, arg2 } );
230     }
231     
232     protected void addWarning( AnnotationInstance element, String JavaDoc key, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3 )
233     {
234         _parentGrammar.addWarning( element, key, new Object JavaDoc[]{ arg1, arg2, arg3 } );
235     }
236     
237     protected AnnotationGrammar getParentGrammar()
238     {
239         return _parentGrammar;
240     }
241     
242     protected final AnnotationProcessorEnvironment getEnv()
243     {
244         return _parentGrammar.getEnv();
245     }
246     
247     protected final Diagnostics getDiagnostics()
248     {
249         return _parentGrammar.getDiagnostics();
250     }
251 }
252
Popular Tags