Author: peterreilly Date: Tue Sep 25 07:50:09 2007 New Revision: 579278 URL: http://svn.apache.org/viewvc?rev=579278&view=rev Log: magic number
Modified: ant/core/trunk/src/main/org/apache/tools/mail/SmtpResponseReader.java ant/core/trunk/src/main/org/apache/tools/tar/TarInputStream.java ant/core/trunk/src/main/org/apache/tools/tar/TarUtils.java ant/core/trunk/src/main/org/apache/tools/zip/AsiExtraField.java ant/core/trunk/src/main/org/apache/tools/zip/ZipOutputStream.java Modified: ant/core/trunk/src/main/org/apache/tools/mail/SmtpResponseReader.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/mail/SmtpResponseReader.java?rev=579278&r1=579277&r2=579278&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/mail/SmtpResponseReader.java (original) +++ ant/core/trunk/src/main/org/apache/tools/mail/SmtpResponseReader.java Tue Sep 25 07:50:09 2007 @@ -56,10 +56,12 @@ public String getResponse() throws IOException { result.setLength(0); String line = reader.readLine(); + // CheckStyle:MagicNumber OFF if (line != null && line.length() >= 3) { result.append(line.substring(0, 3)); result.append(" "); } + // CheckStyle:MagicNumber ON while (line != null) { append(line); @@ -85,16 +87,20 @@ * @return true if there are more lines to check. */ protected boolean hasMoreLines(String line) { + // CheckStyle:MagicNumber OFF return line.length() > 3 && line.charAt(3) == '-'; + // CheckStyle:MagicNumber ON } /** * Append the text from this line of the resonse. */ private void append(String line) { + // CheckStyle:MagicNumber OFF if (line.length() > 4) { result.append(line.substring(4)); result.append(" "); } + // CheckStyle:MagicNumber ON } } Modified: ant/core/trunk/src/main/org/apache/tools/tar/TarInputStream.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/tar/TarInputStream.java?rev=579278&r1=579277&r2=579278&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/tar/TarInputStream.java (original) +++ ant/core/trunk/src/main/org/apache/tools/tar/TarInputStream.java Tue Sep 25 07:50:09 2007 @@ -36,7 +36,9 @@ * */ public class TarInputStream extends FilterInputStream { + private static final int SMALL_BUFFER_SIZE = 256; private static final int BUFFER_SIZE = 8 * 1024; + private static final int LARGE_BUFFER_SIZE = 32 * 1024; private static final int BYTE_MASK = 0xFF; // CheckStyle:VisibilityModifier OFF - bc @@ -257,7 +259,7 @@ if (this.currEntry != null && this.currEntry.isGNULongNameEntry()) { // read in the name StringBuffer longName = new StringBuffer(); - byte[] buf = new byte[256]; + byte[] buf = new byte[SMALL_BUFFER_SIZE]; int length = 0; while ((length = read(buf)) >= 0) { longName.append(new String(buf, 0, length)); @@ -380,7 +382,7 @@ * @throws IOException on error */ public void copyEntryContents(OutputStream out) throws IOException { - byte[] buf = new byte[32 * 1024]; + byte[] buf = new byte[LARGE_BUFFER_SIZE]; while (true) { int numRead = this.read(buf, 0, buf.length); Modified: ant/core/trunk/src/main/org/apache/tools/tar/TarUtils.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/tar/TarUtils.java?rev=579278&r1=579277&r2=579278&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/tar/TarUtils.java (original) +++ ant/core/trunk/src/main/org/apache/tools/tar/TarUtils.java Tue Sep 25 07:50:09 2007 @@ -30,6 +30,8 @@ // CheckStyle:HideUtilityClassConstructorCheck OFF (bc) public class TarUtils { + private static final int BYTE_MASK = 255; + /** * Parse an octal string from a header buffer. This is used for the * file permission mode value. @@ -60,7 +62,9 @@ } stillPadding = false; + // CheckStyle:MagicNumber OFF result = (result << 3) + (header[i] - '0'); + // CheckStyle:MagicNumber ON } return result; @@ -134,8 +138,10 @@ --idx; } else { for (long val = value; idx >= 0 && val > 0; --idx) { + // CheckStyle:MagicNumber OFF buf[offset + idx] = (byte) ((byte) '0' + (byte) (val & 7)); val = val >> 3; + // CheckStyle:MagicNumber ON } } @@ -192,7 +198,7 @@ long sum = 0; for (int i = 0; i < buf.length; ++i) { - sum += 255 & buf[i]; + sum += BYTE_MASK & buf[i]; } return sum; Modified: ant/core/trunk/src/main/org/apache/tools/zip/AsiExtraField.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/AsiExtraField.java?rev=579278&r1=579277&r2=579278&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/zip/AsiExtraField.java (original) +++ ant/core/trunk/src/main/org/apache/tools/zip/AsiExtraField.java Tue Sep 25 07:50:09 2007 @@ -139,6 +139,7 @@ System.arraycopy(ZipShort.getBytes(getMode()), 0, data, 0, 2); byte[] linkArray = getLinkedFile().getBytes(); + // CheckStyle:MagicNumber OFF System.arraycopy(ZipLong.getBytes(linkArray.length), 0, data, 2, WORD); @@ -148,6 +149,7 @@ 0, data, 8, 2); System.arraycopy(linkArray, 0, data, 10, linkArray.length); + // CheckStyle:MagicNumber ON crc.reset(); crc.update(data); @@ -300,6 +302,7 @@ } int newMode = ZipShort.getValue(tmp, 0); + // CheckStyle:MagicNumber OFF byte[] linkArray = new byte[(int) ZipLong.getValue(tmp, 2)]; uid = ZipShort.getValue(tmp, 6); gid = ZipShort.getValue(tmp, 8); @@ -310,6 +313,7 @@ System.arraycopy(tmp, 10, linkArray, 0, linkArray.length); link = new String(linkArray); } + // CheckStyle:MagicNumber ON setDirectory((newMode & DIR_FLAG) != 0); setMode(newMode); } Modified: ant/core/trunk/src/main/org/apache/tools/zip/ZipOutputStream.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/ZipOutputStream.java?rev=579278&r1=579277&r2=579278&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/zip/ZipOutputStream.java (original) +++ ant/core/trunk/src/main/org/apache/tools/zip/ZipOutputStream.java Tue Sep 25 07:50:09 2007 @@ -599,6 +599,7 @@ // version needed to extract // general purpose bit flag + // CheckStyle:MagicNumber OFF if (zipMethod == DEFLATED && raf == null) { // requires version 2 as we are going to store length info // in the data descriptor @@ -610,6 +611,7 @@ writeOut(ZipShort.getBytes(10)); writeOut(ZERO); } + // CheckStyle:MagicNumber ON written += WORD; // compression method @@ -633,7 +635,9 @@ writeOut(ZipLong.getBytes(ze.getSize())); writeOut(ZipLong.getBytes(ze.getSize())); } + // CheckStyle:MagicNumber OFF written += 12; + // CheckStyle:MagicNumber ON // file name length byte[] name = getBytes(ze.getName()); @@ -671,7 +675,9 @@ writeOut(ZipLong.getBytes(entry.getCrc())); writeOut(ZipLong.getBytes(entry.getCompressedSize())); writeOut(ZipLong.getBytes(entry.getSize())); + // CheckStyle:MagicNumber OFF written += 16; + // CheckStyle:MagicNumber ON } /** @@ -686,6 +692,7 @@ written += WORD; // version made by + // CheckStyle:MagicNumber OFF writeOut(ZipShort.getBytes((ze.getPlatform() << 8) | 20)); written += SHORT; @@ -702,6 +709,7 @@ writeOut(ZipShort.getBytes(10)); writeOut(ZERO); } + // CheckStyle:MagicNumber ON written += WORD; // compression method @@ -718,7 +726,9 @@ writeOut(ZipLong.getBytes(ze.getCrc())); writeOut(ZipLong.getBytes(ze.getCompressedSize())); writeOut(ZipLong.getBytes(ze.getSize())); + // CheckStyle:MagicNumber OFF written += 12; + // CheckStyle:MagicNumber ON // file name length byte[] name = getBytes(ze.getName()); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]