User: rinkrank
  Date: 02/04/08 17:07:15

  Modified:    core/src/xdoclet/ant AntPropertyTask.java ReplaceCopy.java
  Log:
  -Dynamic loading of optional modules is partially working (subtasks work. 
registering tag handlers doesn't)
  -Translator no longer throws XDocletException
  
  Revision  Changes    Path
  1.10      +45 -46    xdoclet/core/src/xdoclet/ant/AntPropertyTask.java
  
  Index: AntPropertyTask.java
  ===================================================================
  RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/ant/AntPropertyTask.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -w -r1.9 -r1.10
  --- AntPropertyTask.java      4 Apr 2002 01:03:05 -0000       1.9
  +++ AntPropertyTask.java      9 Apr 2002 00:07:15 -0000       1.10
  @@ -25,10 +25,11 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Aslak Helles�y</a>
    * @created 5. januar 2002
  - * @version $Revision: 1.9 $
  + * @version      $Revision: 1.10 $
    * @deprecated Use ReplaceCopy instead
    */
  -public class AntPropertyTask extends Task {
  +public class AntPropertyTask extends Task
  +{
        /**
         * @todo-javadoc Describe the field
         */
  @@ -38,27 +39,26 @@
         */
        private File templateFile;
   
  -
        /**
         * Sets the DestinationFile attribute of the AntPropertyTask object
         *
         * @param destinationFile The new DestinationFile value
         */
  -     public void setDestinationFile(File destinationFile) {
  +     public void setDestinationFile( File destinationFile )
  +     {
                this.destinationFile = destinationFile;
        }
   
  -
        /**
         * Sets the TemplateFile attribute of the AntPropertyTask object
         *
         * @param templateFile The new TemplateFile value
         */
  -     public void setTemplateFile(File templateFile) {
  +     public void setTemplateFile( File templateFile )
  +     {
                this.templateFile = templateFile;
        }
   
  -
        /**
         * Describe what the method does
         *
  @@ -66,22 +66,17 @@
         * @todo-javadoc Write javadocs for method
         * @todo-javadoc Write javadocs for exception
         */
  -     public void execute() throws BuildException {
  -             if (destinationFile == null) {
  -                     try {
  +     public void execute() throws BuildException
  +     {
  +             if( destinationFile == null )
  +             {
                                throw new 
BuildException(Translator.getString("xdoclet.ant.Messages",
                                                "property_missing", new 
String[]{"destinationFile"}));
  -                     } catch (xdoclet.XDocletException xe) {
  -                             throw new BuildException(xe);
  -                     }
                }
  -             if (templateFile == null) {
  -                     try {
  +             if( templateFile == null )
  +             {
                                throw new 
BuildException(Translator.getString("xdoclet.ant.Messages",
                                                "property_missing", new 
String[]{"templateFile"}));
  -                     } catch (xdoclet.XDocletException xe) {
  -                             throw new BuildException(xe);
  -                     }
                }
   
                System.out.println("INFO: xdoclet.ant.AntPropertyTask is deprecated. 
Please use xdoclet.ant.ReplaceCopy instead.");
  @@ -89,18 +84,22 @@
                Hashtable properties = project.getProperties();
                AntTagsHandler antTagsHandler = new AntTagsHandler(properties);
   
  -             try {
  -                     TemplateEngine engine = new TemplateEngine();
  +             try
  +             {
  +                     TemplateEngine engine = TemplateEngine.getEngineInstance();
   
  -                     engine.setTagHandlerFor("XDtAnt", antTagsHandler);
                        engine.setTagHandlerFor("Ant", antTagsHandler);
   
                        engine.setTemplateURL(templateFile.toURL());
                        engine.setOutput(destinationFile);
                        engine.start();
  -             } catch (MalformedURLException e) {
  +             }
  +             catch( MalformedURLException e )
  +             {
                        throw new BuildException(e);
  -             } catch (TemplateException e) {
  +             }
  +             catch( TemplateException e )
  +             {
                        throw new BuildException(e);
                }
        }
  
  
  
  1.9       +85 -71    xdoclet/core/src/xdoclet/ant/ReplaceCopy.java
  
  Index: ReplaceCopy.java
  ===================================================================
  RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/ant/ReplaceCopy.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -w -r1.8 -r1.9
  --- ReplaceCopy.java  4 Apr 2002 01:03:05 -0000       1.8
  +++ ReplaceCopy.java  9 Apr 2002 00:07:15 -0000       1.9
  @@ -33,10 +33,11 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Aslak Helles�y</a>
    * @created 5. januar 2002
  - * @version $Revision: 1.8 $
  + * @version   $Revision: 1.9 $
    * @todo Write docs!!!!!!!!!!!!!!!!!
    */
  -public class ReplaceCopy extends Copy {
  +public class ReplaceCopy extends Copy
  +{
        /**
         * Overridden doFileOperations() as Ant suggests. It would be less copy-paste
         * if fileUtils.copyFile in the superclass' method used getFileUtils().copyFile
  @@ -44,47 +45,53 @@
         * subclass which used XDoclet template engine. Until Ant fixes this, we'll do
         * inheritance by copy/paste :-(
         */
  -     protected void doFileOperations() {
  +     protected void doFileOperations()
  +     {
                Hashtable properties = project.getProperties();
                AntPropertyTagsHandler antPropertyTagsHandler = new 
AntPropertyTagsHandler(properties);
                TemplateEngine engine = null;
   
  -             try {
  -                     engine = new TemplateEngine();
  +             try
  +             {
  +                     engine = TemplateEngine.getEngineInstance();
                        engine.setTagHandlerFor("Ant", antPropertyTagsHandler);
  -             } catch (TemplateException e) {
  -                     try {
  -                             throw new 
BuildException(Translator.getString("xdoclet.ant.Messages", 
"error_creating_templateengine"));
  -                     } catch (XDocletException xe) {
  -                             throw new BuildException(xe);
                        }
  +             catch( TemplateException e )
  +             {
  +                     throw new BuildException( Translator.getString( 
"xdoclet.ant.Messages", "error_creating_templateengine" ) );
                }
   
  -             if (fileCopyMap.size() > 0) {
  +             if( fileCopyMap.size() > 0 )
  +             {
                        log("Copying " + fileCopyMap.size() +
                                        " file" + (fileCopyMap.size() == 1 ? "" : "s") 
+
                                        " to " + destDir.getAbsolutePath());
   
                        Enumeration e = fileCopyMap.keys();
   
  -                     while (e.hasMoreElements()) {
  +                     while( e.hasMoreElements() )
  +                     {
                                String fromFile = (String)e.nextElement();
                                String toFile = (String)fileCopyMap.get(fromFile);
   
  -                             if (fromFile.equals(toFile)) {
  +                             if( fromFile.equals( toFile ) )
  +                             {
                                        log("Skipping self-copy of " + fromFile, 
verbosity);
                                        continue;
                                }
   
  -                             try {
  +                             try
  +                             {
                                        log("Copying " + fromFile + " to " + toFile, 
verbosity);
   
                                        FilterSetCollection executionFilters = new 
FilterSetCollection();
   
  -                                     if (filtering) {
  +                                     if( filtering )
  +                                     {
                                                
executionFilters.addFilterSet(project.getGlobalFilterSet());
                                        }
  -                                     for (Enumeration filterEnum = 
getFilterSets().elements(); filterEnum.hasMoreElements(); ) {
  +                                     for( Enumeration filterEnum = 
getFilterSets().elements(); filterEnum.hasMoreElements();  )
  +                                     {
                                                
executionFilters.addFilterSet((FilterSet)filterEnum.nextElement());
                                        }
   
  @@ -92,37 +99,41 @@
   //                                       forceOverwrite, preserveLastModified);
                                        replace(fromFile, toFile, engine);
   
  -                             } catch (TemplateException ioe) {
  -                                     try {
  +                             }
  +                             catch( TemplateException ioe )
  +                             {
                                                String msg = 
Translator.getString("xdoclet.ant.Messages", "failed_to_copy",
                                                                new String[]{fromFile, 
toFile, ioe.getMessage()});
   
                                                throw new BuildException(msg, ioe, 
location);
  -                                     } catch (XDocletException xe) {
  -                                             throw new BuildException(xe);
  -                                     }
                                }
                        }
                }
   
  -             if (includeEmpty) {
  +             if( includeEmpty )
  +             {
                        Enumeration e = dirCopyMap.elements();
                        int count = 0;
   
  -                     while (e.hasMoreElements()) {
  +                     while( e.hasMoreElements() )
  +                     {
                                File d = new File((String)e.nextElement());
   
  -                             if (!d.exists()) {
  -                                     if (!d.mkdirs()) {
  +                             if( !d.exists() )
  +                             {
  +                                     if( !d.mkdirs() )
  +                                     {
                                                log("Unable to create directory " + 
d.getAbsolutePath(), Project.MSG_ERR);
                                        }
  -                                     else {
  +                                     else
  +                                     {
                                                count++;
                                        }
                                }
                        }
   
  -                     if (count > 0) {
  +                     if( count > 0 )
  +                     {
                                log("Copied " + count +
                                                " empty director" +
                                                (count == 1 ? "y" : "ies") +
  @@ -131,7 +142,6 @@
                }
        }
   
  -
        /**
         * Describe what the method does
         *
  @@ -145,12 +155,16 @@
         * @todo-javadoc Write javadocs for method parameter
         * @todo-javadoc Write javadocs for exception
         */
  -     private void replace(String fromFile, String toFile, TemplateEngine engine) 
throws TemplateException {
  -             try {
  +     private void replace( String fromFile, String toFile, TemplateEngine engine ) 
throws TemplateException
  +     {
  +             try
  +             {
                        engine.setTemplateURL(new File(fromFile).toURL());
                        engine.setOutput(new File(toFile));
                        engine.start();
  -             } catch (MalformedURLException e) {
  +             }
  +             catch( MalformedURLException e )
  +             {
                        throw new TemplateException(e.getMessage());
                }
        }
  
  
  

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

Sponsored by http://www.ThinkGeek.com/

Reply via email to