ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jerry Huth <jerry.h...@Sun.COM>
Subject [PATCH] Copy.java
Date Thu, 04 Jan 2001 20:23:16 GMT

[PATCH] Copy.java

I have a subclass of Copy that does "custom filtering" (i.e. filters
that can be different for each file).  It works really well, but I had
to override the doFileOperations() function, which is a pretty big
function, and copy its code from Copy.java.

However if the Copy class had some notification functions that were
called before and after copying each file, then I could just override
the notification functions and I wouldn't have to copy any code from
Copy.java.

So, I added these notification functions to Copy.java (revision id
1.12) which I've attached.  Is there any chance of getting this change
in the next version of ANT?  Here are the context diffs for my
changes:


RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Copy.java,v
retrieving revision 1.12
diff -c -r1.12 Copy.java
*** Copy.java	2000/12/15 09:49:30	1.12
--- Copy.java	2001/01/02 22:14:42
***************
*** 311,317 ****
  
      /**
       * Actually does the file (and possibly empty directory) copies.
!      * This is a good method for subclasses to override.
       */
      protected void doFileOperations() {
          if (fileCopyMap.size() > 0) {
--- 311,318 ----
  
      /**
       * Actually does the file (and possibly empty directory) copies.
!      * This is a good method for subclasses to override if overriding
!      * preCopyNotify() and postCopyNotify() is not sufficient.
       */
      protected void doFileOperations() {
          if (fileCopyMap.size() > 0) {
***************
*** 330,335 ****
--- 331,337 ----
                  }
  
                  try {
+                     preCopyNotify( fromFile, toFile, filtering, forceOverwrite) ;
                      log("Copying " + fromFile + " to " + toFile, verbosity);
                      
                      project.copyFile(fromFile, 
***************
*** 337,343 ****
--- 339,348 ----
                                       filtering, 
                                       forceOverwrite,
                                       preserveLastModified);
+ 
+                     postCopyNotify( fromFile, toFile, filtering, forceOverwrite) ;
                  } catch (IOException ioe) {
+                     postCopyNotify( fromFile, toFile, filtering, forceOverwrite) ;
                      String msg = "Failed to copy " + fromFile + " to " + toFile
                          + " due to " + ioe.getMessage();
                      throw new BuildException(msg, ioe, location);
***************
*** 364,368 ****
--- 369,385 ----
              }
          }
      }
+ 
+     /**
+      * This is called just before a file is copied.
+      */
+     protected void preCopyNotify( String fromFile, String toFile, 
+                                   boolean filtering, boolean forceOverwrite) {}
+ 
+     /**
+      * This is called just after a file is copied.
+      */
+     protected void postCopyNotify( String fromFile, String toFile, 
+                                    boolean filtering, boolean forceOverwrite) {}
  
  }

Mime
View raw message