01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: * $Header:$
18: */
19: package org.apache.beehive.netui.compiler.grammar;
20:
21: import org.apache.beehive.netui.compiler.AnnotationMemberType;
22: import org.apache.beehive.netui.compiler.CompilerUtils;
23: import org.apache.beehive.netui.compiler.Diagnostics;
24: import org.apache.beehive.netui.compiler.FlowControllerInfo;
25: import org.apache.beehive.netui.compiler.RuntimeVersionChecker;
26: import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance;
27: import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationTypeElementDeclaration;
28: import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationValue;
29: import org.apache.beehive.netui.compiler.typesystem.declaration.ClassDeclaration;
30: import org.apache.beehive.netui.compiler.typesystem.declaration.MemberDeclaration;
31: import org.apache.beehive.netui.compiler.typesystem.env.CoreAnnotationProcessorEnv;
32:
33: public class RaiseActionGrammar extends BaseFlowControllerGrammar {
34: private static final String[][] REQUIRED_ATTRS = { { ACTION_ATTR } };
35:
36: public RaiseActionGrammar(CoreAnnotationProcessorEnv env,
37: Diagnostics diags, String requiredRuntimeVersion,
38: RuntimeVersionChecker runtimeVersionChecker,
39: ClassDeclaration jpfClass, FlowControllerInfo fcInfo) {
40: super (env, diags, requiredRuntimeVersion,
41: runtimeVersionChecker, fcInfo);
42: addMemberType(ACTION_ATTR, new PageFlowActionType(jpfClass));
43: addMemberType(OUTPUT_FORM_BEAN_ATTR, new MemberFieldType(null,
44: null, this ));
45: }
46:
47: private class PageFlowActionType extends AnnotationMemberType {
48: private ClassDeclaration _jpfClass;
49:
50: public PageFlowActionType(ClassDeclaration jpfClass) {
51: super (RaiseActionGrammar.this .getRequiredRuntimeVersion(),
52: RaiseActionGrammar.this );
53: _jpfClass = jpfClass;
54: }
55:
56: public Object onCheck(
57: AnnotationTypeElementDeclaration valueDecl,
58: AnnotationValue member,
59: AnnotationInstance[] parentAnnotations,
60: MemberDeclaration classMember, int annotationArrayIndex) {
61: String action = (String) member.getValue();
62:
63: if (_jpfClass != null
64: && !WebappPathOrActionType.actionExists(action,
65: _jpfClass, null, getEnv(),
66: getFlowControllerInfo(), true)) {
67: getDiagnostics().addWarning(member,
68: "warning.no-such-action", action,
69: CompilerUtils.getSourceFile(_jpfClass, true));
70: }
71:
72: return null;
73: }
74: }
75:
76: public String[][] getRequiredAttrs() {
77: return REQUIRED_ATTRS;
78: }
79: }
|