User: d_jencks
  Date: 02/04/05 20:01:31

  Modified:    core/src/xdoclet TemplateSubTask.java
  Log:
  Removed shifting endpoint from loop and allowed prefixes on generated file names
  
  Revision  Changes    Path
  1.39      +439 -393  xdoclet/core/src/xdoclet/TemplateSubTask.java
  
  Index: TemplateSubTask.java
  ===================================================================
  RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/TemplateSubTask.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -w -r1.38 -r1.39
  --- TemplateSubTask.java      4 Apr 2002 01:03:07 -0000       1.38
  +++ TemplateSubTask.java      6 Apr 2002 04:01:31 -0000       1.39
  @@ -33,9 +33,14 @@
    *
    * @author Ara Abrahamian ([EMAIL PROTECTED])
    * @created Sep 25, 2001
  - * @version $Revision: 1.38 $
  + * @version   $Revision: 1.39 $
    */
  -public class TemplateSubTask extends SubTask {
  +public class TemplateSubTask extends SubTask
  +{
  +     /**
  +      * @todo-javadoc   Describe the field
  +      */
  +     public final static String SUBTASK_NAME = "template";
   
        /**
         * @todo-javadoc Describe the field
  @@ -119,287 +124,299 @@
         * @todo-javadoc Describe the field
         */
        private GenerationManager generationManager;
  +
        /**
  -      * @todo-javadoc Describe the field
  +      * Converts the full qualified class name to a valid path with File.separator
  +      * characters instead of . characters and class name postfixed by a ".java".
  +      *
  +      * @param className  Description of Parameter
  +      * @return           Description of the Returned Value
         */
  -     public final static String SUBTASK_NAME = "template";
  -
  +     protected static String javaFile( String className )
  +     {
  +             return className.replace( '.', '/' ) + ".java";
  +     }
   
        /**
  -      * Sets the PackageSubstitutions attribute of the TemplateSubTask object
  +      * Gets the PackageSubstitutions attribute of the TemplateSubTask object
         *
  -      * @param packageSubstitutions The new PackageSubstitutions value
  +      * @return   The PackageSubstitutions value
         */
  -     public void setPackageSubstitutions(ArrayList packageSubstitutions) {
  -             this.packageSubstitutions = packageSubstitutions;
  +     public ArrayList getPackageSubstitutions()
  +     {
  +             return packageSubstitutions;
        }
   
  -
        /**
  -      * Sets the PackageSubstitutionInheritanceSupported attribute of the
  -      * TemplateSubTask object
  +      * By default supports, but some subtasks may not support because global
  +      * packageSubstitution is for public interfaces/classes, not good for impl
  +      * classes.
         *
  -      * @param packageSubstitutionInheritanceSupported The new
  -      *      PackageSubstitutionInheritanceSupported value
  +      * @return   true
         */
  -     public void setPackageSubstitutionInheritanceSupported(boolean 
packageSubstitutionInheritanceSupported) {
  -             this.packageSubstitutionInheritanceSupported = 
packageSubstitutionInheritanceSupported;
  +     public boolean isPackageSubstitutionInheritanceSupported()
  +     {
  +             return packageSubstitutionInheritanceSupported;
        }
   
  -
        /**
  -      * Sets the SubTaskClassName attribute of the TemplateSubTask object
  +      * Gets the SubTaskClassName attribute of the TemplateSubTask object
         *
  -      * @param subTaskClassName The new SubTaskClassName value
  +      * @return   The SubTaskClassName value
         */
  -     public void setSubTaskClassName(String subTaskClassName) {
  -             this.subTaskClassName = subTaskClassName;
  +     public String getSubTaskClassName()
  +     {
  +             return subTaskClassName;
        }
   
  -
        /**
  -      * Sets the PrefixWithPackageStructure attribute of the TemplateSubTask object
  +      * Gets the Engine attribute of the TemplateSubTask object
         *
  -      * @param prefixWithPackageStructure The new PrefixWithPackageStructure value
  +      * @return   The Engine value
         */
  -     public void setPrefixWithPackageStructure(boolean prefixWithPackageStructure) {
  -             this.prefixWithPackageStructure = prefixWithPackageStructure;
  +     public TemplateEngine getEngine()
  +     {
  +             return engine;
        }
   
  -
        /**
  -      * Sets the Engine attribute of the TemplateSubTask object
  +      * Gets the Parser attribute of the TemplateSubTask object
         *
  -      * @param engine The new Engine value
  +      * @return   The Parser value
         */
  -     public void setEngine(TemplateEngine engine) {
  -             this.engine = engine;
  +     public TemplateParser getParser()
  +     {
  +             return parser;
        }
   
  -
        /**
  -      * Sets the Parser attribute of the TemplateSubTask object
  +      * Gets the TemplateURL attribute of the TemplateSubTask object
         *
  -      * @param parser The new Parser value
  +      * @return   The TemplateURL value
         */
  -     public void setParser(TemplateParser parser) {
  -             this.parser = parser;
  +     public URL getTemplateURL()
  +     {
  +             return templateFile;
        }
   
  -
        /**
  -      * Sets the DestinationFile attribute of the TemplateSubTask object
  +      * Gets the DestinationFile attribute of the TemplateSubTask object
         *
  -      * @param destinationFile The new DestinationFile value
  +      * @return   The DestinationFile value
         */
  -     public void setDestinationFile(String destinationFile) {
  -             this.destinationFile = destinationFile;
  +     public String getDestinationFile()
  +     {
  +             return destinationFile;
        }
   
  -
        /**
  -      * This method should be called to set a template file programmatically. The
  -      * URL is typically obtained with a getClass().getResource( templateName )
  +      * Gets the OfType attribute of the TemplateSubTask object
         *
  -      * @param templateFile the URL of the template file
  +      * @return   The OfType value
         */
  -     public void setTemplateURL(URL templateFile) {
  -             this.templateFile = templateFile;
  +     public String getOfType()
  +     {
  +             return ofType;
        }
   
  -
        /**
  -      * This method is called from Ant in <template templateFile="blabla"/> Don't
  -      * call this explicitly, use the URL method instead.
  +      * Gets the Extent attribute of the TemplateSubTask object
         *
  -      * @param templateFile the file name (real file!) of the template
  +      * @return   The Extent value
         */
  -     public void setTemplateFile(File templateFile) {
  -             if (templateFile.exists()) {
  -                     try {
  -                             setTemplateURL(templateFile.toURL());
  -                     } catch (MalformedURLException e) {
  -                             throw new 
org.apache.tools.ant.BuildException(e.getMessage());
  -                     }
  -             }
  -             else {
  -                     throw new org.apache.tools.ant.BuildException("Couldn't find 
template: " + templateFile.getAbsolutePath());
  -             }
  +     public String getExtent()
  +     {
  +             return extent;
        }
   
  -
        /**
  -      * Sets the OfType attribute of the TemplateSubTask object
  +      * Gets the HavingClassTag attribute of the TemplateSubTask object
         *
  -      * @param ofType The new OfType value
  +      * @return   The HavingClassTag value
         */
  -     public void setOfType(String ofType) {
  -             this.ofType = ofType;
  +     public String getHavingClassTag()
  +     {
  +             return havingClassTag;
        }
   
  -
        /**
  -      * Sets the Extent attribute of the TemplateSubTask object
  +      * Gets the SubTaskName attribute of the TemplateSubTask object
         *
  -      * @param extent The new Extent value
  +      * @return   The SubTaskName value
         */
  -     public void setExtent(ExtentTypes extent) {
  -             this.extent = extent.getValue();
  +     public String getSubTaskName()
  +     {
  +             return SUBTASK_NAME;
        }
   
  -
        /**
  -      * Sets the HavingClassTag attribute of the TemplateSubTask object
  +      * Gets the PrefixWithPackageStructure attribute of the TemplateSubTask object
         *
  -      * @param havingClassTag The new HavingClassTag value
  +      * @return   The PrefixWithPackageStructure value
         */
  -     public void setHavingClassTag(String havingClassTag) {
  -             this.havingClassTag = havingClassTag;
  +     public boolean isPrefixWithPackageStructure()
  +     {
  +             return prefixWithPackageStructure;
        }
   
  -
        /**
  -      * Sets the GenerationManager attribute of the TemplateSubTask object
  +      * Sets the PackageSubstitutions attribute of the TemplateSubTask object
         *
  -      * @param gM The new GenerationManager value
  +      * @param packageSubstitutions  The new PackageSubstitutions value
         */
  -     public void setGenerationManager(GenerationManager gM) {
  -             this.generationManager = gM;
  +     public void setPackageSubstitutions( ArrayList packageSubstitutions )
  +     {
  +             this.packageSubstitutions = packageSubstitutions;
        }
   
  -
        /**
  -      * Gets the PackageSubstitutions attribute of the TemplateSubTask object
  +      * Sets the PackageSubstitutionInheritanceSupported attribute of the
  +      * TemplateSubTask object
         *
  -      * @return The PackageSubstitutions value
  +      * @param packageSubstitutionInheritanceSupported  The new
  +      *      PackageSubstitutionInheritanceSupported value
         */
  -     public ArrayList getPackageSubstitutions() {
  -             return packageSubstitutions;
  +     public void setPackageSubstitutionInheritanceSupported( boolean 
packageSubstitutionInheritanceSupported )
  +     {
  +             this.packageSubstitutionInheritanceSupported = 
packageSubstitutionInheritanceSupported;
        }
   
  -
        /**
  -      * By default supports, but some subtasks may not support because global
  -      * packageSubstitution is for public interfaces/classes, not good for impl
  -      * classes.
  +      * Sets the SubTaskClassName attribute of the TemplateSubTask object
         *
  -      * @return true
  +      * @param subTaskClassName  The new SubTaskClassName value
         */
  -     public boolean isPackageSubstitutionInheritanceSupported() {
  -             return packageSubstitutionInheritanceSupported;
  +     public void setSubTaskClassName( String subTaskClassName )
  +     {
  +             this.subTaskClassName = subTaskClassName;
        }
   
  -
        /**
  -      * Gets the SubTaskClassName attribute of the TemplateSubTask object
  +      * Sets the PrefixWithPackageStructure attribute of the TemplateSubTask object
         *
  -      * @return The SubTaskClassName value
  +      * @param prefixWithPackageStructure  The new PrefixWithPackageStructure value
         */
  -     public String getSubTaskClassName() {
  -             return subTaskClassName;
  +     public void setPrefixWithPackageStructure( boolean prefixWithPackageStructure )
  +     {
  +             this.prefixWithPackageStructure = prefixWithPackageStructure;
        }
   
  -
        /**
  -      * Gets the Engine attribute of the TemplateSubTask object
  +      * Sets the Engine attribute of the TemplateSubTask object
         *
  -      * @return The Engine value
  +      * @param engine  The new Engine value
         */
  -     public TemplateEngine getEngine() {
  -             return engine;
  +     public void setEngine( TemplateEngine engine )
  +     {
  +             this.engine = engine;
        }
   
  -
        /**
  -      * Gets the Parser attribute of the TemplateSubTask object
  +      * Sets the Parser attribute of the TemplateSubTask object
         *
  -      * @return The Parser value
  +      * @param parser  The new Parser value
         */
  -     public TemplateParser getParser() {
  -             return parser;
  +     public void setParser( TemplateParser parser )
  +     {
  +             this.parser = parser;
        }
   
  -
        /**
  -      * Gets the TemplateURL attribute of the TemplateSubTask object
  +      * Sets the DestinationFile attribute of the TemplateSubTask object
         *
  -      * @return The TemplateURL value
  +      * @param destinationFile  The new DestinationFile value
         */
  -     public URL getTemplateURL() {
  -             return templateFile;
  +     public void setDestinationFile( String destinationFile )
  +     {
  +             this.destinationFile = destinationFile;
        }
   
  -
        /**
  -      * Gets the DestinationFile attribute of the TemplateSubTask object
  +      * This method should be called to set a template file programmatically. The
  +      * URL is typically obtained with a getClass().getResource( templateName )
         *
  -      * @return The DestinationFile value
  +      * @param templateFile  the URL of the template file
         */
  -     public String getDestinationFile() {
  -             return destinationFile;
  +     public void setTemplateURL( URL templateFile )
  +     {
  +             this.templateFile = templateFile;
        }
   
  -
        /**
  -      * Gets the OfType attribute of the TemplateSubTask object
  +      * This method is called from Ant in <template templateFile="blabla"/> Don't
  +      * call this explicitly, use the URL method instead.
         *
  -      * @return The OfType value
  +      * @param templateFile  the file name (real file!) of the template
         */
  -     public String getOfType() {
  -             return ofType;
  +     public void setTemplateFile( File templateFile )
  +     {
  +             if( templateFile.exists() )
  +             {
  +                     try
  +                     {
  +                             setTemplateURL( templateFile.toURL() );
  +                     }
  +                     catch( MalformedURLException e )
  +                     {
  +                             throw new org.apache.tools.ant.BuildException( 
e.getMessage() );
  +                     }
  +             }
  +             else
  +             {
  +                     throw new org.apache.tools.ant.BuildException( "Couldn't find 
template: " + templateFile.getAbsolutePath() );
  +             }
        }
  -
   
        /**
  -      * Gets the Extent attribute of the TemplateSubTask object
  +      * Sets the OfType attribute of the TemplateSubTask object
         *
  -      * @return The Extent value
  +      * @param ofType  The new OfType value
         */
  -     public String getExtent() {
  -             return extent;
  +     public void setOfType( String ofType )
  +     {
  +             this.ofType = ofType;
        }
   
  -
        /**
  -      * Gets the HavingClassTag attribute of the TemplateSubTask object
  +      * Sets the Extent attribute of the TemplateSubTask object
         *
  -      * @return The HavingClassTag value
  +      * @param extent  The new Extent value
         */
  -     public String getHavingClassTag() {
  -             return havingClassTag;
  +     public void setExtent( ExtentTypes extent )
  +     {
  +             this.extent = extent.getValue();
        }
   
  -
        /**
  -      * Gets the SubTaskName attribute of the TemplateSubTask object
  +      * Sets the HavingClassTag attribute of the TemplateSubTask object
         *
  -      * @return The SubTaskName value
  +      * @param havingClassTag  The new HavingClassTag value
         */
  -     public String getSubTaskName() {
  -             return SUBTASK_NAME;
  +     public void setHavingClassTag( String havingClassTag )
  +     {
  +             this.havingClassTag = havingClassTag;
        }
   
  -
        /**
  -      * Gets the PrefixWithPackageStructure attribute of the TemplateSubTask object
  +      * Sets the GenerationManager attribute of the TemplateSubTask object
         *
  -      * @return The PrefixWithPackageStructure value
  +      * @param gM  The new GenerationManager value
         */
  -     public boolean isPrefixWithPackageStructure() {
  -             return prefixWithPackageStructure;
  +     public void setGenerationManager( GenerationManager gM )
  +     {
  +             this.generationManager = gM;
        }
   
  -
        /**
         * Adds a set of files (nested fileset attribute).
         *
         * @param ps The feature to be added to the Fileset attribute
         */
  -     public void addPackageSubstitution(PackageTagsHandler.PackageSubstitution ps) {
  +     public void addPackageSubstitution( PackageTagsHandler.PackageSubstitution ps )
  +     {
                packageSubstitutions.add(ps);
        }
   
  -
        /**
         * Describe what the method does
         *
  @@ -407,7 +424,8 @@
         * @todo-javadoc Write javadocs for method
         * @todo-javadoc Write javadocs for method parameter
         */
  -     public void copyAttributesFrom(TemplateSubTask src) {
  +     public void copyAttributesFrom( TemplateSubTask src )
  +     {
                setPrefixWithPackageStructure(src.isPrefixWithPackageStructure());
                setDestinationFile(src.getDestinationFile());
                setTemplateURL(src.getTemplateURL());
  @@ -416,7 +434,6 @@
                setHavingClassTag(src.getHavingClassTag());
        }
   
  -
        /**
         * Describe what the method does
         *
  @@ -424,36 +441,41 @@
         * @todo-javadoc Write javadocs for method
         * @todo-javadoc Write javadocs for exception
         */
  -     public void init() throws XDocletException {
  +     public void init() throws XDocletException
  +     {
                super.init();
   
  -             try {
  +             try
  +             {
                        setEngine(new TemplateEngine());
                        setParser(new TemplateParser());
  -             } catch (TemplateException te) {
  +             }
  +             catch( TemplateException te )
  +             {
                        throw new XDocletException(te, 
Translator.getString("init_template_engine_failed"));
                }
        }
   
  -
        /**
         * Called to validate configuration parameters.
         *
         * @exception XDocletException Description of Exception
         */
  -     public void validateOptions() throws XDocletException {
  +     public void validateOptions() throws XDocletException
  +     {
                super.validateOptions();
   
  -             if (getTemplateURL() == null) {
  +             if( getTemplateURL() == null )
  +             {
                        throw new 
XDocletException(Translator.getString("template_parameter_missing", new 
String[]{"templateFile"}));
                }
   
  -             if (getDestinationFile() == null) {
  +             if( getDestinationFile() == null )
  +             {
                        throw new 
XDocletException(Translator.getString("template_parameter_missing", new 
String[]{"destinationFile"}));
                }
        }
   
  -
        /**
         * Describe what the method does
         *
  @@ -461,21 +483,11 @@
         * @todo-javadoc Write javadocs for method
         * @todo-javadoc Write javadocs for exception
         */
  -     public void execute() throws XDocletException {
  +     public void execute() throws XDocletException
  +     {
                startProcess();
        }
   
  -
  -     /**
  -      * Sets the ExtentValue attribute of the TemplateSubTask object
  -      *
  -      * @param extent The new ExtentValue value
  -      */
  -     protected void setExtentValue(String extent) {
  -             this.extent = extent;
  -     }
  -
  -
        /**
         * Returns class name for the generated file. {0} substituted by class name.
         *
  @@ -483,24 +495,21 @@
         * @return The GeneratedClassName value
         * @exception XDocletException Description of Exception
         */
  -     protected String getGeneratedFileName(XClass clazz) throws XDocletException {
  +     protected String getGeneratedFileName( XClass clazz ) throws XDocletException
  +     {
                Category cat = Log.getCategory(TemplateSubTask.class, 
"getGeneratedFileName");
   
                XPackage pak = clazz.containingPackage();
                String pak_name = isPackageSubstitutionInheritanceSupported() == true 
? PackageTagsHandler.packageNameAsPathFor(pak) : null;
  -             String dest_file = MessageFormat.format(getDestinationFile(), new 
Object[]{clazz.qualifiedName()});
   
  -             // Get Rid of package
  -             StringTokenizer st = new StringTokenizer(dest_file, ".");
  +             String qualifiedName = clazz.qualifiedName();
  +             int lastDot = qualifiedName.lastIndexOf( "." );
  +             String name = qualifiedName.substring( lastDot + 1 );
   
  -             if (st.countTokens() > 1) {
  -                     for (int i = 0; i < st.countTokens() - 1; i++) {
  -                             st.nextToken();
  -                     }
  -                     dest_file = st.nextToken() + "." + st.nextToken();
  -             }
  +             String dest_file = MessageFormat.format( getDestinationFile(), new 
Object[]{name} );
   
  -             if (cat.isDebugEnabled()) {
  +             if( cat.isDebugEnabled() )
  +             {
                        cat.debug("clazz=" + clazz);
                        cat.debug("pak=" + pak);
                        cat.debug("pak_name=" + pak_name);
  @@ -510,6 +519,15 @@
                return new File(pak_name, dest_file).toString();
        }
   
  +     /**
  +      * Sets the ExtentValue attribute of the TemplateSubTask object
  +      *
  +      * @param extent  The new ExtentValue value
  +      */
  +     protected void setExtentValue( String extent )
  +     {
  +             this.extent = extent;
  +     }
   
        /**
         * Describe what the method does
  @@ -518,10 +536,12 @@
         * @todo-javadoc Write javadocs for method
         * @todo-javadoc Write javadocs for exception
         */
  -     protected void startProcess() throws XDocletException {
  +     protected void startProcess() throws XDocletException
  +     {
                Category cat = Log.getCategory(TemplateSubTask.class, "startProcess");
   
  -             if (cat.isDebugEnabled()) {
  +             if( cat.isDebugEnabled() )
  +             {
                        cat.debug("destDir.toString()=" + getDestDir());
                        cat.debug("getTemplateURL()=" + getTemplateURL());
                        cat.debug("getDestinationfile()=" + getDestinationFile());
  @@ -532,45 +552,61 @@
   
                boolean per_class = isGenerationPerClass();
   
  -             if (per_class) {
  -                     if (cat.isDebugEnabled()) {
  +             if( per_class )
  +             {
  +                     if( cat.isDebugEnabled() )
  +                     {
                                cat.debug("Per class.");
                        }
   
                        XClass[] classes;
   
  -                     try {
  +                     try
  +                     {
                                classes = XJavaDoc.getInstance().sourceClasses();
  -                     } catch (XJavaDocException e) {
  +                     }
  +                     catch( XJavaDocException e )
  +                     {
                                throw new XDocletException(e, e.getMessage());
                        }
   
  -                     for (int i = 0; i < classes.length; i++) {
  +                     for( int i = 0; i < classes.length; i++ )
  +                     {
                                setCurrentClass(classes[i]);
  -                             if (matchesGenerationRules(classes[i]) == true) {
  +                             if( matchesGenerationRules( classes[i] ) == true )
  +                             {
                                        generateForClass(classes[i]);
                                }
                        }
                }
  -             else {
  -                     if (cat.isDebugEnabled()) {
  +             else
  +             {
  +                     if( cat.isDebugEnabled() )
  +                     {
                                cat.debug("Not per class.");
                        }
                        getEngine().setTemplateURL(getTemplateURL());
   
                        File output_file = new File(getDestDir(), 
getDestinationFile());
   
  -                     try {
  +                     try
  +                     {
                                setGenerationManager(new GenerationManager(this));
  -                             if (generationManager.isGenerationNeeded(output_file)) 
{
  +                             if( generationManager.isGenerationNeeded( output_file 
) )
  +                             {
                                        startEngine(getTemplateURL(), output_file);
                                }
  -                     } catch (TemplateException e) {
  -                             if (e instanceof XDocletException) {
  +                     }
  +                     catch( TemplateException e )
  +                     {
  +                             if( e instanceof XDocletException )
  +                             {
                                        throw (XDocletException)e;
                                }
  -                             else {
  -                                     if (cat.isDebugEnabled()) {
  +                             else
  +                             {
  +                                     if( cat.isDebugEnabled() )
  +                                     {
                                                cat.debug("startProcess()");
                                        }
                                        throw new XDocletException(e, 
Translator.getString("running_failed"));
  @@ -580,7 +616,6 @@
                }
        }
   
  -
        /**
         * Returns true if output not already generated for clazz, and is of the
         * specified type and has the specified class tag; false otherwise. If returned
  @@ -590,29 +625,38 @@
         * @return Description of the Returned Value
         * @exception XDocletException Description of Exception
         */
  -     protected boolean matchesGenerationRules(XClass clazz) throws XDocletException 
{
  +     protected boolean matchesGenerationRules( XClass clazz ) throws 
XDocletException
  +     {
                Category cat = Log.getCategory(TemplateSubTask.class, 
"matchesGenerationRules");
   
                //skip automatically generated classes
  -             if (isDocletGenerated(clazz)) {
  -                     if (cat.isDebugEnabled()) {
  +             if( isDocletGenerated( clazz ) )
  +             {
  +                     if( cat.isDebugEnabled() )
  +                     {
                                cat.debug("Reject file '" + clazz.qualifiedName() + "' 
because it is a doclet generated one.");
                        }
                        return false;
                }
   
  -             if (getOfType() != null) {
  -                     if (TypeTagsHandler.isOfType(clazz, getOfType(), 
TypeTagsHandler.extractExtentType(getExtent())) == false) {
  -                             if (cat.isDebugEnabled()) {
  +             if( getOfType() != null )
  +             {
  +                     if( TypeTagsHandler.isOfType( clazz, getOfType(), 
TypeTagsHandler.extractExtentType( getExtent() ) ) == false )
  +                     {
  +                             if( cat.isDebugEnabled() )
  +                             {
                                        cat.debug("Reject class '" + 
clazz.qualifiedName() + "' because it is not of type '" + getOfType() + "'.");
                                }
                                return false;
                        }
                }
   
  -             if (getHavingClassTag() != null) {
  -                     if (!clazz.doc().hasTag(getHavingClassTag(), false)) {
  -                             if (cat.isDebugEnabled()) {
  +             if( getHavingClassTag() != null )
  +             {
  +                     if( !clazz.doc().hasTag( getHavingClassTag(), false ) )
  +                     {
  +                             if( cat.isDebugEnabled() )
  +                             {
                                        cat.debug("Reject class '" + 
clazz.qualifiedName() + "' because it doesn't have class tag '" + getHavingClassTag() 
+ "'.");
                                }
                                return false;
  @@ -622,46 +666,56 @@
                return true;
        }
   
  -
        /**
         * Processed template for clazz and generates output file for clazz.
         *
         * @param clazz Description of Parameter
         * @exception XDocletException Description of Exception
         */
  -     protected void generateForClass(XClass clazz) throws XDocletException {
  +     protected void generateForClass( XClass clazz ) throws XDocletException
  +     {
                Category cat = Log.getCategory(TemplateSubTask.class, 
"generateForClass");
   
                File file = new File(getDestDir().toString(), 
getGeneratedFileName(clazz));
   
  -             if (cat.isDebugEnabled()) {
  +             if( cat.isDebugEnabled() )
  +             {
                        cat.debug("destDir.toString()=" + getDestDir().toString());
                        cat.debug("getGeneratedFileName()=" + 
getGeneratedFileName(clazz));
                        cat.debug("file=" + file);
                }
   
  -             if (file.exists()) {
  -                     if (cat.isDebugEnabled()) {
  +             if( file.exists() )
  +             {
  +                     if( cat.isDebugEnabled() )
  +                     {
                                cat.debug("File exists.");
                        }
   
                        // Check modification timestamps
                        setGenerationManager(new GenerationManager(this));
  -                     if (!generationManager.isGenerationNeeded(clazz, file, true)) {
  +                     if( !generationManager.isGenerationNeeded( clazz, file, true ) 
)
  +                     {
                                return;
                        }
                }
   
                file.getParentFile().mkdirs();
   
  -             try {
  +             try
  +             {
                        startEngine(getTemplateURL(), new File(getDestDir(), 
getGeneratedFileName(clazz)));
  -             } catch (TemplateException e) {
  -                     if (e instanceof XDocletException) {
  +             }
  +             catch( TemplateException e )
  +             {
  +                     if( e instanceof XDocletException )
  +                     {
                                throw (XDocletException)e;
                        }
  -                     else {
  -                             if (cat.isDebugEnabled()) {
  +                     else
  +                     {
  +                             if( cat.isDebugEnabled() )
  +                             {
                                        cat.debug("generateForClass()");
                                }
                                throw new XDocletException(e, 
Translator.getString("running_failed"));
  @@ -669,7 +723,6 @@
                }
        }
   
  -
        /**
         * Describe what the method does
         *
  @@ -677,23 +730,26 @@
         * @todo-javadoc Write javadocs for method
         * @todo-javadoc Write javadocs for exception
         */
  -     protected void engineStarted() throws XDocletException {
  +     protected void engineStarted() throws XDocletException
  +     {
                Category cat = Log.getCategory(TemplateSubTask.class, "engineStarted");
   
  -             if (isGenerationPerClass()) {
  +             if( isGenerationPerClass() )
  +             {
                        
System.out.println(Translator.getString("generating_template_output_per_class", new 
String[]{getCurrentClass().qualifiedName(), getTemplateURL().toString()}));
                }
  -             else {
  +             else
  +             {
                        
System.out.println(Translator.getString("generating_template_output_single_file", new 
String[]{getDestinationFile(), getTemplateURL().toString()}));
                }
   
  -             if (cat.isDebugEnabled()) {
  +             if( cat.isDebugEnabled() )
  +             {
                        cat.debug("getCurrentClass()=" + getCurrentClass());
                        cat.debug("isGenerationPerClass()=" + isGenerationPerClass());
                }
        }
   
  -
        /**
         * Describe what the method does
         *
  @@ -701,10 +757,10 @@
         * @todo-javadoc Write javadocs for method
         * @todo-javadoc Write javadocs for exception
         */
  -     protected void engineFinished() throws TemplateException {
  +     protected void engineFinished() throws TemplateException
  +     {
        }
   
  -
        /**
         * Describe what the method does
         *
  @@ -716,7 +772,8 @@
         * @todo-javadoc Write javadocs for method parameter
         * @todo-javadoc Write javadocs for exception
         */
  -     protected void startEngine(URL templateURL, File output_file) throws 
TemplateException {
  +     protected void startEngine( URL templateURL, File output_file ) throws 
TemplateException
  +     {
                //Category cat = Log.getCategory( TemplateSubTask.class, "startEngine" 
);
   
                //I had to add this line! Apparently log4j does some nasty with 
System.out.
  @@ -732,40 +789,29 @@
                engineFinished();
        }
   
  -
        /**
         * Gets the GenerationPerClass attribute of the TemplateSubTask object
         *
         * @return The GenerationPerClass value
         */
  -     private boolean isGenerationPerClass() {
  +     private boolean isGenerationPerClass()
  +     {
                return getDestinationFile().indexOf("{0}") != -1;
        }
   
  -
  -     /**
  -      * Converts the full qualified class name to a valid path with File.separator
  -      * characters instead of . characters and class name postfixed by a ".java".
  -      *
  -      * @param className Description of Parameter
  -      * @return Description of the Returned Value
  -      */
  -     protected static String javaFile(String className) {
  -             return className.replace('.', '/') + ".java";
  -     }
  -
  -
        /**
         * @author Ara Abrahamian ([EMAIL PROTECTED])
         * @created July 19, 2001
         */
  -     public static class ExtentTypes extends 
org.apache.tools.ant.types.EnumeratedAttribute {
  +     public static class ExtentTypes extends 
org.apache.tools.ant.types.EnumeratedAttribute
  +     {
                /**
                 * Gets the Values attribute of the ExtentTypes object
                 *
                 * @return The Values value
                 */
  -             public java.lang.String[] getValues() {
  +             public java.lang.String[] getValues()
  +             {
                        return (new java.lang.String[]{"concrete-type", "superclass", 
"hierarchy"});
                }
        }
  
  
  

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

Reply via email to