Update of 
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-qtags/src/test/java/org/xdoclet/plugin/qtags/impl/test
In directory 
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30108/plugin-qtags/src/test/java/org/xdoclet/plugin/qtags/impl/test

Modified Files:
        FooBarTag.java FooBarTagImpl.java 
Log Message:
Support to QTags to return array types: 
Tag values will be running through a StringTokenizer.
Each array value will be validated through if used it @qtags.allowed-value.
The StringTokenizer delimiter is by default "," but can also be ";" - This can 
be set using @qtags.list-token.
Note: Before @qtags.default was not being verified against a valid value set by 
@qtags.allowed-value.
Current generated tag impl changed this - The default value is set before 
values validation.



Index: FooBarTagImpl.java
===================================================================
RCS file: 
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-qtags/src/test/java/org/xdoclet/plugin/qtags/impl/test/FooBarTagImpl.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** FooBarTagImpl.java  31 May 2005 11:28:59 -0000      1.17
--- FooBarTagImpl.java  21 Aug 2005 13:44:29 -0000      1.18
***************
*** 8,16 ****
  public class FooBarTagImpl extends org.xdoclet.XDocletTag implements 
org.xdoclet.plugin.qtags.impl.test.FooBarTag {
      public static final String NAME = "foo.bar";
!     private static final java.util.List ALLOWED_PARAMETERS = 
java.util.Arrays.asList(new String[] {"age", "apple", "funny", "grape-fruit", 
""});
!     private static final java.util.List ALLOWED_VALUES = 
java.util.Arrays.asList(new String[] {""});
! 
!     public FooBarTagImpl(String name, String value, 
com.thoughtworks.qdox.model.AbstractJavaEntity entity,
!         int lineNumber) {
          super(name, value, entity, lineNumber);
      }
--- 8,27 ----
  public class FooBarTagImpl extends org.xdoclet.XDocletTag implements 
org.xdoclet.plugin.qtags.impl.test.FooBarTag {
      public static final String NAME = "foo.bar";
!     private static final java.util.List ALLOWED_PARAMETERS = 
java.util.Arrays.asList( new String[] {
!         "age",
!         "age-list",
!         "apple",
!         "apple-list",
!         "funny",
!         "funny-list",
!         "grape-fruit",
!         "grape-fruit-list",
!         ""
!     });
!     
!     private static final java.util.List ALLOWED_VALUES = 
java.util.Arrays.asList( new String[] {
!         ""
!     });
!     public FooBarTagImpl(String name, String value, 
com.thoughtworks.qdox.model.AbstractJavaEntity entity, int lineNumber) {
          super(name, value, entity, lineNumber);
      }
***************
*** 19,121 ****
          boolean required = false;
          String result = getNamedParameter("age");
! 
!         if (required && result == null) {
              bomb("age=\"???\" must be specified.");
          }
  
          if (result != null) {
!             try {
!                 return Integer.decode(result).intValue();
!             } catch (NumberFormatException nfe) {
!                 bomb("age=\"" + result + "\" is not valid integer");
!                 throw nfe;
!             }
!         } else {
!             return 0;
          }
      }
  
      public java.lang.String getApple() {
          boolean required = false;
          String result = getNamedParameter("apple");
! 
!         if (required && result == null) {
              bomb("apple=\"???\" must be specified.");
          }
  
          if (result != null) {
!             if (!(false || result.equals("red") || result.equals("green"))) {
!                 // todo we should say what file and line number too
!                 bomb("apple=\"" + result + "\" is an invalid parameter 
value.");
!             }
          }
  
!         if (result == null) {
              result = "green";
          }
  
!         return result;
!     }
  
      public boolean isFunny() {
          boolean required = false;
          String result = getNamedParameter("funny");
! 
!         if (required && result == null) {
              bomb("funny=\"???\" must be specified.");
          }
  
!         if (result == null) {
              result = "true";
          }
  
!         return Boolean.valueOf(result).booleanValue();
      }
  
      public java.lang.String getGrapeFruit() {
          boolean required = true;
          String result = getNamedParameter("grape-fruit");
! 
!         if (required && result == null) {
              bomb("grape-fruit=\"???\" must be specified.");
          }
  
!         return result;
      }
  
      protected void validateLocation() {
!         if (isOnClass) {
              bomb("is not allowed on classes");
          }
! 
!         if (isOnField) {
              bomb("is not allowed on fields");
          }
! 
          // check uniqueness
-         // warn deprecation
-         System.err.println("@" + getName() + ":" + getValue());
  
          // check for allowed values for whole tag
!         if (ALLOWED_VALUES.size() > 1 && 
!ALLOWED_VALUES.contains(getValue())) {
!             bomb("\"" + getValue() + "\" is not a valid value. Allowed values 
are ");
!         }
! 
          // Verify that all parameters are known.
          final java.util.Collection parameterNames = 
getNamedParameterMap().keySet();
- 
          for (java.util.Iterator iterator = parameterNames.iterator(); 
iterator.hasNext();) {
              String parameterName = (String) iterator.next();
- 
              if (!ALLOWED_PARAMETERS.contains(parameterName)) {
                  bomb(parameterName + " is an invalid parameter name.");
              }
          }
! 
          // Get all the parameters to validate their contents
          getAge();
          getApple();
          isFunny();
          getGrapeFruit();
      }
  }
\ No newline at end of file
--- 30,268 ----
          boolean required = false;
          String result = getNamedParameter("age");
!         if(required && result == null) {
              bomb("age=\"???\" must be specified.");
          }
  
+         int retVal = 0;
+ 
+ 
          if (result != null) {
! 
!             
!                 try {
!                     retVal = Integer.decode(result).intValue();
!                 } catch(NumberFormatException nfe) {
!                     bomb("age=\"" + result + "\" is not valid integer");
!                     throw nfe;
!                 }
          }
+         
+         return retVal;
      }
+     public int[] getAgeList() {
+         boolean required = false;
+         String result = getNamedParameter("age-list");
+         if(required && result == null) {
+             bomb("age-list=\"???\" must be specified.");
+         }
+ 
+         int[] retVal = null;
+ 
+ 
+         if (result != null) {
+             java.util.StringTokenizer strTok = new 
java.util.StringTokenizer(result, ",");
+             retVal = new int[strTok.countTokens()];
+             int idx = 0;
+             String token;
  
+             
+             while (strTok.hasMoreTokens()) {
+                 token = strTok.nextToken(); 
+                 try {
+                     retVal[idx++] = Integer.decode(token).intValue();
+                 } catch(NumberFormatException nfe) {
+                     bomb("age-list=\"" + token + "\" is not valid integer");
+                     throw nfe;
+                 }
+             }
+         }
+         
+         return retVal;
+     }
      public java.lang.String getApple() {
          boolean required = false;
          String result = getNamedParameter("apple");
!         if(required && result == null) {
              bomb("apple=\"???\" must be specified.");
          }
  
+         java.lang.String retVal = null;
+ 
+         if(result == null) {
+             result = "green";
+         }
+ 
          if (result != null) {
! 
!             
!                 if( !(false || result.equals("red")|| result.equals("green")) 
) {
!                     // todo we should say what file and line number too
!                     bomb("apple=\"" + result + "\" is an invalid parameter 
value.");
!                 }
!                 retVal = result;
!         }
!         
!         return retVal;
!     }
!     public java.lang.String[] getAppleList() {
!         boolean required = false;
!         String result = getNamedParameter("apple-list");
!         if(required && result == null) {
!             bomb("apple-list=\"???\" must be specified.");
          }
  
!         java.lang.String[] retVal = null;
! 
!         if(result == null) {
              result = "green";
          }
  
!         if (result != null) {
!             java.util.StringTokenizer strTok = new 
java.util.StringTokenizer(result, ",");
!             retVal = new java.lang.String[strTok.countTokens()];
!             int idx = 0;
!             String token;
  
+             
+             while (strTok.hasMoreTokens()) {
+                 token = strTok.nextToken(); 
+                 if( !(false || token.equals("red")|| token.equals("green")) ) 
{
+                     // todo we should say what file and line number too
+                     bomb("apple-list=\"" + token + "\" is an invalid 
parameter value.");
+                 }
+                 retVal[idx++] = token;
+             }
+         }
+         
+         return retVal;
+     }
      public boolean isFunny() {
          boolean required = false;
          String result = getNamedParameter("funny");
!         if(required && result == null) {
              bomb("funny=\"???\" must be specified.");
          }
  
!         boolean retVal = false;
! 
!         if(result == null) {
              result = "true";
          }
  
!         if (result != null) {
! 
!             
!                 retVal = Boolean.valueOf(result).booleanValue();
!         }
!         
!         return retVal;
      }
+     public boolean[] isFunnyList() {
+         boolean required = false;
+         String result = getNamedParameter("funny-list");
+         if(required && result == null) {
+             bomb("funny-list=\"???\" must be specified.");
+         }
  
+         boolean[] retVal = null;
+ 
+         if(result == null) {
+             result = "true";
+         }
+ 
+         if (result != null) {
+             java.util.StringTokenizer strTok = new 
java.util.StringTokenizer(result, ";");
+             retVal = new boolean[strTok.countTokens()];
+             int idx = 0;
+             String token;
+ 
+             
+             while (strTok.hasMoreTokens()) {
+                 token = strTok.nextToken(); 
+                 retVal[idx++] = Boolean.valueOf(token).booleanValue();
+             }
+         }
+         
+         return retVal;
+     }
      public java.lang.String getGrapeFruit() {
          boolean required = true;
          String result = getNamedParameter("grape-fruit");
!         if(required && result == null) {
              bomb("grape-fruit=\"???\" must be specified.");
          }
  
!         java.lang.String retVal = null;
! 
! 
!         if (result != null) {
! 
!             
!                 retVal = result;
!         }
!         
!         return retVal;
!     }
!     public java.lang.String[] getGrapeFruitList() {
!         boolean required = true;
!         String result = getNamedParameter("grape-fruit-list");
!         if(required && result == null) {
!             bomb("grape-fruit-list=\"???\" must be specified.");
!         }
! 
!         java.lang.String[] retVal = null;
! 
! 
!         if (result != null) {
!             java.util.StringTokenizer strTok = new 
java.util.StringTokenizer(result, ",");
!             retVal = new java.lang.String[strTok.countTokens()];
!             int idx = 0;
!             String token;
! 
!             
!             while (strTok.hasMoreTokens()) {
!                 token = strTok.nextToken(); 
!                 retVal[idx++] = token;
!             }
!         }
!         
!         return retVal;
      }
  
      protected void validateLocation() {
!         if(isOnClass) {
              bomb("is not allowed on classes");
          }
!         if(isOnField) {
              bomb("is not allowed on fields");
          }
!         
          // check uniqueness
  
+         // warn deprecation
+         System.err.println("@" + getName() + ":"  + getValue());
+         
          // check for allowed values for whole tag
!         if( ALLOWED_VALUES.size() > 1 && 
!ALLOWED_VALUES.contains(getValue())) {
!             bomb( "\"" + getValue() +"\" is not a valid value. Allowed values 
are ");
!         }        
          // Verify that all parameters are known.
          final java.util.Collection parameterNames = 
getNamedParameterMap().keySet();
          for (java.util.Iterator iterator = parameterNames.iterator(); 
iterator.hasNext();) {
              String parameterName = (String) iterator.next();
              if (!ALLOWED_PARAMETERS.contains(parameterName)) {
                  bomb(parameterName + " is an invalid parameter name.");
              }
          }
!         
          // Get all the parameters to validate their contents
          getAge();
+         getAgeList();
          getApple();
+         getAppleList();
          isFunny();
+         isFunnyList();
          getGrapeFruit();
+         getGrapeFruitList();
      }
  }
\ No newline at end of file

Index: FooBarTag.java
===================================================================
RCS file: 
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-qtags/src/test/java/org/xdoclet/plugin/qtags/impl/test/FooBarTag.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** FooBarTag.java      31 May 2005 11:28:59 -0000      1.9
--- FooBarTag.java      21 Aug 2005 13:44:29 -0000      1.10
***************
*** 21,24 ****
--- 21,25 ----
  public interface FooBarTag extends DocletTag {
      int getAge();
+     int[] getAgeList();
  
      /**
***************
*** 30,33 ****
--- 31,44 ----
       */
      String getApple();
+     
+     /**
+      * Bla bla
+      *
+      * @qtags.allowed-value red
+      * @qtags.allowed-value green
+      * @qtags.default green
+      * @qtags.list-token
+      */
+     String[] getAppleList();
  
      /**
***************
*** 37,40 ****
--- 48,59 ----
       */
      boolean isFunny();
+     
+     /**
+      * Hip hop
+      *
+      * @qtags.default true
+      * @qtags.list-token semicolon
+      */
+     boolean[] isFunnyList();
  
      /**
***************
*** 44,46 ****
--- 63,73 ----
       */
      String getGrapeFruit();
+     
+     /**
+      * Ping pong
+      *
+      * @qtags.required
+      * @qtags.list-token comma
+      */
+     String[] getGrapeFruitList();
  }
\ No newline at end of file



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
xdoclet-plugins-commits mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-plugins-commits

Reply via email to