KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > compiler > grammar > RaiseActionGrammar


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.grammar;
19
20 import org.apache.beehive.netui.compiler.AnnotationMemberType;
21 import org.apache.beehive.netui.compiler.CompilerUtils;
22 import org.apache.beehive.netui.compiler.Diagnostics;
23 import org.apache.beehive.netui.compiler.FlowControllerInfo;
24 import org.apache.beehive.netui.compiler.RuntimeVersionChecker;
25 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance;
26 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationTypeElementDeclaration;
27 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationValue;
28 import org.apache.beehive.netui.compiler.typesystem.declaration.ClassDeclaration;
29 import org.apache.beehive.netui.compiler.typesystem.declaration.MemberDeclaration;
30 import org.apache.beehive.netui.compiler.typesystem.env.AnnotationProcessorEnvironment;
31
32
33 public class RaiseActionGrammar
34         extends BaseFlowControllerGrammar
35 {
36     private static final String JavaDoc[][] REQUIRED_ATTRS = { { ACTION_ATTR } };
37     
38     public RaiseActionGrammar( AnnotationProcessorEnvironment env, Diagnostics diags, String JavaDoc requiredRuntimeVersion,
39                                RuntimeVersionChecker runtimeVersionChecker, ClassDeclaration jpfClass,
40                                FlowControllerInfo fcInfo )
41     {
42         super( env, diags, requiredRuntimeVersion, runtimeVersionChecker, fcInfo );
43         addMemberType( ACTION_ATTR, new PageFlowActionType( jpfClass ) );
44         addMemberType( OUTPUT_FORM_BEAN_ATTR, new MemberFieldType( null , null, this ) );
45     }
46     
47     private class PageFlowActionType
48             extends AnnotationMemberType
49     {
50         private ClassDeclaration _jpfClass;
51         
52         public PageFlowActionType( ClassDeclaration jpfClass )
53         {
54             super( RaiseActionGrammar.this.getRequiredRuntimeVersion(), RaiseActionGrammar.this );
55             _jpfClass = jpfClass;
56         }
57
58         
59         public Object JavaDoc onCheck( AnnotationTypeElementDeclaration valueDecl, AnnotationValue member,
60                                AnnotationInstance[] parentAnnotations, MemberDeclaration classMember,
61                                int annotationArrayIndex )
62         {
63             String JavaDoc action = ( String JavaDoc ) member.getValue();
64             
65             if ( _jpfClass != null
66                  && ! WebappPathOrActionType.actionExists( action, _jpfClass, null, getEnv(), getFlowControllerInfo(), true ) )
67             {
68                 getDiagnostics().addWarning( member, "warning.no-such-action", action,
69                                              CompilerUtils.getSourceFile( _jpfClass, true ) );
70             }
71             
72             return null;
73         }
74     }
75     
76     public String JavaDoc[][] getRequiredAttrs()
77     {
78         return REQUIRED_ATTRS;
79     }
80 }
81
Popular Tags