ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/image Image.java
Date Fri, 13 Sep 2002 13:28:12 GMT
ehatcher    2002/09/13 06:28:11

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/image
                        Image.java
  Log:
  IDEA reformat, and changed destdir to be File type
  
  Revision  Changes    Path
  1.4       +51 -53    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/image/Image.java
  
  Index: Image.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/image/Image.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Image.java	29 Aug 2002 17:13:33 -0000	1.3
  +++ Image.java	13 Sep 2002 13:28:11 -0000	1.4
  @@ -69,9 +69,9 @@
   import java.io.File;
   import java.io.FileOutputStream;
   import java.io.IOException;
  -import java.util.Vector;
   import java.util.ArrayList;
   import java.util.Iterator;
  +import java.util.Vector;
   
   /**
    * A MatchingTask which relies on <A HREF="http://java.sun.com/products/java-media/jai">JAI
(Java Advanced Imaging)</A>
  @@ -98,7 +98,7 @@
       protected File srcDir = null;
       protected File destDir = null;
   
  -   /**
  +    /**
        * Adds a set of files to be deleted.
        */
       public void addFileset(FileSet set) {
  @@ -109,9 +109,9 @@
        * If false, note errors to the output but keep going.
        * @param failonerror true or false
        */
  -     public void setFailOnError(boolean failonerror) {
  -         this.failonerror = failonerror;
  -     }
  +    public void setFailOnError(boolean failonerror) {
  +        this.failonerror = failonerror;
  +    }
   
       /**
        * Set the source dir to find the image files.
  @@ -131,14 +131,14 @@
        *  Sets whether or not to overwrite a file if there is a naming conflict.
        */
       public void setOverwrite(boolean overwrite) {
  -            this.overwrite = overwrite;
  +        this.overwrite = overwrite;
       }
   
       /**
        *  Enables Garbage Collection after each image processed.  Defaults to false.
        */
       public void setGc(boolean gc) {
  -            garbage_collect = gc;
  +        garbage_collect = gc;
       }
   
   
  @@ -146,8 +146,8 @@
        * Sets the destination directory for manipulated images.
        * @param destination The destination directory
        */
  -    public void setDestDir(String destination) {
  -        destDir = new File(destination);
  +    public void setDestDir(File destDir) {
  +        this.destDir = destDir;
       }
   
       /**
  @@ -213,8 +213,8 @@
                   str_encoding = "TIFF";
               }
   
  -            if (destDir == null){
  -              destDir = srcDir;
  +            if (destDir == null) {
  +                destDir = srcDir;
               }
   
               File new_file = new File(destDir.getAbsolutePath() + File.separator + file.getName());
  @@ -231,19 +231,17 @@
   
   
           } catch (IOException err) {
  -           if (!failonerror) {
  -             log("Error processing file:  " + err);
  -           } else {
  -             throw new BuildException(err);
  -           }
  -        }
  -
  -        catch (java.lang.RuntimeException rerr) {
  -           if (!failonerror) {
  -             log("Error processing file:  " + rerr);
  -           } else {
  -             throw new BuildException(rerr);
  -           }
  +            if (!failonerror) {
  +                log("Error processing file:  " + err);
  +            } else {
  +                throw new BuildException(err);
  +            }
  +        } catch (java.lang.RuntimeException rerr) {
  +            if (!failonerror) {
  +                log("Error processing file:  " + rerr);
  +            } else {
  +                throw new BuildException(rerr);
  +            }
           }
   
       }
  @@ -251,58 +249,58 @@
       /**
        * Executes the Task
        */
  -    public void execute() {
  +    public void execute() throws BuildException {
   
           validateAttributes();
   
           try {
               DirectoryScanner ds = null;
  -            String [] files =null;
  +            String[] files = null;
               ArrayList filesList = new ArrayList();
   
   
               // deal with specified srcDir
  -            if (srcDir != null){
  -              ds = super.getDirectoryScanner(srcDir);
  +            if (srcDir != null) {
  +                ds = super.getDirectoryScanner(srcDir);
   
  -              files = ds.getIncludedFiles();
  -              for (int i = 0; i < files.length; i++){
  -                filesList.add(new File(srcDir.getAbsolutePath() + File.separator + files[i]));
  -              }
  +                files = ds.getIncludedFiles();
  +                for (int i = 0; i < files.length; i++) {
  +                    filesList.add(new File(srcDir.getAbsolutePath() + File.separator +
files[i]));
  +                }
               }
               // deal with the filesets
               for (int i = 0; i < filesets.size(); i++) {
                   FileSet fs = (FileSet) filesets.elementAt(i);
                   ds = fs.getDirectoryScanner(getProject());
  -                files =ds.getIncludedFiles();
  +                files = ds.getIncludedFiles();
                   File fromDir = fs.getDir(getProject());
  -                for (int j = 0; j < files.length; j++){
  -                  filesList.add(new File(fromDir.getAbsolutePath() + File.separator + files[j]));
  +                for (int j = 0; j < files.length; j++) {
  +                    filesList.add(new File(fromDir.getAbsolutePath() + File.separator +
files[j]));
                   }
               }
   
  -            if (!overwrite){
  -             // remove any files that shouldn't be overwritten.
  -             ArrayList filesToRemove = new ArrayList();
  -             for(Iterator i = filesList.iterator();i.hasNext();){
  -               File f = (File)i.next();
  -               File new_file = new File(destDir.getAbsolutePath() + File.separator + f.getName());
  -               if (new_file.exists()){
  -                 filesToRemove.add(f);
  -               }
  -             }
  -             filesList.removeAll(filesToRemove);
  +            if (!overwrite) {
  +                // remove any files that shouldn't be overwritten.
  +                ArrayList filesToRemove = new ArrayList();
  +                for (Iterator i = filesList.iterator(); i.hasNext();) {
  +                    File f = (File) i.next();
  +                    File new_file = new File(destDir.getAbsolutePath() + File.separator
+ f.getName());
  +                    if (new_file.exists()) {
  +                        filesToRemove.add(f);
  +                    }
  +                }
  +                filesList.removeAll(filesToRemove);
               }
   
   
               // iterator through all the files and process them.
  -            for (Iterator i = filesList.iterator();i.hasNext();){
  -              File file = (File)i.next();
  +            for (Iterator i = filesList.iterator(); i.hasNext();) {
  +                File file = (File) i.next();
   
  -              processFile(file);
  -              if (garbage_collect) {
  -                  System.gc();
  -              }
  +                processFile(file);
  +                if (garbage_collect) {
  +                    System.gc();
  +                }
               }
   
   
  @@ -321,7 +319,7 @@
       protected void validateAttributes() throws BuildException {
           if (srcDir == null && filesets.size() == 0) {
               throw new BuildException("Specify at least one source "
  -                                     + "- a srcDir or a fileset.");
  +                    + "- a srcDir or a fileset.");
           }
   
           if (srcDir == null && destDir == 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