User: ara_e_w 
  Date: 02/02/28 12:22:48

  Modified:    core/src/xdoclet/util DocletUtil.java
  Log:
  sad but true: other than the @namespace:tag we have to support @namespace.tag 
notation too because of JDK1.4's strictness with unknown @tags
  I made all neccessary changes (mini changes alctually, and changed CustomerBMPBean 
for test).
  
  PLEASE DON'T USE Doc.tags() methods directly, use DocletUtil.getTagsByName.
  
  Revision  Changes    Path
  1.12      +47 -13    xdoclet/core/src/xdoclet/util/DocletUtil.java
  
  Index: DocletUtil.java
  ===================================================================
  RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/util/DocletUtil.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -w -r1.11 -r1.12
  --- DocletUtil.java   4 Feb 2002 23:55:55 -0000       1.11
  +++ DocletUtil.java   28 Feb 2002 20:22:48 -0000      1.12
  @@ -1,11 +1,6 @@
   package xdoclet.util;
   
  -import com.sun.javadoc.ClassDoc;
  -import com.sun.javadoc.Doc;
  -import com.sun.javadoc.FieldDoc;
  -import com.sun.javadoc.MethodDoc;
  -import com.sun.javadoc.ConstructorDoc;
  -import com.sun.javadoc.Tag;
  +import com.sun.javadoc.*;
   
   import org.apache.log4j.Category;
   
  @@ -20,7 +15,7 @@
   /**
    * @author    Ara Abrahamian ([EMAIL PROTECTED])
    * @created   July 14, 2001
  - * @version   $Revision: 1.11 $
  + * @version   $Revision: 1.12 $
    */
   public final class DocletUtil
   {
  @@ -29,6 +24,15 @@
                return getText( doc, tagName, true );
        }
   
  +     /**
  +      * TagName can be in namespace:tag or namespace.tag format
  +      *
  +      * @param doc
  +      * @param tagName
  +      * @param superclasses
  +      * @return
  +      * @exception XDocletException
  +      */
        public static String getText( Doc doc, String tagName, boolean superclasses ) 
throws XDocletException
        {
                Tag[] tags = null;
  @@ -77,17 +81,17 @@
   
        public static Tag[] getTagsByName( FieldDoc field, String tag_name )
        {
  -             return field.tags( tag_name );
  +             return getTagsByNameForMemberDoc( field, tag_name );
        }
   
        public static Tag[] getTagsByName( MethodDoc method, String tag_name )
        {
  -             return method.tags( tag_name );
  +             return getTagsByNameForMemberDoc( method, tag_name );
        }
   
        public static Tag[] getTagsByName( ConstructorDoc constructor, String tag_name 
)
        {
  -             return constructor.tags( tag_name );
  +             return getTagsByNameForMemberDoc( constructor, tag_name );
        }
   
        public static Tag[] getTagsByName( ClassDoc clazz, String tag_name )
  @@ -105,6 +109,11 @@
                }
   
                Tag[] tags = clazz.tags( tag_name );
  +             String dotted_format_tag_name = tag_name.replace( ':', '.' );
  +
  +             //try the namespace.tag format
  +             if( tags.length == 0 )
  +                     tags = clazz.tags( dotted_format_tag_name );
   
                if( cat.isDebugEnabled() )
                {
  @@ -120,6 +129,9 @@
                        while( clazz != null )
                        {
                                tags = clazz.tags( tag_name );
  +                             //if not found maybe it's in namespace.tag format
  +                             if( tags.length == 0 )
  +                                     tags = clazz.tags( dotted_format_tag_name );
   
                                for( int i = 0; i < tags.length; i++ )
                                {
  @@ -159,9 +171,9 @@
                return hasTag( doc, tag, true );
        }
   
  -     public static boolean hasTag( Doc doc, String tag, boolean superclasses )
  +     public static boolean hasTag( Doc doc, String tag_name, boolean superclasses )
        {
  -             if( doc.tags( tag ).length > 0 )
  +             if( docHasTag( doc, tag_name ) )
                {
                        return true;
                }
  @@ -173,7 +185,7 @@
                                {
                                        doc = ( ( ClassDoc ) doc ).superclass();
   
  -                                     if( doc != null && doc.tags( tag ).length > 0 )
  +                                     if( doc != null && docHasTag( doc, tag_name ) )
                                        {
                                                return true;
                                        }
  @@ -203,5 +215,27 @@
                        ret[i++] = st.nextToken();
                }
                return ret;
  +     }
  +
  +     private static Tag[] getTagsByNameForMemberDoc( MemberDoc doc, String tag_name 
)
  +     {
  +             Tag[] result = doc.tags( tag_name );
  +
  +             //try the namespace.tag format
  +             if( result.length == 0 )
  +             {
  +                     String dotted_format_tag_name = tag_name.replace( ':', '.' );
  +
  +                     result = doc.tags( dotted_format_tag_name );
  +             }
  +
  +             return result;
  +     }
  +
  +     private static boolean docHasTag( Doc doc, String tag_name )
  +     {
  +             String dotted_format_tag_name = tag_name.replace( ':', '.' );
  +
  +             return doc.tags( tag_name ).length > 0 || doc.tags( 
dotted_format_tag_name ).length > 0;
        }
   }
  
  
  

_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Reply via email to