ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject svn commit: r575635 - in /ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant: filters/FixCrLfFilter.java taskdefs/Truncate.java taskdefs/WaitFor.java
Date Fri, 14 Sep 2007 11:39:46 GMT
Author: peterreilly
Date: Fri Sep 14 04:39:45 2007
New Revision: 575635

URL: http://svn.apache.org/viewvc?rev=575635&view=rev
Log:
sync magic numbers

Modified:
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/filters/FixCrLfFilter.java
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Truncate.java
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/WaitFor.java

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/filters/FixCrLfFilter.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/filters/FixCrLfFilter.java?rev=575635&r1=575634&r2=575635&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/filters/FixCrLfFilter.java
(original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/filters/FixCrLfFilter.java
Fri Sep 14 04:39:45 2007
@@ -70,9 +70,12 @@
  *
  */
 public final class FixCrLfFilter extends BaseParamFilterReader implements ChainableReader
{
+    private static final int DEFAULT_TAB_LENGTH = 8;
+    private static final int MIN_TAB_LENGTH = 2;
+    private static final int MAX_TAB_LENGTH = 80;
     private static final char CTRLZ = '\u001A';
 
-    private int tabLength = 8;
+    private int tabLength = DEFAULT_TAB_LENGTH;
 
     private CrLf eol;
 
@@ -376,8 +379,11 @@
      * @throws IOException on error.
      */
     public void setTablength(int tabLength) throws IOException {
-        if (tabLength < 2 || tabLength > 80) {
-            throw new IOException("tablength must be between 2 and 80");
+        if (tabLength < MIN_TAB_LENGTH
+            || tabLength > MAX_TAB_LENGTH) {
+            throw new IOException(
+                "tablength must be between " + MIN_TAB_LENGTH
+                + " and " + MAX_TAB_LENGTH);
         }
         this.tabLength = tabLength;
     }
@@ -393,9 +399,10 @@
      * </P>
      */
     private static class SimpleFilterReader extends Reader {
+        private static int PREEMPT_BUFFER_LENGTH = 16;
         private Reader in;
 
-        private int[] preempt = new int[16];
+        private int[] preempt = new int[PREEMPT_BUFFER_LENGTH];
 
         private int preemptIndex = 0;
 

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Truncate.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Truncate.java?rev=575635&r1=575634&r2=575635&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Truncate.java (original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Truncate.java Fri
Sep 14 04:39:45 2007
@@ -37,6 +37,8 @@
  */
 public class Truncate extends Task {
 
+    private static final int BUFFER_SIZE = 1024;
+
     private static final Long ZERO = new Long(0L);
 
     private static final String NO_CHILD = "No files specified.";
@@ -47,7 +49,7 @@
 
     private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
 
-    private static final byte[] FILL_BUFFER = new byte[1024];
+    private static final byte[] FILL_BUFFER = new byte[BUFFER_SIZE];
 
     private Path path;
     private boolean create = true;

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/WaitFor.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/WaitFor.java?rev=575635&r1=575634&r2=575635&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/WaitFor.java (original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/WaitFor.java Fri
Sep 14 04:39:45 2007
@@ -52,10 +52,19 @@
  * @ant.task category="control"
  */
 public class WaitFor extends ConditionBase {
+    private static final long ONE_SECOND = 1000L;
+    private static final long ONE_MINUTE = ONE_SECOND * 60L;
+    private static final long ONE_HOUR   = ONE_MINUTE * 60L;
+    private static final long ONE_DAY    = ONE_HOUR * 24L;
+    private static final long ONE_WEEK   = ONE_DAY * 7L;
+
+    private static final long DEFAULT_MAX_WAIT_MILLIS = ONE_MINUTE * 3L;
+    private static final long DEFAULT_CHECK_MILLIS = 500L;
+
     /** default max wait time */
-    private long maxWaitMillis = 1000L * 60L * 3L;
+    private long maxWaitMillis = DEFAULT_MAX_WAIT_MILLIS;
     private long maxWaitMultiplier = 1L;
-    private long checkEveryMillis = 500L;
+    private long checkEveryMillis = DEFAULT_CHECK_MILLIS;
     private long checkEveryMultiplier = 1L;
     private String timeoutProperty;
 
@@ -201,11 +210,11 @@
         /** Constructor the Unit enumerated type. */
         public Unit() {
             timeTable.put(MILLISECOND, new Long(1L));
-            timeTable.put(SECOND,      new Long(1000L));
-            timeTable.put(MINUTE,      new Long(1000L * 60L));
-            timeTable.put(HOUR,        new Long(1000L * 60L * 60L));
-            timeTable.put(DAY,         new Long(1000L * 60L * 60L * 24L));
-            timeTable.put(WEEK,        new Long(1000L * 60L * 60L * 24L * 7L));
+            timeTable.put(SECOND,      new Long(ONE_SECOND));
+            timeTable.put(MINUTE,      new Long(ONE_MINUTE));
+            timeTable.put(HOUR,        new Long(ONE_HOUR));
+            timeTable.put(DAY,         new Long(ONE_DAY));
+            timeTable.put(WEEK,        new Long(ONE_WEEK));
         }
 
         /**



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


Mime
View raw message