User: rinkrank
  Date: 02/03/25 16:01:18

  Modified:    core/src/xdoclet/doc/info InfoSubTask.java
                        InfoTagsHandler.java
  Log:
  -Added Field and Constructor-level support to info/todo
  -Restructured layout for todo task (with gifs)
  -Added a method to FileManager for writing out binary files from jar resources
  -Some ArrayList -> List refactorings
  
  Revision  Changes    Path
  1.18      +28 -2     xdoclet/core/src/xdoclet/doc/info/InfoSubTask.java
  
  Index: InfoSubTask.java
  ===================================================================
  RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/doc/info/InfoSubTask.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -w -r1.17 -r1.18
  --- InfoSubTask.java  24 Mar 2002 17:44:18 -0000      1.17
  +++ InfoSubTask.java  26 Mar 2002 00:01:18 -0000      1.18
  @@ -10,11 +10,13 @@
   import xdoclet.doc.DocumentDocletTask;
   import xdoclet.util.Log;
   import xdoclet.util.Translator;
  +import xdoclet.util.FileManager;
   import xdoclet.tags.AbstractProgramElementTagsHandler;
   import xdoclet.tags.ClassTagsHandler;
   import xdoclet.tags.PackageTagsHandler;
   
   import java.io.File;
  +import java.io.IOException;
   import java.util.Iterator;
   import java.util.Properties;
   import java.util.SortedSet;
  @@ -28,16 +30,27 @@
    *
    * @author    <a href="mailto:[EMAIL PROTECTED]";>Aslak Helles�y</a>
    * @created   September 18, 2001
  - * @version   $Revision: 1.17 $
  + * @version   $Revision: 1.18 $
  + * @todo This is a test on class level
  + * @todo This is another test on class level
    */
   public class InfoSubTask extends TemplateSubTask
   {
  +     /**
  +      * @todo blabla (this is a test)
  +      */
        public final static String SUBTASK_NAME = "info";
   
  +     /**
  +      * @todo blabla (this is another test)
  +      */
        private final Properties _properties = new Properties();
        private String     _header;
        private String     _projectname;
   
  +     /**
  +      * @todo blabla (this is yet another test)
  +      */
        public InfoSubTask( DocumentDocletTask documentDocletTask )
        {
                // Set default values
  @@ -94,6 +107,19 @@
                        new String[]{_properties.getProperty( "tagName" )} ) );
   
                // first, generate the general stuff on the root.
  +
  +             // copy the static stuff (gifs and stylesheet)
  +             try {
  +                     FileManager.writeURLContent(getClass().getResource( 
"/xdoclet/doc/info/class.gif" ), new File(getDestDir(), "class.gif"));
  +                     FileManager.writeURLContent(getClass().getResource( 
"/xdoclet/doc/info/field.gif" ), new File(getDestDir(), "field.gif"));
  +                     FileManager.writeURLContent(getClass().getResource( 
"/xdoclet/doc/info/constructor.gif" ), new File(getDestDir(), "constructor.gif"));
  +                     FileManager.writeURLContent(getClass().getResource( 
"/xdoclet/doc/info/method.gif" ), new File(getDestDir(), "method.gif"));
  +             } catch( Throwable e ) {
  +                     e.printStackTrace();
  +             }
  +
  +             // Although stylesheet could be copied out with above method, use 
template engine.
  +             // We might want to parameterise colors/fonts with tags
                setTemplateURL( getClass().getResource( "/xdoclet/doc/info/info.css" ) 
);
                setDestinationFile( "info.css" );
                startProcess();
  @@ -137,10 +163,10 @@
                        startProcess();
   
                        classes = AbstractProgramElementTagsHandler.getAllClasses();
  +                     setTemplateURL( getClass().getResource( 
"/xdoclet/doc/info/class-details.j" ) );
                        for( int i = 0; i < classes.length; i++ )
                        {
                                setCurrentClass( classes[i] );
  -                             setTemplateURL( getClass().getResource( 
"/xdoclet/doc/info/class-details.j" ) );
                                setDestinationFile( ClassTagsHandler.getClassNameFor( 
getCurrentClass() ) + "-details.html" );
                                startProcess();
                        }
  
  
  
  1.10      +92 -82    xdoclet/core/src/xdoclet/doc/info/InfoTagsHandler.java
  
  Index: InfoTagsHandler.java
  ===================================================================
  RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/doc/info/InfoTagsHandler.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -w -r1.9 -r1.10
  --- InfoTagsHandler.java      24 Mar 2002 17:44:18 -0000      1.9
  +++ InfoTagsHandler.java      26 Mar 2002 00:01:18 -0000      1.10
  @@ -1,17 +1,21 @@
   package xdoclet.doc.info;
   
  +import xjavadoc.XPackage;
   import xjavadoc.XClass;
  +import xjavadoc.XConstructor;
  +import xjavadoc.XField;
   import xjavadoc.XMethod;
  -import xjavadoc.XPackage;
   import xjavadoc.XTag;
  +import xjavadoc.XProgramElement;
   
   import xdoclet.XDocletException;
   import xdoclet.XDocletTagSupport;
   import xdoclet.tags.AbstractProgramElementTagsHandler;
  -import xdoclet.tags.ClassTagsHandler;
  -import xdoclet.tags.MethodTagsHandler;
   import xdoclet.tags.PackageTagsHandler;
  +import xdoclet.tags.ClassTagsHandler;
   import xdoclet.tags.ConstructorTagsHandler;
  +import xdoclet.tags.MethodTagsHandler;
  +import xdoclet.tags.FieldTagsHandler;
   import xdoclet.template.TemplateException;
   
   import xdoclet.util.Translator;
  @@ -21,75 +25,73 @@
   /**
    * @author    <a href="mailto:[EMAIL PROTECTED]";>Aslak Helles�y</a>
    * @created   Oct 15, 2001
  - * @version   $Revision: 1.9 $
  + * @version   $Revision: 1.10 $
    */
   public class InfoTagsHandler extends XDocletTagSupport
   {
        public void ifTagCountNotZero( String template, Properties properties ) throws 
XDocletException
        {
                String level = properties.getProperty( "level" );
  +             int tagCount = tagCount_Impl( level );
  +             if( tagCount != 0 )
  +             {
  +                     generate( template );
  +             }
  +     }
  +
  +     public String tagCount(Properties properties ) throws XDocletException {
  +             String level = properties.getProperty( "level" );
  +             int tagCount = tagCount_Impl( level );
  +             return String.valueOf(tagCount);
  +     }
  +
  +     private int tagCount_Impl( String level ) throws XDocletException {
                int tagCount = 0;
   
  -             if( "global".equals( level ) )
  +             if( "all".equals( level ) )
                {
  -                     tagCount = tagCountInAllClassesAndMethods_Impl( 
getProperties() );
  +                     tagCount = tagCountInAll_Impl( getProperties() );
                }
                else if( "package".equals( level ) )
                {
  -                     tagCount = tagCountInClassesAndMethodsInAPackage_Impl( 
getProperties(), getCurrentPackage() );
  +                     tagCount = tagCountInPackage_Impl( getProperties(), 
getCurrentPackage() );
                }
  -             else if( "classNoMethods".equals( level ) )
  +             else if( "whole-class".equals( level ) )
                {
  -                     tagCount = tagCountInClass_Impl( getProperties(), 
getCurrentClass(), false );
  +                     tagCount = tagCountInClass_Impl( getProperties(), 
getCurrentClass(), true, true, true, true );
                }
                else if( "class".equals( level ) )
                {
  -                     tagCount = tagCountInClass_Impl( getProperties(), 
getCurrentClass(), true );
  +                     tagCount = tagCountInClass_Impl( getProperties(), 
getCurrentClass(), true, false, false, false );
                }
  -             else if( "method".equals( level ) )
  +             else if( "field".equals( level ) )
                {
  -                     int a = tagCountInClass_Impl( getProperties(), 
getCurrentClass(), true );
  -                     int b = tagCountInClass_Impl( getProperties(), 
getCurrentClass(), false );
  -
  -                     tagCount = a - b;
  +                     tagCount = tagCountInClass_Impl( getProperties(), 
getCurrentClass(), false, true, false, false );
                }
                else if( "constructor".equals( level ) )
                {
  -                     int a = tagCountInClass_Impl( getProperties(), 
getCurrentClass(), true );
  -                     int b = tagCountInClass_Impl( getProperties(), 
getCurrentClass(), false );
  -
  -                     tagCount = a - b;
  +                     tagCount = tagCountInClass_Impl( getProperties(), 
getCurrentClass(), false, false, true, false );
  +             }
  +             else if( "method".equals( level ) )
  +             {
  +                     tagCount = tagCountInClass_Impl( getProperties(), 
getCurrentClass(), false, false, false, true );
                }
                else
                {
                        throw new XDocletException( Translator.getString( 
"xdoclet.doc.Messages",
                                "bad_level", new String[]{level} ) );
                }
  -
  -             if( tagCount != 0 )
  -             {
  -                     generate( template );
  -             }
  -     }
  -
  -     public String tagCountInAllClassesAndMethods() throws XDocletException
  -     {
  -             return String.valueOf( tagCountInAllClassesAndMethods_Impl( 
getProperties() ) );
  -     }
  -
  -     public String tagCountInClassesAndMethodsInAPackage() throws XDocletException
  -     {
  -             return String.valueOf( tagCountInClassesAndMethodsInAPackage_Impl( 
getProperties(), getCurrentPackage() ) );
  +             return tagCount;
        }
   
  -     public String tagCountInClass() throws XDocletException
  +     public String classTagValue() throws XDocletException
        {
  -             return String.valueOf( tagCountInClass_Impl( getProperties(), 
getCurrentClass(), true ) );
  +             return getClassTagsHandler().classTagValue( getProperties() );
        }
   
  -     public String methodTagValue() throws XDocletException
  +     public String fieldTagValue() throws XDocletException
        {
  -             return getMethodTagsHandler().methodTagValue( getProperties() );
  +             return getFieldTagsHandler().fieldTagValue( getProperties() );
        }
   
        public String constructorTagValue() throws XDocletException
  @@ -97,14 +99,9 @@
                return getConstructorTagsHandler().constructorTagValue( 
getProperties() );
        }
   
  -     public String classTagValue() throws XDocletException
  -     {
  -             return getClassTagsHandler().classTagValue( getProperties() );
  -     }
  -
  -     public void forAllMethodTags( String template ) throws XDocletException
  +     public String methodTagValue() throws XDocletException
        {
  -             getMethodTagsHandler().forAllMethodTags( template, getProperties() );
  +             return getMethodTagsHandler().methodTagValue( getProperties() );
        }
   
        public void forAllClassTags( String template ) throws XDocletException
  @@ -112,24 +109,19 @@
                getClassTagsHandler().forAllClassTags( template, getProperties() );
        }
   
  -     public void forAllMethods( String template ) throws XDocletException
  -     {
  -             getMethodTagsHandler().forAllMethods( template, getProperties() );
  -     }
  -
  -     public void forAllClasses( String template ) throws XDocletException
  +     public void forAllConstructorTags( String template ) throws XDocletException
        {
  -             getClassTagsHandler().forAllClasses( template, getProperties() );
  +             getConstructorTagsHandler().forAllConstructorTags( template, 
getProperties() );
        }
   
  -     public void forAllPackages( String template ) throws XDocletException
  +     public void forAllMethodTags( String template ) throws XDocletException
        {
  -             getPackageTagsHandler().forAllPackages( template, getProperties() );
  +             getMethodTagsHandler().forAllMethodTags( template, getProperties() );
        }
   
  -     public void ifHasMethodTag( String template ) throws XDocletException
  +     public void forAllFieldTags( String template ) throws XDocletException
        {
  -             getMethodTagsHandler().ifHasMethodTag( template, getProperties() );
  +             getFieldTagsHandler().forAllFieldTags( template, getProperties() );
        }
   
        public String projectname() throws XDocletException
  @@ -139,7 +131,7 @@
                return infoSubTask.getProjectname();
        }
   
  -     public String stylesheetlink() throws XDocletException
  +     public String rootlink() throws XDocletException
        {
                String packageName = "";
   
  @@ -156,7 +148,6 @@
                {
                        sb.append( "../" );
                }
  -             sb.append( "info.css" );
                return sb.toString();
        }
   
  @@ -180,6 +171,19 @@
                }
        }
   
  +     private FieldTagsHandler getFieldTagsHandler() throws XDocletException
  +     {
  +             try
  +             {
  +                     return ( ( FieldTagsHandler ) getEngine().getTagHandlerFor( 
"Field" ) );
  +             }
  +             catch( TemplateException ex )
  +             {
  +                     throw new XDocletException( ex, Translator.getString( 
"xdoclet.doc.Messages",
  +                             "tagshandler_not_found", new 
String[]{"FieldTagsHandler", "Field"} ) );
  +             }
  +     }
  +
        private ConstructorTagsHandler getConstructorTagsHandler() throws 
XDocletException
        {
                try
  @@ -219,7 +223,7 @@
                }
        }
   
  -     private int tagCountInAllClassesAndMethods_Impl( Properties attributes ) 
throws XDocletException
  +     private int tagCountInAll_Impl( Properties attributes ) throws XDocletException
        {
                int tagCount = 0;
                String tag_name = attributes.getProperty( "tagName" );
  @@ -237,54 +241,60 @@
                for( Iterator packageIterator = packages.iterator(); 
packageIterator.hasNext();  )
                {
                        cur_package = ( XPackage ) packageIterator.next();
  -                     tagCount += tagCountInClassesAndMethodsInAPackage_Impl( 
attributes, cur_package );
  +                     tagCount += tagCountInPackage_Impl( attributes, cur_package );
                }
   
                return tagCount;
        }
   
  -     private int tagCountInClassesAndMethodsInAPackage_Impl( Properties attributes, 
XPackage pakkage ) throws XDocletException
  +     private int tagCountInPackage_Impl( Properties attributes, XPackage pakkage ) 
throws XDocletException
        {
                int tagCount = 0;
                String tag_name = attributes.getProperty( "tagName" );
  -
                XClass[] classes = pakkage.classes();
  -
                for( int i = 0; i < classes.length; i++ )
                {
  -                     tagCount += tagCountInClass_Impl( attributes, classes[i], true 
);
  +                     tagCount += tagCountInClass_Impl( attributes, classes[i], 
true, true, true, true );
                }
  -
                return tagCount;
        }
   
  -     private int tagCountInClass_Impl( Properties attributes, XClass clazz, boolean 
countMethods ) throws XDocletException
  +     private int tagCountInClass_Impl( Properties attributes, XClass clazz, boolean 
countClass, boolean countFields, boolean countConstructors, boolean countMethods ) 
throws XDocletException
        {
                int tagCount = 0;
  -             String tag_name = attributes.getProperty( "tagName" );
  -
  -             XTag[] classTags = clazz.doc().tags( tag_name, false );
  +             String tagName = attributes.getProperty( "tagName" );
   
  -             if( classTags != null )
  +             if( countClass )
                {
  -                     tagCount += classTags.length;
  +                     tagCount += tagCount( clazz, tagName );
  +             }
  +             if( countConstructors )
  +             {
  +                     XConstructor[] constructors = clazz.constructors();
  +                     tagCount += tagCount( constructors, tagName );
                }
  -
                if( countMethods )
                {
                        XMethod[] methods = clazz.methods();
  -
  -                     for( int i = 0; i < methods.length; i++ )
  -                     {
  -                             XTag[] methodTags = methods[i].doc().tags( tag_name );
  -
  -                             if( methodTags != null )
  -                             {
  -                                     tagCount += methodTags.length;
  -                             }
  +                     tagCount += tagCount( methods, tagName );
                        }
  +             if( countFields )
  +             {
  +                     XField[] fields = clazz.fields();
  +                     tagCount += tagCount( fields, tagName );
                }
                return tagCount;
        }
   
  +     private int tagCount( XProgramElement programElement, String tagName ) {
  +             int count = programElement.doc().tags( tagName, false ).length;
  +             return count;
  +     }
  +     private int tagCount( XProgramElement[] programElements, String tagName ) {
  +             int count = 0;
  +             for( int i = 0; i < programElements.length; i++ ) {
  +                     count += tagCount( programElements[i], tagName );
  +             }
  +             return count;
  +     }
   }
  
  
  

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

Reply via email to