You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2011/10/12 10:19:11 UTC

svn commit: r1182254 - /ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Pack200Normalize.java

Author: bodewig
Date: Wed Oct 12 08:19:10 2011
New Revision: 1182254

URL: http://svn.apache.org/viewvc?rev=1182254&view=rev
Log:
refactor

Modified:
    ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Pack200Normalize.java

Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Pack200Normalize.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Pack200Normalize.java?rev=1182254&r1=1182253&r2=1182254&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Pack200Normalize.java (original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Pack200Normalize.java Wed Oct 12 08:19:10 2011
@@ -82,6 +82,19 @@ public class Pack200Normalize extends Ta
     }
 
     public void execute() {
+        validate();
+        if (isOutOfDate()) {
+            normalize();
+        } else if (dest != null) {
+            log(src + " not normalized as " + dest + " is up-to-date.",
+                Project.MSG_VERBOSE);
+        } else {
+            log(src + " not normalized as force attribute is false.",
+                Project.MSG_VERBOSE);
+        }
+    }
+
+    private void validate() {
         if (src == null) {
             throw new BuildException("srcFile attribute is required");
         }
@@ -94,32 +107,29 @@ public class Pack200Normalize extends Ta
         if (dest != null && dest.isDirectory()) {
             throw new BuildException(dest + " must be a file");
         }
-        if (force ||
+    }
+
+    private boolean isOutOfDate() {
+        return force ||
             (dest != null
              && SelectorUtils.isOutOfDate(new FileResource(src),
                                           new FileResource(dest),
                                           FileUtils.getFileUtils()
                                           .getFileTimestampGranularity())
-             )
-            ) {
-            if (dest != null) {
-                log("Normalizing " + src + " to " + dest + ".");
-            } else {
-                log("Normalizing " + src + ".");
-            }
-            try {
-                Pack200Utils.normalize(src, dest != null ? dest : src,
-                                       properties);
-            } catch (IOException ex) {
-                throw new BuildException("Caught an error normalizing "
-                                         + src, ex);
-            }
-        } else if (dest != null) {
-            log(src + " not normalized as " + dest + " is up-to-date.",
-                Project.MSG_VERBOSE);
+             );
+    }
+
+    private void normalize() {
+        if (dest != null) {
+            log("Normalizing " + src + " to " + dest + ".");
         } else {
-            log(src + " not normalized as force attribute is false.",
-                Project.MSG_VERBOSE);
+            log("Normalizing " + src + ".");
+        }
+        try {
+            Pack200Utils.normalize(src, dest != null ? dest : src, properties);
+        } catch (IOException ex) {
+            throw new BuildException("Caught an error normalizing "
+                                     + src, ex);
         }
     }
 }
\ No newline at end of file