User: ara_e_w 
  Date: 02/03/04 13:32:41

  Modified:    core/src/xdoclet/tags ClassTagsHandler.java
                        PackageTagsHandler.java
  Log:
  - <pakageSubstitution/> is now available to TemplateSubTasks
  - added an option to turn of the timestamp/etc guessing of merge point/etc of a 
template
  - you can set subtaskname now (pretty cool if you want to fool xdoclet!)
  
  Revision  Changes    Path
  1.22      +5 -15     xdoclet/core/src/xdoclet/tags/ClassTagsHandler.java
  
  Index: ClassTagsHandler.java
  ===================================================================
  RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/tags/ClassTagsHandler.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -w -r1.21 -r1.22
  --- ClassTagsHandler.java     28 Feb 2002 20:22:47 -0000      1.21
  +++ ClassTagsHandler.java     4 Mar 2002 21:32:41 -0000       1.22
  @@ -7,7 +7,6 @@
   import xdoclet.DocletSupport;
   import xdoclet.DocletTask;
   import xdoclet.XDocletException;
  -import xdoclet.XDocletTagSupport;
   import xdoclet.template.PrettyPrintWriter;
   import xdoclet.template.TemplateException;
   import xdoclet.util.DocletUtil;
  @@ -21,7 +20,7 @@
   /**
    * @author    Ara Abrahamian ([EMAIL PROTECTED])
    * @created   Oct 14, 2001
  - * @version   $Revision: 1.21 $
  + * @version   $Revision: 1.22 $
    */
   public class ClassTagsHandler extends AbstractProgramElementTagsHandler
   {
  @@ -58,11 +57,6 @@
                return clazz.qualifiedName();
        }
   
  -     private static String fromInterfaceToBean( String value )
  -     {
  -             return value;
  -     }
  -
        /**
         * Returns the not-full-qualified name of the current class without the package
         * name.
  @@ -184,8 +178,6 @@
                        }
                }
   
  -             value = fromInterfaceToBean( value );
  -
                cur_class = getContext().getRoot().classNamed( value );
   
                if( cur_class == null )
  @@ -558,16 +550,15 @@
        public void forAllClassTagTokens( String template, Properties attributes ) 
throws XDocletException
        {
                Category cat = Log.getCategory( ClassTagsHandler.class, 
"forAllClassTagTokens" );
  -             boolean superclasses = TypeConversionUtil.stringToBoolean( 
attributes.getProperty( "superclasses" ), true );
                // get class tag value to iterate over
                String tagValue = getTagValue( attributes, FOR_CLASS );
                String delimiter = attributes.getProperty( "delimiter" );
  -             String s = attributes.getProperty( "skip" );
  +             String skip_str = attributes.getProperty( "skip" );
                int skip;
   
                try
                {
  -                     skip = Integer.valueOf( attributes.getProperty( "skip" ) 
).intValue();
  +                     skip = Integer.valueOf( skip_str ).intValue();
                }
                catch( Throwable t )
                {
  @@ -628,7 +619,6 @@
                        return getCurrentClass().commentText();
   
                char[] spaces = getIndentChars( attributes );
  -             Tag[] class_tags = getCurrentClass().tags();
                StringBuffer result = new StringBuffer();
   
                result.append( spaces ).append( "/**" ).append( 
PrettyPrintWriter.LINE_SEPARATOR );
  @@ -759,7 +749,7 @@
                        throw new XDocletException( Translator.getString( 
"tag_must_include_a_property",
                                new String[]{"importList", "currentClass"} ) );
   
  -             String currentPackage = PackageTagsHandler.getPackageFor( currentClass 
);
  +             String currentPackage = PackageTagsHandler.getPackageNameFor( 
currentClass );
   
                StringBuffer st = new StringBuffer();
                PackageDoc[] packages = getCurrentClass().importedPackages();
  @@ -772,7 +762,7 @@
                }
                for( int i = 0; i < classes.length; i++ )
                {
  -                     if( !PackageTagsHandler.getPackageFor( classes[i].toString() 
).equals( currentPackage ) )
  +                     if( !PackageTagsHandler.getPackageNameFor( 
classes[i].toString() ).equals( currentPackage ) )
                                st.append( "import " ).append( classes[i].toString() 
).append( ";" ).append( PrettyPrintWriter.LINE_SEPARATOR );
                }
   
  
  
  
  1.7       +76 -23    xdoclet/core/src/xdoclet/tags/PackageTagsHandler.java
  
  Index: PackageTagsHandler.java
  ===================================================================
  RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/tags/PackageTagsHandler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -w -r1.6 -r1.7
  --- PackageTagsHandler.java   5 Feb 2002 00:36:00 -0000       1.6
  +++ PackageTagsHandler.java   4 Mar 2002 21:32:41 -0000       1.7
  @@ -2,54 +2,79 @@
   
   import com.sun.javadoc.ClassDoc;
   import com.sun.javadoc.PackageDoc;
  -import com.sun.javadoc.ProgramElementDoc;
   
   import xdoclet.XDocletException;
  +import xdoclet.DocletContext;
   import xdoclet.template.TemplateException;
   import xdoclet.util.Translator;
   
  -import java.util.Iterator;
  -import java.util.Properties;
  -import java.util.SortedSet;
  -import java.util.TreeSet;
  -import java.util.StringTokenizer;
  +import java.util.*;
  +import java.io.Serializable;
   
   /**
    * @author    Ara Abrahamian ([EMAIL PROTECTED])
    * @created   Oct 14, 2001
  - * @version   $Revision: 1.6 $
  + * @version   $Revision: 1.7 $
    */
   public class PackageTagsHandler extends AbstractProgramElementTagsHandler
   {
        public static String getPackageNameFor( PackageDoc pak )
        {
  -             return pak.name();
  +             return getPackageNameFor( pak.name() );
        }
   
        /**
  -      * Returns the package of the Class given as a String
  +      * It applies package substitutions.
         *
  -      * @param fullClassName
  -      * @return               Description of the Returned Value
  +      * @param packageName
  +      * @return
         */
  -     public static String getPackageFor( String fullClassName )
  +     public static String getPackageNameFor( String packageName )
        {
  -             StringTokenizer st = new StringTokenizer( fullClassName, "." );
  -             String pack = "";
  +             Vector package_substitutions = getPackageSubstitutions( 
DocletContext.getInstance().getActiveSubTask().getSubTaskName() );
  +
  +             if( package_substitutions == null )
  +                     return packageName;
  +
  +             for( int i = 0; i < package_substitutions.size(); i++ )
  +             {
  +                     PackageSubstitution ps = ( PackageSubstitution ) 
package_substitutions.elementAt( i );
  +                     StringTokenizer st = new StringTokenizer( ps.getPackages(), 
",", false );
   
                while( st.hasMoreTokens() )
                {
  -                     String nt = st.nextToken();
  +                             String packages = st.nextToken();
  +                             String suffix = "." + packages;
   
  -                     if( st.hasMoreTokens() )
  +                             if( packageName.endsWith( suffix ) )
                        {
  -                             if( pack.equals( "" ) )
  -                                     pack = nt;
  -                             else
  -                                     pack = pack + "." + nt;
  +                                     packageName = packageName.substring( 0, 
packageName.length() - suffix.length() ) + "." + ps.getSubstituteWith();
  +                                     break;
                        }
                }
  -             return pack;
  +             }
  +
  +             return packageName;
  +     }
  +
  +     public static Vector getPackageSubstitutions( String subtask_name )
  +     {
  +             //SubTask's packageSubstitutions has precedence over the global 
packageSubstitutions defined in DocletTask
  +             Vector package_substitutions = null;
  +             boolean supports_package_substitution_inheritance = true;
  +
  +             Boolean supports = ( ( Boolean ) 
DocletContext.getInstance().getConfigParam( subtask_name + 
".packageSubstitutionInheritanceSupported" ) );
  +
  +             if( supports != null )
  +                     supports_package_substitution_inheritance = 
supports.booleanValue();
  +
  +             package_substitutions = ( Vector ) 
DocletContext.getInstance().getConfigParam( subtask_name + ".packageSubstitutions" );
  +
  +             //nothing specified for subtask, inherit the one from DocletTask
  +             if( supports_package_substitution_inheritance && ( 
package_substitutions == null || package_substitutions.isEmpty() ) )
  +                     package_substitutions = ( Vector ) 
DocletContext.getInstance().getConfigParam( "packageSubstitutions" );
  +
  +             return package_substitutions;
        }
   
        /**
  @@ -113,7 +138,7 @@
                {
                        String fullClassName = getEngine().outputOf( template );
   
  -                     getEngine().print( fullClassName.substring( 0, 
fullClassName.lastIndexOf( "." ) ) );
  +                     getEngine().print( getPackageNameFor( fullClassName.substring( 
0, fullClassName.lastIndexOf( "." ) ) ) );
                }
                catch( TemplateException ex )
                {
  @@ -176,4 +201,32 @@
                return packageNameAsPathFor( packageName() );
        }
   
  +     /**
  +      * @created   November 16, 2001
  +      */
  +     public static class PackageSubstitution implements Serializable
  +     {
  +             private String    packages = null;
  +             private String    substituteWith = null;
  +
  +             public String getPackages()
  +             {
  +                     return packages;
  +             }
  +
  +             public String getSubstituteWith()
  +             {
  +                     return substituteWith;
  +             }
  +
  +             public void setPackages( String packages )
  +             {
  +                     this.packages = packages;
  +             }
  +
  +             public void setSubstituteWith( String substituteWith )
  +             {
  +                     this.substituteWith = substituteWith;
  +             }
  +     }
   }
  
  
  

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

Reply via email to