diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java index 41a6c6735..0ca112396 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java @@ -37,6 +37,9 @@ import org.apache.tools.ant.Task; */ public class RExecTask extends Task { + + private static final int PAUSE_TIME = 250; + /** * The userid to login with, if automated login is used */ @@ -210,7 +213,7 @@ public class RExecTask extends Task { while (sb.toString().indexOf(s) == -1) { while (Calendar.getInstance().before(endTime) && is.available() == 0) { - Thread.sleep(250); + Thread.sleep(PAUSE_TIME); } if (is.available() == 0) { throw new BuildException( @@ -270,7 +273,7 @@ public class RExecTask extends Task { int read = 0; while (read != -1) { while (Calendar.getInstance().before(endTime) && is.available() == 0) { - Thread.sleep(250); + Thread.sleep(PAUSE_TIME); } if (is.available() == 0) { log(sb.toString(), Project.MSG_INFO); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java index b1096ea5a..d7805b0a5 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java @@ -36,6 +36,8 @@ import org.apache.tools.ant.util.FileUtils; public abstract class SOS extends Task implements SOSCmd { + private static final int ERROR_EXIT_STATUS = 255; + private String sosCmdDir = null; private String sosUsername = null; private String sosPassword = ""; @@ -390,7 +392,7 @@ public abstract class SOS extends Task implements SOSCmd { int result = 0; buildCmdLine(); result = run(commandLine); - if (result == 255) { // This is the exit status + if (result == ERROR_EXIT_STATUS) { // This is the exit status String msg = "Failed executing: " + commandLine.toString(); throw new BuildException(msg, getLocation()); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java index bfcf5690e..f00487c11 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java @@ -138,11 +138,13 @@ public abstract class MSVSS extends Task implements MSVSSConstants { */ public final void setVsspath(final String vssPath) { String projectPath; + // CheckStyle:MagicNumber OFF if (vssPath.startsWith("vss://")) { //$NON-NLS-1$ projectPath = vssPath.substring(5); } else { projectPath = vssPath; } + // CheckStyle:MagicNumber ON if (projectPath.startsWith(PROJECT_PREFIX)) { this.vssPath = projectPath; @@ -425,6 +427,7 @@ public abstract class MSVSS extends Task implements MSVSSConstants { */ private String getShortLabel() { String shortLabel; + // CheckStyle:MagicNumber OFF if (label != null && label.length() > 31) { shortLabel = this.label.substring(0, 30); log("Label is longer than 31 characters, truncated to: " + shortLabel, @@ -432,6 +435,7 @@ public abstract class MSVSS extends Task implements MSVSSConstants { } else { shortLabel = label; } + // CheckStyle:MagicNumber ON return shortLabel; } /** @@ -554,6 +558,7 @@ public abstract class MSVSS extends Task implements MSVSSConstants { if (fromLabel == null && toLabel == null) { return ""; } + // CheckStyle:MagicNumber OFF if (fromLabel != null && toLabel != null) { if (fromLabel.length() > 31) { fromLabel = fromLabel.substring(0, 30); @@ -581,6 +586,7 @@ public abstract class MSVSS extends Task implements MSVSSConstants { } return FLAG_VERSION_LABEL + toLabel; } + // CheckStyle:MagicNumber ON } /** diff --git a/src/main/org/apache/tools/ant/types/Quantifier.java b/src/main/org/apache/tools/ant/types/Quantifier.java index 796ec1640..ac1b84ce6 100755 --- a/src/main/org/apache/tools/ant/types/Quantifier.java +++ b/src/main/org/apache/tools/ant/types/Quantifier.java @@ -78,6 +78,7 @@ public class Quantifier extends EnumeratedAttribute { private static final Predicate[] PREDS = new Predicate[VALUES.length]; static { + // CheckStyle:MagicNumber OFF PREDS[0] = ALL_PRED; PREDS[1] = ALL_PRED; PREDS[2] = ALL_PRED; @@ -87,6 +88,7 @@ public class Quantifier extends EnumeratedAttribute { PREDS[6] = MAJORITY_PRED; PREDS[7] = MAJORITY_PRED; PREDS[8] = NONE_PRED; + // CheckStyle:MagicNumber ON } /** diff --git a/src/main/org/apache/tools/ant/types/mappers/FilterMapper.java b/src/main/org/apache/tools/ant/types/mappers/FilterMapper.java index 101fcb786..391a3f7b0 100644 --- a/src/main/org/apache/tools/ant/types/mappers/FilterMapper.java +++ b/src/main/org/apache/tools/ant/types/mappers/FilterMapper.java @@ -34,6 +34,9 @@ import org.apache.tools.ant.util.FileUtils; * This is a FileNameMapper based on a FilterChain. */ public class FilterMapper extends FilterChain implements FileNameMapper { + + private static final int BUFFER_SIZE = 8192; + /** * From attribute not supported. * @param from a string @@ -64,7 +67,7 @@ public class FilterMapper extends FilterChain implements FileNameMapper { try { Reader stringReader = new StringReader(sourceFileName); ChainReaderHelper helper = new ChainReaderHelper(); - helper.setBufferSize(8192); + helper.setBufferSize(BUFFER_SIZE); helper.setPrimaryReader(stringReader); helper.setProject(getProject()); Vector filterChains = new Vector(); diff --git a/src/main/org/apache/tools/ant/types/resources/CompressedResource.java b/src/main/org/apache/tools/ant/types/resources/CompressedResource.java index 6685a5931..759e6f361 100644 --- a/src/main/org/apache/tools/ant/types/resources/CompressedResource.java +++ b/src/main/org/apache/tools/ant/types/resources/CompressedResource.java @@ -38,6 +38,8 @@ import org.apache.tools.ant.util.FileUtils; */ public abstract class CompressedResource extends Resource { + private static final int BUFFER_SIZE = 8192; + private Resource resource; /** no arg constructor */ @@ -153,7 +155,7 @@ public abstract class CompressedResource extends Resource { InputStream in = null; try { in = getInputStream(); - byte[] buf = new byte[8192]; + byte[] buf = new byte[BUFFER_SIZE]; int size = 0; int readNow; while ((readNow = in.read(buf, 0, buf.length)) > 0) { diff --git a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java index f309878c3..7255519e1 100644 --- a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java +++ b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java @@ -56,6 +56,7 @@ import org.apache.tools.ant.BuildException; */ public class DigestAlgorithm implements Algorithm { + private static final int BUFFER_SIZE = 8192; // ----- member variables ----- @@ -78,7 +79,7 @@ public class DigestAlgorithm implements Algorithm { /** * Size of the read buffer to use. */ - private int readBufferSize = 8 * 1024; + private int readBufferSize = BUFFER_SIZE; // ----- Algorithm-Configuration ----- diff --git a/src/main/org/apache/tools/ant/util/DOMElementWriter.java b/src/main/org/apache/tools/ant/util/DOMElementWriter.java index e47f7bf70..cc8e68b0e 100644 --- a/src/main/org/apache/tools/ant/util/DOMElementWriter.java +++ b/src/main/org/apache/tools/ant/util/DOMElementWriter.java @@ -532,6 +532,7 @@ public class DOMElementWriter { * @since 1.10, Ant 1.5 */ public boolean isLegalCharacter(char c) { + // CheckStyle:MagicNumber OFF if (c == 0x9 || c == 0xA || c == 0xD) { return true; } else if (c < 0x20) { @@ -543,6 +544,7 @@ public class DOMElementWriter { } else if (c <= 0xFFFD) { return true; } + // CheckStyle:MagicNumber ON return false; }