You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2003/01/31 13:15:19 UTC

cvs commit: jakarta-ant/docs/manual/OptionalTasks replaceregexp.html

bodewig     2003/01/31 04:15:19

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional
                        ReplaceRegExp.java
               .        WHATSNEW
               docs/manual/OptionalTasks replaceregexp.html
  Log:
  Add encoding attribute to <replaceregexp>
  
  Revision  Changes    Path
  1.16      +24 -3     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
  
  Index: ReplaceRegExp.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ReplaceRegExp.java	23 Sep 2002 10:37:31 -0000	1.15
  +++ ReplaceRegExp.java	31 Jan 2003 12:15:18 -0000	1.16
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -56,10 +56,13 @@
   import java.io.BufferedReader;
   import java.io.BufferedWriter;
   import java.io.File;
  +import java.io.FileInputStream;
   import java.io.FileReader;
   import java.io.FileWriter;
  +import java.io.InputStreamReader;
   import java.io.IOException;
   import java.io.PrintWriter;
  +import java.io.Reader;
   import java.util.Vector;
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.DirectoryScanner;
  @@ -153,6 +156,10 @@
   
       private FileUtils fileUtils = FileUtils.newFileUtils();
   
  +    /**
  +     * Encoding to assume for the files
  +     */
  +    private String encoding = null;
   
       /** Default Constructor  */
       public ReplaceRegExp() {
  @@ -241,6 +248,16 @@
   
   
       /**
  +     * Specifies the encoding Ant expects the files to be in -
  +     * defaults to the platforms default encoding.
  +     *
  +     * @since Ant 1.6
  +     */
  +    public void setEncoding(String encoding) {
  +        this.encoding = encoding;
  +    }
  +
  +    /**
        * list files to apply the replacement to
        */
       public void addFileset(FileSet set) {
  @@ -300,11 +317,15 @@
           File parentDir = fileUtils.getParentFile(f);
           File temp = fileUtils.createTempFile("replace", ".txt", parentDir);
   
  -        FileReader r = null;
  +        Reader r = null;
           FileWriter w = null;
   
           try {
  -            r = new FileReader(f);
  +            if (encoding == null) {
  +                r = new FileReader(f);
  +            } else {
  +                r = new InputStreamReader(new FileInputStream(f), encoding);
  +            }
               w = new FileWriter(temp);
   
               BufferedReader br = new BufferedReader(r);
  
  
  
  1.350     +4 -0      jakarta-ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
  retrieving revision 1.349
  retrieving revision 1.350
  diff -u -r1.349 -r1.350
  --- WHATSNEW	29 Jan 2003 11:57:24 -0000	1.349
  +++ WHATSNEW	31 Jan 2003 12:15:18 -0000	1.350
  @@ -196,6 +196,10 @@
     You can put in it all the strings described by p4 help usage. Refer to 
     the docs for more information.
   
  +* <replaceregexp> now has an optional encoding attribute to support
  +  replacing in files that are in a different encoding than the
  +  platform's default.
  +
   Changes from Ant 1.5.1Beta1 to 1.5.1
   ====================================
   
  
  
  
  1.12      +5 -0      jakarta-ant/docs/manual/OptionalTasks/replaceregexp.html
  
  Index: replaceregexp.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/OptionalTasks/replaceregexp.html,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- replaceregexp.html	4 Sep 2002 11:33:23 -0000	1.11
  +++ replaceregexp.html	31 Jan 2003 12:15:18 -0000	1.12
  @@ -81,6 +81,11 @@
                        Defaults to <i>false</i>.</td>
       <td valign="top" align="center">No</td>
     </tr>
  +  <tr>
  +    <td valign="top">encoding</td>
  +    <td valign="top">The encoding of the file. <em>since Ant 1.6</em></td>
  +    <td align="center">No - defaults to default JVM encoding</td>
  +  </tr>
   </table>
   <h3>Examples</h3>
   <pre>  &lt;replaceregexp file=&quot;${src}/build.properties&quot;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ant-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: ant-dev-help@jakarta.apache.org