KickJava   Java API By Example, From Geeks To Geeks.

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


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.grammar.CommandHandlerGrammar;
21 import org.apache.beehive.netui.compiler.typesystem.declaration.ClassDeclaration;
22 import org.apache.beehive.netui.compiler.typesystem.declaration.MethodDeclaration;
23 import org.apache.beehive.netui.compiler.typesystem.env.AnnotationProcessorEnvironment;
24
25 import java.util.HashMap JavaDoc;
26 import java.util.Map JavaDoc;
27
28
29 public class FacesBackingChecker
30         extends BaseChecker
31         implements JpfLanguageConstants
32 {
33     public FacesBackingChecker( AnnotationProcessorEnvironment env, FacesBackingInfo fbInfo, Diagnostics diags )
34     {
35         super( env, fbInfo, diags );
36     }
37     
38     public Map JavaDoc onCheck( ClassDeclaration jclass )
39             throws FatalCompileTimeException
40     {
41         if ( ! CompilerUtils.isAssignableFrom( FACES_BACKING_BEAN_CLASS, jclass, getEnv() ))
42         {
43             getDiagnostics().addError( jclass, "error.does-not-extend-base", FACES_BACKING_BEAN_CLASS );
44             return null;
45         }
46         
47         ClassDeclaration[] packageClasses = jclass.getPackage().getClasses();
48         ClassDeclaration jpfClass = null;
49         
50         for ( int i = 0; i < packageClasses.length; i++ )
51         {
52             ClassDeclaration classDecl = packageClasses[i];
53             if ( CompilerUtils.isPageFlowClass( classDecl, getEnv() ) ) jpfClass = classDecl;
54         }
55         
56         FlowControllerInfo fcInfo = new FlowControllerInfo( jpfClass );
57         fcInfo.startBuild( getEnv(), jpfClass );
58         
59         CommandHandlerGrammar chg =
60                 new CommandHandlerGrammar( getEnv(), getDiagnostics(), getRuntimeVersionChecker(), jpfClass, fcInfo );
61         MethodDeclaration[] methods = CompilerUtils.getClassMethods( jclass, COMMAND_HANDLER_TAG_NAME );
62
63         for ( int i = 0; i < methods.length; i++ )
64         {
65             MethodDeclaration method = methods[i];
66             getFBSourceFileInfo().addCommandHandler( method.getSimpleName() );
67             chg.check( CompilerUtils.getAnnotation( method, COMMAND_HANDLER_TAG_NAME ), null, method );
68         }
69         
70         Map JavaDoc checkResultMap = new HashMap JavaDoc();
71         checkResultMap.put( JpfLanguageConstants.ExtraInfoKeys.facesBackingInfo, getSourceFileInfo() );
72         return checkResultMap;
73     }
74
75     protected FacesBackingInfo getFBSourceFileInfo()
76     {
77         return ( FacesBackingInfo ) super.getSourceFileInfo();
78     }
79 }
80
Popular Tags