Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 78694 invoked from network); 17 Sep 2007 11:14:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Sep 2007 11:14:16 -0000 Received: (qmail 81022 invoked by uid 500); 17 Sep 2007 11:14:08 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 80964 invoked by uid 500); 17 Sep 2007 11:14:08 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 80953 invoked by uid 500); 17 Sep 2007 11:14:08 -0000 Received: (qmail 80950 invoked by uid 99); 17 Sep 2007 11:14:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Sep 2007 04:14:08 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Sep 2007 11:16:04 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7EA861A9832; Mon, 17 Sep 2007 04:13:51 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r576370 - in /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs: BUnzip2.java Checksum.java ExecTask.java Execute.java Expand.java GUnzip.java Get.java Pack.java Date: Mon, 17 Sep 2007 11:13:49 -0000 To: ant-cvs@apache.org From: peterreilly@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070917111351.7EA861A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: peterreilly Date: Mon Sep 17 04:13:48 2007 New Revision: 576370 URL: http://svn.apache.org/viewvc?rev=576370&view=rev Log: magic numbers Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecTask.java ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Expand.java ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/GUnzip.java ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Pack.java Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java?rev=576370&r1=576369&r2=576370&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java Mon Sep 17 04:13:48 2007 @@ -39,6 +39,8 @@ public class BUnzip2 extends Unpack { + private static final int BUFFER_SIZE = 8 * 1024; + private static final String DEFAULT_EXTENSION = ".bz2"; /** @@ -74,7 +76,7 @@ throw new BuildException("Invalid bz2 file.", getLocation()); } zIn = new CBZip2InputStream(bis); - byte[] buffer = new byte[8 * 1024]; + byte[] buffer = new byte[BUFFER_SIZE]; int count = 0; do { out.write(buffer, 0, count); Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java?rev=576370&r1=576369&r2=576370&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java Mon Sep 17 04:13:48 2007 @@ -58,6 +58,12 @@ * @ant.task category="control" */ public class Checksum extends MatchingTask implements Condition { + + private static final int NIBBLE = 4; + private static final int WORD = 16; + private static final int BUFFER_SIZE = 8 * 1024; + private static final int BYTE_MASK = 0xFF; + private static class FileUnion extends Restrict { private Union u; FileUnion() { @@ -144,7 +150,7 @@ /** * Size of the read buffer to use. */ - private int readBufferSize = 8 * 1024; + private int readBufferSize = BUFFER_SIZE; /** * Formater for the checksum file. @@ -572,7 +578,7 @@ private String createDigestString(byte[] fileDigest) { StringBuffer checksumSb = new StringBuffer(); for (int i = 0; i < fileDigest.length; i++) { - String hexStr = Integer.toHexString(0x00ff & fileDigest[i]); + String hexStr = Integer.toHexString(BYTE_MASK & fileDigest[i]); if (hexStr.length() < 2) { checksumSb.append("0"); } @@ -604,9 +610,9 @@ // two characters form the hex value. for (int i = 0, j = 0; j < l; i++) { - int f = Character.digit(data[j++], 16) << 4; - f = f | Character.digit(data[j++], 16); - out[i] = (byte) (f & 0xFF); + int f = Character.digit(data[j++], WORD) << NIBBLE; + f = f | Character.digit(data[j++], WORD); + out[i] = (byte) (f & BYTE_MASK); } return out; Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecTask.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecTask.java?rev=576370&r1=576369&r2=576370&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecTask.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecTask.java Mon Sep 17 04:13:48 2007 @@ -43,13 +43,13 @@ */ public class ExecTask extends Task { - // CheckStyle:VisibilityModifier OFF - bc private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); private String os; private String osFamily; private File dir; + // CheckStyle:VisibilityModifier OFF - bc protected boolean failOnError = false; protected boolean newEnvironment = false; private Long timeout = null; @@ -433,7 +433,7 @@ if (environment != null) { for (int i = 0; i < environment.length; i++) { if (isPath(environment[i])) { - p = new Path(getProject(), environment[i].substring(5)); + p = new Path(getProject(), getPath(environment[i])); break; } } @@ -444,7 +444,7 @@ while (e.hasMoreElements()) { String line = (String) e.nextElement(); if (isPath(line)) { - p = new Path(getProject(), line.substring(5)); + p = new Path(getProject(), getPath(line)); break; } } @@ -703,7 +703,11 @@ } private boolean isPath(String line) { - return line.startsWith("PATH=") || line.startsWith("Path="); + return line.startsWith("PATH=") + || line.startsWith("Path="); } + private String getPath(String line) { + return line.substring("PATH=".length()); + } } Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java?rev=576370&r1=576369&r2=576370&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java Mon Sep 17 04:13:48 2007 @@ -49,6 +49,8 @@ */ public class Execute { + private static final int ONE_SECOND = 1000; + /** Invalid exit code. * set to {@link Integer#MAX_VALUE} */ @@ -518,7 +520,7 @@ useVMLauncher); if (Os.isFamily("windows")) { try { - Thread.sleep(1000); + Thread.sleep(ONE_SECOND); } catch (InterruptedException e) { project.log("interruption in the sleep after having spawned a" + " process", Project.MSG_VERBOSE); @@ -911,6 +913,7 @@ final int preCmdLength = 7; final String cmdDir = commandDir.getAbsolutePath(); String[] newcmd = new String[cmd.length + preCmdLength]; + // CheckStyle:MagicNumber OFF - do not bother newcmd[0] = "cmd"; newcmd[1] = "/c"; newcmd[2] = cmdDir.substring(0, 2); @@ -918,6 +921,7 @@ newcmd[4] = "cd"; newcmd[5] = cmdDir.substring(2); newcmd[6] = "&&"; + // CheckStyle:MagicNumber ON System.arraycopy(cmd, 0, newcmd, preCmdLength, cmd.length); return exec(project, newcmd, env); @@ -959,12 +963,14 @@ // the command final int preCmdLength = 6; String[] newcmd = new String[cmd.length + preCmdLength]; + // CheckStyle:MagicNumber OFF - do not bother newcmd[0] = "cmd"; newcmd[1] = "/c"; newcmd[2] = "cd"; newcmd[3] = "/d"; newcmd[4] = commandDir.getAbsolutePath(); newcmd[5] = "&&"; + // CheckStyle:MagicNumber ON System.arraycopy(cmd, 0, newcmd, preCmdLength, cmd.length); return exec(project, newcmd, env); Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Expand.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Expand.java?rev=576370&r1=576369&r2=576370&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Expand.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Expand.java Mon Sep 17 04:13:48 2007 @@ -58,6 +58,7 @@ * name="unwar" */ public class Expand extends Task { + private static final int BUFFER_SIZE = 1024; private File dest; //req private File source; // req private boolean overwrite = true; @@ -275,7 +276,7 @@ if (isDirectory) { f.mkdirs(); } else { - byte[] buffer = new byte[1024]; + byte[] buffer = new byte[BUFFER_SIZE]; int length = 0; FileOutputStream fos = null; try { Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/GUnzip.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/GUnzip.java?rev=576370&r1=576369&r2=576370&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/GUnzip.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/GUnzip.java Mon Sep 17 04:13:48 2007 @@ -36,7 +36,7 @@ */ public class GUnzip extends Unpack { - + private static final int BUFFER_SIZE = 8 * 1024; private static final String DEFAULT_EXTENSION = ".gz"; /** @@ -62,7 +62,7 @@ out = new FileOutputStream(dest); fis = srcResource.getInputStream(); zIn = new GZIPInputStream(fis); - byte[] buffer = new byte[8 * 1024]; + byte[] buffer = new byte[BUFFER_SIZE]; int count = 0; do { out.write(buffer, 0, count); Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java?rev=576370&r1=576369&r2=576370&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java Mon Sep 17 04:13:48 2007 @@ -44,7 +44,7 @@ * @ant.task category="network" */ public class Get extends Task { - + private static final int BIG_BUFFER_SIZE = 100 * 1024; private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); private URL source; // required @@ -202,7 +202,7 @@ progress.beginDownload(); boolean finished = false; try { - byte[] buffer = new byte[100 * 1024]; + byte[] buffer = new byte[BIG_BUFFER_SIZE]; int length; while ((length = is.read(buffer)) >= 0) { fos.write(buffer, 0, length); Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Pack.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Pack.java?rev=576370&r1=576369&r2=576370&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Pack.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Pack.java Mon Sep 17 04:13:48 2007 @@ -35,7 +35,7 @@ */ public abstract class Pack extends Task { - + private static final int BUFFER_SIZE = 8 * 1024; // CheckStyle:VisibilityModifier OFF - bc protected File zipFile; protected File source; @@ -148,7 +148,7 @@ */ private void zipFile(InputStream in, OutputStream zOut) throws IOException { - byte[] buffer = new byte[8 * 1024]; + byte[] buffer = new byte[BUFFER_SIZE]; int count = 0; do { zOut.write(buffer, 0, count); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org