git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@579278 13f79535-47bb-0310-9956-ffa450edef68master
@@ -56,10 +56,12 @@ public class SmtpResponseReader { | |||
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 @@ public class SmtpResponseReader { | |||
* @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 | |||
} | |||
} |
@@ -36,7 +36,9 @@ import java.io.OutputStream; | |||
* | |||
*/ | |||
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 @@ public class TarInputStream extends FilterInputStream { | |||
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 @@ public class TarInputStream extends FilterInputStream { | |||
* @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); | |||
@@ -30,6 +30,8 @@ package org.apache.tools.tar; | |||
// 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 @@ public class TarUtils { | |||
} | |||
stillPadding = false; | |||
// CheckStyle:MagicNumber OFF | |||
result = (result << 3) + (header[i] - '0'); | |||
// CheckStyle:MagicNumber ON | |||
} | |||
return result; | |||
@@ -134,8 +138,10 @@ public class TarUtils { | |||
--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 @@ public class TarUtils { | |||
long sum = 0; | |||
for (int i = 0; i < buf.length; ++i) { | |||
sum += 255 & buf[i]; | |||
sum += BYTE_MASK & buf[i]; | |||
} | |||
return sum; | |||
@@ -139,6 +139,7 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable { | |||
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 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable { | |||
0, data, 8, 2); | |||
System.arraycopy(linkArray, 0, data, 10, linkArray.length); | |||
// CheckStyle:MagicNumber ON | |||
crc.reset(); | |||
crc.update(data); | |||
@@ -300,6 +302,7 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable { | |||
} | |||
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 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable { | |||
System.arraycopy(tmp, 10, linkArray, 0, linkArray.length); | |||
link = new String(linkArray); | |||
} | |||
// CheckStyle:MagicNumber ON | |||
setDirectory((newMode & DIR_FLAG) != 0); | |||
setMode(newMode); | |||
} | |||
@@ -599,6 +599,7 @@ public class ZipOutputStream extends FilterOutputStream { | |||
// 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 @@ public class ZipOutputStream extends FilterOutputStream { | |||
writeOut(ZipShort.getBytes(10)); | |||
writeOut(ZERO); | |||
} | |||
// CheckStyle:MagicNumber ON | |||
written += WORD; | |||
// compression method | |||
@@ -633,7 +635,9 @@ public class ZipOutputStream extends FilterOutputStream { | |||
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 @@ public class ZipOutputStream extends FilterOutputStream { | |||
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 @@ public class ZipOutputStream extends FilterOutputStream { | |||
written += WORD; | |||
// version made by | |||
// CheckStyle:MagicNumber OFF | |||
writeOut(ZipShort.getBytes((ze.getPlatform() << 8) | 20)); | |||
written += SHORT; | |||
@@ -702,6 +709,7 @@ public class ZipOutputStream extends FilterOutputStream { | |||
writeOut(ZipShort.getBytes(10)); | |||
writeOut(ZERO); | |||
} | |||
// CheckStyle:MagicNumber ON | |||
written += WORD; | |||
// compression method | |||
@@ -718,7 +726,9 @@ public class ZipOutputStream extends FilterOutputStream { | |||
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()); | |||