Browse Source

magic numbers

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@578199 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 17 years ago
parent
commit
0961bd8616
8 changed files with 27 additions and 6 deletions
  1. +5
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java
  2. +3
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java
  3. +6
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java
  4. +2
    -0
      src/main/org/apache/tools/ant/types/Quantifier.java
  5. +4
    -1
      src/main/org/apache/tools/ant/types/mappers/FilterMapper.java
  6. +3
    -1
      src/main/org/apache/tools/ant/types/resources/CompressedResource.java
  7. +2
    -1
      src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java
  8. +2
    -0
      src/main/org/apache/tools/ant/util/DOMElementWriter.java

+ 5
- 2
src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java View File

@@ -37,6 +37,9 @@ import org.apache.tools.ant.Task;
*/ */


public class RExecTask extends Task { public class RExecTask extends Task {

private static final int PAUSE_TIME = 250;

/** /**
* The userid to login with, if automated login is used * 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 (sb.toString().indexOf(s) == -1) {
while (Calendar.getInstance().before(endTime) while (Calendar.getInstance().before(endTime)
&& is.available() == 0) { && is.available() == 0) {
Thread.sleep(250);
Thread.sleep(PAUSE_TIME);
} }
if (is.available() == 0) { if (is.available() == 0) {
throw new BuildException( throw new BuildException(
@@ -270,7 +273,7 @@ public class RExecTask extends Task {
int read = 0; int read = 0;
while (read != -1) { while (read != -1) {
while (Calendar.getInstance().before(endTime) && is.available() == 0) { while (Calendar.getInstance().before(endTime) && is.available() == 0) {
Thread.sleep(250);
Thread.sleep(PAUSE_TIME);
} }
if (is.available() == 0) { if (is.available() == 0) {
log(sb.toString(), Project.MSG_INFO); log(sb.toString(), Project.MSG_INFO);


+ 3
- 1
src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java View File

@@ -36,6 +36,8 @@ import org.apache.tools.ant.util.FileUtils;


public abstract class SOS extends Task implements SOSCmd { public abstract class SOS extends Task implements SOSCmd {


private static final int ERROR_EXIT_STATUS = 255;

private String sosCmdDir = null; private String sosCmdDir = null;
private String sosUsername = null; private String sosUsername = null;
private String sosPassword = ""; private String sosPassword = "";
@@ -390,7 +392,7 @@ public abstract class SOS extends Task implements SOSCmd {
int result = 0; int result = 0;
buildCmdLine(); buildCmdLine();
result = run(commandLine); 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(); String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, getLocation()); throw new BuildException(msg, getLocation());
} }


+ 6
- 0
src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java View File

@@ -138,11 +138,13 @@ public abstract class MSVSS extends Task implements MSVSSConstants {
*/ */
public final void setVsspath(final String vssPath) { public final void setVsspath(final String vssPath) {
String projectPath; String projectPath;
// CheckStyle:MagicNumber OFF
if (vssPath.startsWith("vss://")) { //$NON-NLS-1$ if (vssPath.startsWith("vss://")) { //$NON-NLS-1$
projectPath = vssPath.substring(5); projectPath = vssPath.substring(5);
} else { } else {
projectPath = vssPath; projectPath = vssPath;
} }
// CheckStyle:MagicNumber ON


if (projectPath.startsWith(PROJECT_PREFIX)) { if (projectPath.startsWith(PROJECT_PREFIX)) {
this.vssPath = projectPath; this.vssPath = projectPath;
@@ -425,6 +427,7 @@ public abstract class MSVSS extends Task implements MSVSSConstants {
*/ */
private String getShortLabel() { private String getShortLabel() {
String shortLabel; String shortLabel;
// CheckStyle:MagicNumber OFF
if (label != null && label.length() > 31) { if (label != null && label.length() > 31) {
shortLabel = this.label.substring(0, 30); shortLabel = this.label.substring(0, 30);
log("Label is longer than 31 characters, truncated to: " + shortLabel, log("Label is longer than 31 characters, truncated to: " + shortLabel,
@@ -432,6 +435,7 @@ public abstract class MSVSS extends Task implements MSVSSConstants {
} else { } else {
shortLabel = label; shortLabel = label;
} }
// CheckStyle:MagicNumber ON
return shortLabel; return shortLabel;
} }
/** /**
@@ -554,6 +558,7 @@ public abstract class MSVSS extends Task implements MSVSSConstants {
if (fromLabel == null && toLabel == null) { if (fromLabel == null && toLabel == null) {
return ""; return "";
} }
// CheckStyle:MagicNumber OFF
if (fromLabel != null && toLabel != null) { if (fromLabel != null && toLabel != null) {
if (fromLabel.length() > 31) { if (fromLabel.length() > 31) {
fromLabel = fromLabel.substring(0, 30); fromLabel = fromLabel.substring(0, 30);
@@ -581,6 +586,7 @@ public abstract class MSVSS extends Task implements MSVSSConstants {
} }
return FLAG_VERSION_LABEL + toLabel; return FLAG_VERSION_LABEL + toLabel;
} }
// CheckStyle:MagicNumber ON
} }


/** /**


+ 2
- 0
src/main/org/apache/tools/ant/types/Quantifier.java View File

@@ -78,6 +78,7 @@ public class Quantifier extends EnumeratedAttribute {
private static final Predicate[] PREDS = new Predicate[VALUES.length]; private static final Predicate[] PREDS = new Predicate[VALUES.length];


static { static {
// CheckStyle:MagicNumber OFF
PREDS[0] = ALL_PRED; PREDS[0] = ALL_PRED;
PREDS[1] = ALL_PRED; PREDS[1] = ALL_PRED;
PREDS[2] = ALL_PRED; PREDS[2] = ALL_PRED;
@@ -87,6 +88,7 @@ public class Quantifier extends EnumeratedAttribute {
PREDS[6] = MAJORITY_PRED; PREDS[6] = MAJORITY_PRED;
PREDS[7] = MAJORITY_PRED; PREDS[7] = MAJORITY_PRED;
PREDS[8] = NONE_PRED; PREDS[8] = NONE_PRED;
// CheckStyle:MagicNumber ON
} }


/** /**


+ 4
- 1
src/main/org/apache/tools/ant/types/mappers/FilterMapper.java View File

@@ -34,6 +34,9 @@ import org.apache.tools.ant.util.FileUtils;
* This is a FileNameMapper based on a FilterChain. * This is a FileNameMapper based on a FilterChain.
*/ */
public class FilterMapper extends FilterChain implements FileNameMapper { public class FilterMapper extends FilterChain implements FileNameMapper {

private static final int BUFFER_SIZE = 8192;

/** /**
* From attribute not supported. * From attribute not supported.
* @param from a string * @param from a string
@@ -64,7 +67,7 @@ public class FilterMapper extends FilterChain implements FileNameMapper {
try { try {
Reader stringReader = new StringReader(sourceFileName); Reader stringReader = new StringReader(sourceFileName);
ChainReaderHelper helper = new ChainReaderHelper(); ChainReaderHelper helper = new ChainReaderHelper();
helper.setBufferSize(8192);
helper.setBufferSize(BUFFER_SIZE);
helper.setPrimaryReader(stringReader); helper.setPrimaryReader(stringReader);
helper.setProject(getProject()); helper.setProject(getProject());
Vector filterChains = new Vector(); Vector filterChains = new Vector();


+ 3
- 1
src/main/org/apache/tools/ant/types/resources/CompressedResource.java View File

@@ -38,6 +38,8 @@ import org.apache.tools.ant.util.FileUtils;
*/ */
public abstract class CompressedResource extends Resource { public abstract class CompressedResource extends Resource {


private static final int BUFFER_SIZE = 8192;

private Resource resource; private Resource resource;


/** no arg constructor */ /** no arg constructor */
@@ -153,7 +155,7 @@ public abstract class CompressedResource extends Resource {
InputStream in = null; InputStream in = null;
try { try {
in = getInputStream(); in = getInputStream();
byte[] buf = new byte[8192];
byte[] buf = new byte[BUFFER_SIZE];
int size = 0; int size = 0;
int readNow; int readNow;
while ((readNow = in.read(buf, 0, buf.length)) > 0) { while ((readNow = in.read(buf, 0, buf.length)) > 0) {


+ 2
- 1
src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java View File

@@ -56,6 +56,7 @@ import org.apache.tools.ant.BuildException;
*/ */
public class DigestAlgorithm implements Algorithm { public class DigestAlgorithm implements Algorithm {


private static final int BUFFER_SIZE = 8192;


// ----- member variables ----- // ----- member variables -----


@@ -78,7 +79,7 @@ public class DigestAlgorithm implements Algorithm {
/** /**
* Size of the read buffer to use. * Size of the read buffer to use.
*/ */
private int readBufferSize = 8 * 1024;
private int readBufferSize = BUFFER_SIZE;




// ----- Algorithm-Configuration ----- // ----- Algorithm-Configuration -----


+ 2
- 0
src/main/org/apache/tools/ant/util/DOMElementWriter.java View File

@@ -532,6 +532,7 @@ public class DOMElementWriter {
* @since 1.10, Ant 1.5 * @since 1.10, Ant 1.5
*/ */
public boolean isLegalCharacter(char c) { public boolean isLegalCharacter(char c) {
// CheckStyle:MagicNumber OFF
if (c == 0x9 || c == 0xA || c == 0xD) { if (c == 0x9 || c == 0xA || c == 0xD) {
return true; return true;
} else if (c < 0x20) { } else if (c < 0x20) {
@@ -543,6 +544,7 @@ public class DOMElementWriter {
} else if (c <= 0xFFFD) { } else if (c <= 0xFFFD) {
return true; return true;
} }
// CheckStyle:MagicNumber ON
return false; return false;
} }




Loading…
Cancel
Save