User: rinkrank
  Date: 02/03/16 10:22:13

  Modified:    core/src/xdoclet/util Tag: XJAVADOC_REFACTORING
                        DocletUtil.java
  Log:
  xjavadoc refactoring. doesn't work yet, but it compiles
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.14.2.1  +2 -197    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.14
  retrieving revision 1.14.2.1
  diff -u -w -r1.14 -r1.14.2.1
  --- DocletUtil.java   9 Mar 2002 23:41:54 -0000       1.14
  +++ DocletUtil.java   16 Mar 2002 18:22:12 -0000      1.14.2.1
  @@ -1,204 +1,16 @@
   package xdoclet.util;
   
  -import com.sun.javadoc.*;
  -
  -import org.apache.log4j.Category;
  -
   import xdoclet.XDocletException;
  -import xdoclet.template.PrettyPrintWriter;
  -
  -import java.util.List;
  -import java.util.ArrayList;
  -import java.util.Arrays;
   import java.util.StringTokenizer;
   
   /**
    * @author    Ara Abrahamian ([EMAIL PROTECTED])
  + * @author    <a href="[EMAIL PROTECTED]">Aslak Helles�y</a>
    * @created   July 14, 2001
  - * @version   $Revision: 1.14 $
  + * @version   $Revision: 1.14.2.1 $
    */
   public final class DocletUtil
   {
  -     public static String getText( Doc doc, String tagName ) throws XDocletException
  -     {
  -             return getText( doc, tagName, true );
  -     }
  -
  -     /**
  -      * Returns the entire body (parameters etc) of a tag within a supplied Doc
  -      * context as text.
  -      *
  -      * @param doc                   The Doc subclass (ClassDoc, MethodDoc,
  -      *      ConstructorDoc or FieldDoc) to search for the tag.
  -      * @param tagName               The name of the tag. Can be in namespace:tag or
  -      *      namespace.tag format.
  -      * @param superclasses          Whether superclass definitions should also be
  -      *      searched.
  -      * @return                      The tag body
  -      * @exception XDocletException
  -      */
  -     public static String getText( Doc doc, String tagName, boolean superclasses ) 
throws XDocletException
  -     {
  -             Tag[] tags = null;
  -
  -             if( doc instanceof ClassDoc )
  -             {
  -                     tags = getTagsByName( ( ClassDoc ) doc, tagName, superclasses 
);
  -             }
  -             else if( doc instanceof MethodDoc )
  -             {
  -                     tags = getTagsByName( ( MethodDoc ) doc, tagName );
  -             }
  -             else if( doc instanceof ConstructorDoc )
  -             {
  -                     tags = getTagsByName( ( ConstructorDoc ) doc, tagName );
  -             }
  -             else if( doc instanceof FieldDoc )
  -             {
  -                     tags = getTagsByName( ( FieldDoc ) doc, tagName );
  -             }
  -             else
  -             {
  -                     throw new IllegalArgumentException( Translator.getString( 
"bad_gettext_doc_type",
  -                             new String[]{doc.toString()} ) );
  -             }
  -
  -             if( tags != null && tags.length > 0 )
  -             {
  -                     return getText( tags[0] );
  -             }
  -             else
  -             {
  -                     return null;
  -             }
  -     }
  -
  -     public static String getText( Tag tag )
  -     {
  -             String text = tag.text().trim();
  -
  -             // To make tags separated in different lines work
  -
  -             text = text.replace( ( char ) 10, ' ' );
  -             return text.replace( ( char ) 13, ' ' );
  -     }
  -
  -     public static Tag[] getTagsByName( ClassDoc clazz, String tag_name )
  -     {
  -             return getTagsByName( clazz, tag_name, true );
  -     }
  -
  -     public static Tag[] getTagsByName( ClassDoc clazz, String tag_name, boolean 
superclasses )
  -     {
  -             Category cat = Log.getCategory( DocletUtil.class, "getTagsByName" );
  -
  -             if( cat.isDebugEnabled() )
  -             {
  -                     cat.debug( "Search for " + tag_name + " in " + clazz + " (look 
in superclasses=" + superclasses + ")" );
  -             }
  -
  -             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() )
  -             {
  -                     cat.debug( tags.length + " Tags Found" );
  -             }
  -
  -             if( superclasses == true )
  -             {
  -                     List tags_list = new ArrayList( Arrays.asList( tags ) );
  -                     boolean found = false;
  -
  -                     clazz = clazz.superclass();
  -                     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++ )
  -                             {
  -                                     // Do not add redundant tags (a tag defined 
exactly in base and
  -                                     // child). I have to do it manually because 
equals() is not
  -                                     // defined by javadoc's TagImpl!
  -
  -                                     found = false;
  -                                     for( int j = 0; j < tags_list.size(); j++ )
  -                                     {
  -                                             if( tags_list.get( j 
).toString().equals( tags[i].toString() ) )
  -                                             {
  -                                                     found = true;
  -                                                     break;
  -                                             }
  -                                     }
  -
  -                                     if( !found )
  -                                     {
  -                                             tags_list.add( tags[i] );
  -                                     }
  -                             }
  -
  -                             clazz = clazz.superclass();
  -                     }
  -
  -                     return ( Tag[] ) tags_list.toArray( new Tag[0] );
  -             }
  -             else
  -             {
  -                     return tags;
  -             }
  -     }
  -
  -     public static Tag[] getTagsByName( 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;
  -     }
  -
  -     public static boolean hasTag( Doc doc, String tag )
  -     {
  -             return hasTag( doc, tag, true );
  -     }
  -
  -     public static boolean hasTag( Doc doc, String tag_name, boolean superclasses )
  -     {
  -             if( docHasTag( doc, tag_name ) )
  -             {
  -                     return true;
  -             }
  -             else
  -             {
  -                     if( superclasses == true )
  -                     {
  -                             while( doc != null && doc instanceof ClassDoc )
  -                             {
  -                                     doc = ( ( ClassDoc ) doc ).superclass();
  -
  -                                     if( doc != null && docHasTag( doc, tag_name ) )
  -                                     {
  -                                             return true;
  -                                     }
  -                             }
  -                     }
  -
  -                     return false;
  -             }
  -     }
   
        /**
         * Return an array of String from a String containing delimited values. For
  @@ -219,12 +31,5 @@
                        ret[i++] = st.nextToken();
                }
                return ret;
  -     }
  -
  -     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