You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ri...@apache.org on 2004/09/28 02:05:28 UTC

svn commit: rev 47352 - in incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler: . grammar

Author: rich
Date: Mon Sep 27 17:05:28 2004
New Revision: 47352

Modified:
   incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FormBeanChecker.java
   incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/MessageKeyType.java
Log:
Fixed the annotation processor to emit an error if the 'messageKey' attribute is the empty string in any of the validation annotations (@Jpf.Validate*).

DRT: netui (WinXP)
BB: self (linux)



Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FormBeanChecker.java
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FormBeanChecker.java	(original)
+++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FormBeanChecker.java	Mon Sep 27 17:05:28 2004
@@ -57,31 +57,29 @@
         GetterValidatablePropertyGrammar validatablePropertyGrammar = new GetterValidatablePropertyGrammar();
         boolean isFormBeanClass = CompilerUtils.getAnnotation( jclass, FORM_BEAN_TAG_NAME ) != null;
         
-        if ( ! isFormBeanClass )
+        //
+        // Look for ValidationField annotations on the methods; if there are some present, then we consider this
+        // a form bean class, even if it's not annotated as such.
+        //
+        Collection< MethodDeclaration > methods = CompilerUtils.getClassMethods( jclass, null );
+        
+        for ( MethodDeclaration method : methods )
         {
-            //
-            // Look for ValidationField annotations on the methods.
-            //
-            Collection< MethodDeclaration > methods = CompilerUtils.getClassMethods( jclass, null );
-            
-            for ( MethodDeclaration method : methods )
-            {
-                isFormBeanClass |=
-                    checkValidationAnnotation( method, VALIDATABLE_PROPERTY_TAG_NAME, validatablePropertyGrammar );
-                // We don't currently support validation rule annotations directly on getter methods.
-                /*
-                hasOne |= checkValidationAnnotation( method, LOCALE_RULES_ATTR, _validationLocaleRulesGrammar );
-                hasOne |= checkValidationAnnotation( method, VALIDATE_REQUIRED_TAG_NAME, _baseValidationRuleGrammar );
-                hasOne |= checkValidationAnnotation( method, VALIDATE_RANGE_TAG_NAME, _validateRangeGrammar );
-                hasOne |= checkValidationAnnotation( method, VALIDATE_MIN_LENGTH_TAG_NAME, _baseValidationRuleGrammar );
-                hasOne |= checkValidationAnnotation( method, VALIDATE_MAX_LENGTH_TAG_NAME, _baseValidationRuleGrammar );
-                hasOne |= checkValidationAnnotation( method, VALIDATE_CREDIT_CARD_TAG_NAME, _baseValidationRuleGrammar );
-                hasOne |= checkValidationAnnotation( method, VALIDATE_EMAIL_TAG_NAME, _baseValidationRuleGrammar );
-                hasOne |= checkValidationAnnotation( method, VALIDATE_MASK_TAG_NAME, _baseValidationRuleGrammar );
-                hasOne |= checkValidationAnnotation( method, VALIDATE_DATE_TAG_NAME, _baseValidationRuleGrammar );
-                hasOne |= checkValidationAnnotation( method, VALIDATE_TYPE_TAG_NAME, _validateTypeGrammar );
-                */
-            }
+            isFormBeanClass |=
+                checkValidationAnnotation( method, VALIDATABLE_PROPERTY_TAG_NAME, validatablePropertyGrammar );
+            // We don't currently support validation rule annotations directly on getter methods.
+            /*
+            hasOne |= checkValidationAnnotation( method, LOCALE_RULES_ATTR, _validationLocaleRulesGrammar );
+            hasOne |= checkValidationAnnotation( method, VALIDATE_REQUIRED_TAG_NAME, _baseValidationRuleGrammar );
+            hasOne |= checkValidationAnnotation( method, VALIDATE_RANGE_TAG_NAME, _validateRangeGrammar );
+            hasOne |= checkValidationAnnotation( method, VALIDATE_MIN_LENGTH_TAG_NAME, _baseValidationRuleGrammar );
+            hasOne |= checkValidationAnnotation( method, VALIDATE_MAX_LENGTH_TAG_NAME, _baseValidationRuleGrammar );
+            hasOne |= checkValidationAnnotation( method, VALIDATE_CREDIT_CARD_TAG_NAME, _baseValidationRuleGrammar );
+            hasOne |= checkValidationAnnotation( method, VALIDATE_EMAIL_TAG_NAME, _baseValidationRuleGrammar );
+            hasOne |= checkValidationAnnotation( method, VALIDATE_MASK_TAG_NAME, _baseValidationRuleGrammar );
+            hasOne |= checkValidationAnnotation( method, VALIDATE_DATE_TAG_NAME, _baseValidationRuleGrammar );
+            hasOne |= checkValidationAnnotation( method, VALIDATE_TYPE_TAG_NAME, _validateTypeGrammar );
+            */
         }
         
         //

Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/MessageKeyType.java
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/MessageKeyType.java	(original)
+++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/MessageKeyType.java	Mon Sep 27 17:05:28 2004
@@ -37,6 +37,10 @@
     public Object onCheck( AnnotationTypeElementDeclaration valueDecl, AnnotationValue member,
                            AnnotationMirror[] parentAnnotations, MemberDeclaration classMember )
     {
+        if ( ( ( String ) member.getValue() ).length() == 0 )
+        {
+            addError( member, "error.empty-string-not-allowed" );
+        }
         // We're not currently supporting generation of validation messages.
         /*
         //