ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: jakarta-ant/docs/manual/CoreTasks replace.html
Date Mon, 30 Jul 2001 13:35:23 GMT
conor       01/07/30 06:35:23

  Modified:    src/main/org/apache/tools/ant/taskdefs Replace.java
               docs/manual/CoreTasks replace.html
  Log:
  Produce a summary, on request, of the actions taken by the replace
  task
  
  PR:	956
  
  Revision  Changes    Path
  1.15      +24 -2     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Replace.java
  
  Index: Replace.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Replace.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Replace.java	2001/07/07 13:51:11	1.14
  +++ Replace.java	2001/07/30 13:35:23	1.15
  @@ -78,7 +78,11 @@
       private Vector replacefilters = new Vector();
   
       private File dir = null;
  -   
  +
  +    private int fileCount;
  +    private int replaceCount;    
  +    private boolean summary = false;
  +    
       //Inner class
       public class NestedString {
   
  @@ -187,13 +191,15 @@
           }
   
           validateReplacefilters();
  +        fileCount = 0;
  +        replaceCount = 0;
   
           if (src != null) {
               processFile(src);
           }
   
           if (dir != null) {
  -        DirectoryScanner ds = super.getDirectoryScanner(dir);
  +            DirectoryScanner ds = super.getDirectoryScanner(dir);
               String[] srcs = ds.getIncludedFiles();
   
               for(int i=0; i<srcs.length; i++) {
  @@ -201,6 +207,10 @@
                   processFile(file);
               }
           }
  +        
  +        if (summary) {
  +            log("Replaced " + replaceCount + " occurrences in " + fileCount + " files.",
Project.MSG_INFO);
  +        }
       }
       
       /**
  @@ -337,6 +347,7 @@
               // If there were changes, move the new one to the old one;
               // otherwise, delete the new one
               if (changes) {
  +                ++fileCount;
                   src.delete();
                   temp.renameTo(src);
               } else {
  @@ -371,6 +382,16 @@
       }
   
       /**
  +     * Request a summary
  +     *
  +     * @param summary true if you would like a summary logged of the replace operation
  +     */
  +    public void setSummary(boolean summary) {
  +        this.summary = summary;
  +    }
  +    
  +    
  +    /**
        * Set the source files path when using matching tasks.
        */
       public void setDir(File dir) {
  @@ -445,6 +466,7 @@
               // search again
               start = found + str1.length();
               found = str.indexOf(str1,start);
  +            ++replaceCount;
           }
   
           // write the remaining characters
  
  
  
  1.3       +8 -0      jakarta-ant/docs/manual/CoreTasks/replace.html
  
  Index: replace.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTasks/replace.html,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- replace.html	2001/02/13 12:31:52	1.2
  +++ replace.html	2001/07/30 13:35:23	1.3
  @@ -43,6 +43,14 @@
       <td valign="top" align="center">No</td>
     </tr>
     <tr>
  +    <td valign="top">summary</td>
  +    <td valign="top">Indicates whether a summary of the replace operation 
  +                     should be produced, detailing how many token occurrences 
  +                     and files were processed
  +                     </td>
  +    <td valign="top" align="center">No, by default no summary is produced</td>
  +  </tr>
  +  <tr>
       <td valign="top">propertyFile</td>
       <td valign="top">valid property file from which properties specified using nested
<code>&lt;replacefilter&gt;</code> elements are drawn.</td>
       <td valign="top" align="center">Yes only if <i>property</i> attribute
of <code>&lt;replacefilter&gt;</code> is used.</td>
  
  
  

Mime
View raw message