KickJava   Java API By Example, From Geeks To Geeks.

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


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.AnnotationGrammar;
22 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationValue;
23 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance;
24 import org.apache.beehive.netui.compiler.typesystem.declaration.MemberDeclaration;
25 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationTypeElementDeclaration;
26
27
28
29 public class MessageKeyType
30         extends AnnotationMemberType
31 {
32     public MessageKeyType( String JavaDoc requiredRuntimeVersion, AnnotationGrammar parentGrammar )
33     {
34         super( requiredRuntimeVersion, parentGrammar );
35     }
36     
37     
38     public Object JavaDoc onCheck( AnnotationTypeElementDeclaration valueDecl, AnnotationValue member,
39                            AnnotationInstance[] parentAnnotations, MemberDeclaration classMember,
40                            int annotationArrayIndex )
41     {
42         if ( ( ( String JavaDoc ) member.getValue() ).length() == 0 )
43         {
44             addError( member, "error.empty-string-not-allowed" );
45         }
46         // We're not currently supporting generation of validation messages.
47
/*
48         //
49         // If there is a list of (generated) validation messages, and if the current message key isn't in it,
50         // output a warning.
51         //
52         TypeDeclaration outerType = CompilerUtils.getOutermostClass( classMember );
53         Collection validationMessages =
54                 CompilerUtils.getAnnotationArrayValue( outerType, CONTROLLER_TAG_NAME, VALIDATION_MESSAGES_ATTR, true );
55         
56         if ( validationMessages != null )
57         {
58             String value = ( String ) member.getValue();
59             
60             for ( java.util.Iterator ii = validationMessages.iterator(); ii.hasNext(); )
61             {
62                 AnnotationInstance validationMessage = ( AnnotationInstance ) ii.next();
63                 String msgKey = CompilerUtils.getString( validationMessage, KEY_ATTR, true );
64                 assert msgKey != null;
65                 if ( value.equals( msgKey ) ) return null; // ok, we found it.
66             }
67         
68             addWarning( member, "warning.missing-validation-message", VALIDATION_MESSAGE_TAG_NAME, value );
69         }
70         */

71         
72         return null;
73     }
74 }
75
Popular Tags