ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From umag...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs SendEmail.java
Date Mon, 10 Dec 2001 18:01:16 GMT
umagesh     01/12/10 10:01:16

  Modified:    docs/manual/CoreTasks mail.html
               src/main/org/apache/tools/ant/taskdefs SendEmail.java
  Log:
  Name of file attachments can be optionally included.
  
  PR: 3024
  
  Revision  Changes    Path
  1.6       +7 -1      jakarta-ant/docs/manual/CoreTasks/mail.html
  
  Index: mail.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTasks/mail.html,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- mail.html	2001/11/15 22:11:27	1.5
  +++ mail.html	2001/12/10 18:01:16	1.6
  @@ -41,9 +41,15 @@
   	Multiple files are comma-separated.</td>
     </tr>
     <tr>
  +    <td valign="top">includefilenames</td>
  +    <td valign="top">Include filename(s) before file contents.
  +    Valid only when the files attribute is specified.</td>
  +    <td align="center" valign="top">No, default is <I>false</I></td>
  +  </tr>
  +  <tr>
       <td valign="top">mailhost</td>
       <td valign="top">Host name of the mail server.</td>
  -    <td align="center" valign="top">No, default to &quot;localhost&quot;</td>
  +    <td align="center" valign="top">No, default is &quot;localhost&quot;</td>
     </tr>
     <tr>
       <td valign="top">mailport</td>
  
  
  
  1.6       +28 -2     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/SendEmail.java
  
  Index: SendEmail.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/SendEmail.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SendEmail.java	2001/11/15 22:11:28	1.5
  +++ SendEmail.java	2001/12/10 18:01:16	1.6
  @@ -107,9 +107,15 @@
    * <td>Message to send inthe body of the email.</td>
    * </tr>
    * </table>
  + * <tr>
  + * <td>includefilenames</td>
  + * <td>Includes filenames before file contents when set to true.</td>
  + * <td>No, default is <I>false</I></td>
  + * </tr>
    * <p>
    *
    * @author glenn_twiggs@bmc.com
  + * @author <a href="mailto:umagesh@rediffmail.com">Magesh Umasankar</a>
    */
   public class SendEmail extends Task {
       private String from;
  @@ -119,6 +125,7 @@
       private String toList;
       private String subject;
       private Vector files = new Vector();
  +    private boolean includefilenames;
     
       /** Creates new SendEmail */
       public SendEmail() {
  @@ -191,6 +198,15 @@
       }
   
       /**
  +     * Sets Includefilenames attribute
  +     *
  +     * @param includefilenames Set to true if file names are to be included.
  +     */
  +    public void setIncludefilenames(boolean includefilenames) {
  +        this.includefilenames = includefilenames;
  +    }
  +
  +    /**
        * Executes this build task.
        *
        * @throws BuildException if there is an error during task execution.
  @@ -230,14 +246,24 @@
                           int bufsize = 1024;
                           int length;
                           byte[] buf = new byte[bufsize];
  -
  +                        if (includefilenames) {
  +                            String filename = file.getName();
  +                            int filenamelength = filename.length();
  +                            out.println(filename);
  +                            for (int star=0; star < filenamelength; star++) {
  +                                out.print('=');
  +                            }
  +                            out.println();
  +                        }
                           BufferedInputStream in = null;
                           try {
                               in = new BufferedInputStream(
                                   new FileInputStream(file), bufsize);
  -    
                               while ((length = in.read(buf, 0, bufsize)) != -1) {
                                   out.write(buf, 0, length);
  +                            }
  +                            if (includefilenames) {
  +                                out.println();
                               }
                           } finally {
                               if (in != null) {
  
  
  

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


Mime
View raw message