ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Exit.java Filter.java FixCRLF.java GenerateKey.java Get.java Jar.java
Date Thu, 11 Apr 2002 14:28:01 GMT
bodewig     02/04/11 07:28:01

  Modified:    src/main/org/apache/tools/ant/taskdefs Exit.java Filter.java
                        FixCRLF.java GenerateKey.java Get.java Jar.java
  Log:
  Use FileUtils instead of yet another touch method in <get>.
  
  cosmetics.
  
  Revision  Changes    Path
  1.14      +2 -0      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Exit.java
  
  Index: Exit.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Exit.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Exit.java	3 Mar 2002 01:46:20 -0000	1.13
  +++ Exit.java	11 Apr 2002 14:28:00 -0000	1.14
  @@ -64,6 +64,8 @@
    *
    * @author <a href="mailto:nico@seessle.de">Nico Seessle</a>
    *
  + * @since Ant 1.2
  + *
    * @ant.task name="fail" category="control"
    */
   public class Exit extends Task { 
  
  
  
  1.15      +9 -6      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Filter.java
  
  Index: Filter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Filter.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Filter.java	3 Mar 2002 01:46:20 -0000	1.14
  +++ Filter.java	11 Apr 2002 14:28:00 -0000	1.15
  @@ -54,11 +54,8 @@
   
   package org.apache.tools.ant.taskdefs;
   
  -
  -
   import java.io.File;
   
  -
   import org.apache.tools.ant.Task;
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Project;
  @@ -72,6 +69,8 @@
    * @author Gero Vermaas <a href="mailto:gero@xs4all.nl">gero@xs4all.nl</a>
    * @author <A href="gholam@xtra.co.nz">Michael McCallum</A>
    *
  + * @since Ant 1.1
  + *
    * @ant.task category="filesystem"
    */
   public class Filter extends Task {
  @@ -93,11 +92,15 @@
       }
   
       public void execute() throws BuildException {
  -        boolean isFiltersFromFile = filtersFile != null && token == null &&
value == null;
  -        boolean isSingleFilter = filtersFile == null && token != null &&
value != null;
  +        boolean isFiltersFromFile = 
  +            filtersFile != null && token == null && value == null;
  +        boolean isSingleFilter = 
  +            filtersFile == null && token != null && value != null;
           
           if (!isFiltersFromFile && !isSingleFilter) {
  -            throw new BuildException("both token and value parameters, or only a filtersFile
parameter is required", location);
  +            throw new BuildException("both token and value parameters, or "
  +                                     + "only a filtersFile parameter is "
  +                                     + "required", location);
           }
           
           if (isSingleFilter) {
  
  
  
  1.33      +21 -15    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
  
  Index: FixCRLF.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- FixCRLF.java	3 Mar 2002 01:46:20 -0000	1.32
  +++ FixCRLF.java	11 Apr 2002 14:28:00 -0000	1.33
  @@ -116,7 +116,8 @@
    *
    * @author Sam Ruby <a href="mailto:rubys@us.ibm.com">rubys@us.ibm.com</a>
    * @author <a href="mailto:pbwest@powerup.com.au">Peter B. West</a>
  - * @version $Revision: 1.32 $ $Name:  $
  + * @version $Revision: 1.33 $ $Name:  $
  + * @since Ant 1.1
    *
    * @ant.task category="filesystem"
    */
  @@ -309,7 +310,7 @@
       }
   
       /**
  -     * Specify how DOS EOF (control-z) charaters are to be handled
  +     * Specify how DOS EOF (control-z) characters are to be handled
        *
        * @param option valid values:
        * <ul>
  @@ -405,7 +406,8 @@
               try {
                   tmpFile = fileUtils.createTempFile("fixcrlf", "", destD);
                   Writer writer = (encoding == null) ? new FileWriter(tmpFile)
  -                    : new OutputStreamWriter(new FileOutputStream(tmpFile), encoding);
  +                    : new OutputStreamWriter(new FileOutputStream(tmpFile),
  +                                             encoding);
                   outWriter = new BufferedWriter(writer);
               } catch (IOException e) {
                   throw new BuildException(e);
  @@ -469,11 +471,13 @@
   
                           case IN_CHAR_CONST:
                           case IN_STR_CONST:
  -                            // Got here from LOOKING by finding an opening "\'"
  -                            // next points to that quote character.
  -                            // Find the end of the constant.  Watch out for
  -                            // backslashes.  Literal tabs are left unchanged, and
  -                            // the column is adjusted accordingly.
  +                            // Got here from LOOKING by finding an
  +                            // opening "\'" next points to that quote
  +                            // character.
  +                            // Find the end of the constant.  Watch
  +                            // out for backslashes.  Literal tabs are
  +                            // left unchanged, and the column is
  +                            // adjusted accordingly.
   
                               int begin = line.getNext();
                               char terminator = (lines.getState() == IN_STR_CONST
  @@ -482,10 +486,10 @@
                               endOfCharConst(line, terminator);
                               while (line.getNext() < line.getLookahead()) {
                                   if (line.getNextCharInc() == '\t') {
  -                                    line.setColumn(
  -                                                   line.getColumn() +
  +                                    line.setColumn(line.getColumn() +
                                                      tablength -
  -                                                   line.getColumn() % tablength);
  +                                                   (line.getColumn() 
  +                                                    % tablength));
                                   }
                                   else {
                                       line.incColumn();
  @@ -494,7 +498,8 @@
   
                               // Now output the substring
                               try {
  -                                outWriter.write(line.substring(begin, line.getNext()));
  +                                outWriter.write(line.substring(begin, 
  +                                                               line.getNext()));
                               } catch (IOException e) {
                                   throw new BuildException(e);
                               }
  @@ -541,15 +546,16 @@
               }
   
   
  -            File destFile = new File(destD, file);
  -
               try {
                   lines.close();
                   lines = null;
               }
               catch (IOException e) {
  -                throw new BuildException("Unable to close source file " + srcFile);
  +                throw new BuildException("Unable to close source file " 
  +                                         + srcFile);
               }
  +
  +            File destFile = new File(destD, file);
   
               if (destFile.exists()) {
                   // Compare the destination with the temp file
  
  
  
  1.13      +12 -7     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/GenerateKey.java
  
  Index: GenerateKey.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/GenerateKey.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- GenerateKey.java	3 Mar 2002 01:46:20 -0000	1.12
  +++ GenerateKey.java	11 Apr 2002 14:28:00 -0000	1.13
  @@ -65,6 +65,8 @@
    * 
    * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
    *
  + * @since Ant 1.2
  + *
    * @ant.task name="genkey" category="java"
    */
   public class GenerateKey extends Task {
  @@ -172,10 +174,12 @@
   
       public DistinguishedName createDname() throws BuildException {
           if( null != expandedDname ) {
  -            throw new BuildException( "DName sub-element can only be specified once." );
  +            throw new BuildException( "DName sub-element can only be "
  +                                      + "specified once." );
           }
           if( null != dname ) {
  -            throw new BuildException( "It is not possible to specify dname both " +
  +            throw new BuildException( "It is not possible to specify dname " +
  +                                      " both " +
                                         "as attribute and element." );
           }
           expandedDname = new DistinguishedName();
  @@ -184,11 +188,12 @@
     
       public void setDname(final String dname) {
           if( null != expandedDname ) {
  -            throw new BuildException( "It is not possible to specify dname both " +
  +            throw new BuildException( "It is not possible to specify dname " +
  +                                      " both " +
                                         "as attribute and element." );
           }
           this.dname = dname;
  -    } 
  +    }
   
       public void setAlias(final String alias) {
           this.alias = alias;
  @@ -240,9 +245,9 @@
   
       public void execute() throws BuildException {
           if (Project.getJavaVersion().equals(Project.JAVA_1_1)) {
  -            throw new BuildException( "The genkey task is only available on JDK" +
  -                                      " versions 1.2 or greater" );
  -        } 
  +            throw new BuildException( "The genkey task is only available on JDK"
  +                                      + " versions 1.2 or greater" );
  +        }
   
           if (null == alias) {
               throw new BuildException( "alias attribute must be set" );
  
  
  
  1.18      +46 -58    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Get.java
  
  Index: Get.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Get.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Get.java	3 Mar 2002 01:46:20 -0000	1.17
  +++ Get.java	11 Apr 2002 14:28:00 -0000	1.18
  @@ -62,9 +62,10 @@
   import java.net.URLConnection;
   import java.net.HttpURLConnection;
   import java.util.Date;
  -import org.apache.tools.ant.Task;
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Project;
  +import org.apache.tools.ant.Task;
  +import org.apache.tools.ant.util.FileUtils;
   
   /**
    * Get a particular file from a URL source.
  @@ -75,6 +76,8 @@
    * @author costin@dnt.ro
    * @author gg@grtmail.com (Added Java 1.1 style HTTP basic auth)
    *
  + * @since Ant 1.1
  + *
    * @ant.task category="network"
    */
   public class Get extends Task {
  @@ -143,7 +146,8 @@
                   // check to see if sun's Base64 encoder is available.
                   try {
                       sun.misc.BASE64Encoder encoder =
  -                        (sun.misc.BASE64Encoder) Class.forName("sun.misc.BASE64Encoder").newInstance();
  +                        (sun.misc.BASE64Encoder) 
  +                        Class.forName("sun.misc.BASE64Encoder").newInstance();
                       encoding = encoder.encode (up.getBytes());
   
                   }
  @@ -151,7 +155,8 @@
                       Base64Converter encoder = new Base64Converter();
                       encoding = encoder.encode(up.getBytes());
                   }
  -                connection.setRequestProperty ("Authorization", "Basic " + encoding);
  +                connection.setRequestProperty ("Authorization", 
  +                                               "Basic " + encoding);
               }
   
               //connect to the remote site (may take some time)
  @@ -159,24 +164,29 @@
               //next test for a 304 result (HTTP only)
               if(connection instanceof HttpURLConnection)  {
                   HttpURLConnection httpConnection=(HttpURLConnection)connection;
  -                if(httpConnection.getResponseCode()==HttpURLConnection.HTTP_NOT_MODIFIED)
 {
  -                    //not modified so no file download. just return instead
  -                    //and trace out something so the user doesn't think that the
  -                    //download happened when it didnt
  +                if(httpConnection.getResponseCode() 
  +                   == HttpURLConnection.HTTP_NOT_MODIFIED)  {
  +                    //not modified so no file download. just return
  +                    //instead and trace out something so the user
  +                    //doesn't think that the download happened when it
  +                    //didnt
                       log("Not modified - so not downloaded");
                       return;
                   }
                   // test for 401 result (HTTP only)
  -                if(httpConnection.getResponseCode()==HttpURLConnection.HTTP_UNAUTHORIZED)
 {
  +                if(httpConnection.getResponseCode()
  +                   == HttpURLConnection.HTTP_UNAUTHORIZED)  {
                       log("Not authorized - check " + dest + " for details");
                       return;
                   }
   
               }
   
  -            //REVISIT: at this point even non HTTP connections may support the if-modified-since
  -            //behaviour -we just check the date of the content and skip the write if it
is not
  -            //newer. Some protocols (FTP) dont include dates, of course.
  +            //REVISIT: at this point even non HTTP connections may
  +            //support the if-modified-since behaviour -we just check
  +            //the date of the content and skip the write if it is not
  +            //newer. Some protocols (FTP) dont include dates, of
  +            //course.
   
               FileOutputStream fos = new FileOutputStream(dest);
   
  @@ -204,26 +214,30 @@
               while ((length = is.read(buffer)) >= 0) {
                   fos.write(buffer, 0, length);
                   if (verbose) {
  -                  System.out.print(".");
  +                    System.out.print(".");
                   }
               }
               if(verbose) {
  -              System.out.println();
  +                System.out.println();
               }
               fos.close();
               is.close();
   
  -            //if (and only if) the use file time option is set, then the
  -            //saved file now has its timestamp set to that of the downloaded file
  +            //if (and only if) the use file time option is set, then
  +            //the saved file now has its timestamp set to that of the
  +            //downloaded file
               if(useTimestamp)  {
                   long remoteTimestamp=connection.getLastModified();
                   if (verbose)  {
                       Date t=new Date(remoteTimestamp);
                       log("last modified = "+t.toString()
  -                        +((remoteTimestamp==0)?" - using current time instead":""));
  +                        +((remoteTimestamp==0) 
  +                          ? " - using current time instead"
  +                          : ""));
                   }
                   if(remoteTimestamp!=0) {
  -                    touchFile(dest,remoteTimestamp);
  +                    FileUtils.newFileUtils()
  +                        .setFileLastModified(dest, remoteTimestamp);
                   }
               }
           } catch (IOException ioe) {
  @@ -236,34 +250,6 @@
       }
   
       /**
  -     * set the timestamp of a named file to a specified time.
  -     *
  -     * @param filename
  -     * @param time in milliseconds since the start of the era
  -     * @return true if it succeeded. False means that this is a
  -     * java1.1 system and that file times can not be set
  -     *@exception BuildException Thrown in unrecoverable error. Likely
  -     *this comes from file access failures.
  -     */
  -    protected boolean touchFile(File file, long timemillis)
  -        throws BuildException  {
  -
  -        if (Project.getJavaVersion() != Project.JAVA_1_1) {
  -            Touch touch = (Touch) project.createTask("touch");
  -            touch.setOwningTarget(target);
  -            touch.setTaskName(getTaskName());
  -            touch.setLocation(getLocation());
  -            touch.setFile(file);
  -            touch.setMillis(timemillis);
  -            touch.touch();
  -            return true;
  -
  -        } else {
  -            return false;
  -        }
  -    }
  -
  -    /**
        * Set the URL.
        *
        * @param u URL for the file.
  @@ -302,16 +288,18 @@
       /**
        * Use timestamps, if set to "<CODE>true</CODE>".
        *
  -     * <p>In this situation, the if-modified-since header is set so that the file
is
  -     * only fetched if it is newer than the local file (or there is no local file)
  -     * This flag is only valid on HTTP connections, it is ignored in other cases.
  -     * When the flag is set, the local copy of the downloaded file will also
  -     * have its timestamp set to the remote file time.
  -     * <br>
  -     * Note that remote files of date 1/1/1970 (GMT) are treated as 'no timestamp', and
  -     * web servers often serve files with a timestamp in the future by replacing their
timestamp
  -     * with that of the current time. Also, inter-computer clock differences can cause
no end of
  -     * grief.
  +     * <p>In this situation, the if-modified-since header is set so
  +     * that the file is only fetched if it is newer than the local
  +     * file (or there is no local file) This flag is only valid on
  +     * HTTP connections, it is ignored in other cases.  When the flag
  +     * is set, the local copy of the downloaded file will also have
  +     * its timestamp set to the remote file time.</p>
  +     * 
  +     * <p>Note that remote files of date 1/1/1970 (GMT) are treated as
  +     * 'no timestamp', and web servers often serve files with a
  +     * timestamp in the future by replacing their timestamp with that
  +     * of the current time. Also, inter-computer clock differences can
  +     * cause no end of grief.</p>
        * @param v "true" to enable file time fetching
        */
       public void setUseTimestamp(boolean v) {
  @@ -327,7 +315,7 @@
        * @param u username for authentication
        */
       public void setUsername(String u) {
  -      this.uname = u;
  +        this.uname = u;
       }
   
       /**
  @@ -336,7 +324,7 @@
        * @param p password for authentication
        */
       public void setPassword(String p) {
  -      this.pword = p;
  +        this.pword = p;
       }
   
       /*********************************************************************
  @@ -346,7 +334,7 @@
       *
       * @author
       *    Unknown
  -    *  @author
  +    * @author
       *    <a HREF="gg@grtmail.com">Gautam Guliani</a>
       *********************************************************************/
   
  
  
  
  1.46      +0 -1      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Jar.java
  
  Index: Jar.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Jar.java,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- Jar.java	11 Apr 2002 13:22:16 -0000	1.45
  +++ Jar.java	11 Apr 2002 14:28:00 -0000	1.46
  @@ -59,7 +59,6 @@
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.types.ZipFileSet;
   import org.apache.tools.ant.types.EnumeratedAttribute;
  -import org.apache.tools.ant.util.StringUtils;
   import org.apache.tools.zip.ZipOutputStream;
   
   import java.io.IOException;
  
  
  

--
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