git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@577684 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -55,7 +55,7 @@ import org.apache.tools.ant.types.Commandline; | |||||
| */ | */ | ||||
| public class NetCommand { | public class NetCommand { | ||||
| private static final int DEFAULT_RESPONSE_THRESHOLD = 64; | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | ||||
| // CheckStyle:VisibilityModifier OFF - bc | // CheckStyle:VisibilityModifier OFF - bc | ||||
| @@ -115,7 +115,7 @@ public class NetCommand { | |||||
| /** | /** | ||||
| * internal threshold for auto-switch | * internal threshold for auto-switch | ||||
| */ | */ | ||||
| private int automaticResponseFileThreshold = 64; | |||||
| private int automaticResponseFileThreshold = DEFAULT_RESPONSE_THRESHOLD; | |||||
| /** | /** | ||||
| * constructor | * constructor | ||||
| @@ -105,6 +105,7 @@ class ConstantPool { | |||||
| * minimal task only. | * minimal task only. | ||||
| */ | */ | ||||
| public class ClassNameReader extends Object { | public class ClassNameReader extends Object { | ||||
| private static final int CLASS_MAGIC_NUMBER = 0xCAFEBABE; | |||||
| /** | /** | ||||
| * Get the class name of a class in an input stream. | * Get the class name of a class in an input stream. | ||||
| @@ -117,7 +118,7 @@ public class ClassNameReader extends Object { | |||||
| DataInputStream data = new DataInputStream(input); | DataInputStream data = new DataInputStream(input); | ||||
| // verify this is a valid class file. | // verify this is a valid class file. | ||||
| int cookie = data.readInt(); | int cookie = data.readInt(); | ||||
| if (cookie != 0xCAFEBABE) { | |||||
| if (cookie != CLASS_MAGIC_NUMBER) { | |||||
| return null; | return null; | ||||
| } | } | ||||
| /* int version = */ data.readInt(); | /* int version = */ data.readInt(); | ||||
| @@ -44,19 +44,20 @@ import java.util.zip.ZipOutputStream; | |||||
| * jlink links together multiple .jar files. | * jlink links together multiple .jar files. | ||||
| */ | */ | ||||
| public class jlink { | public class jlink { | ||||
| private static final int BUFFER_SIZE = 8192; | |||||
| private static final int VECTOR_INIT_SIZE = 10; | |||||
| private String outfile = null; | private String outfile = null; | ||||
| private Vector mergefiles = new Vector(10); | |||||
| private Vector mergefiles = new Vector(VECTOR_INIT_SIZE); | |||||
| private Vector addfiles = new Vector(10); | |||||
| private Vector addfiles = new Vector(VECTOR_INIT_SIZE); | |||||
| private boolean compression = false; | private boolean compression = false; | ||||
| // CheckStyle:VisibilityModifier OFF - bc | // CheckStyle:VisibilityModifier OFF - bc | ||||
| byte[] buffer = new byte[8192]; | |||||
| byte[] buffer = new byte[BUFFER_SIZE]; | |||||
| // CheckStyle:VisibilityModifier OFF - bc | // CheckStyle:VisibilityModifier OFF - bc | ||||
| @@ -63,7 +63,7 @@ public class Jasper41Mangler implements JspMangler { | |||||
| * Mangle the specified character to create a legal Java class name. | * Mangle the specified character to create a legal Java class name. | ||||
| */ | */ | ||||
| private static String mangleChar(char ch) { | private static String mangleChar(char ch) { | ||||
| // CheckStyle:MagicNumber OFF | |||||
| String s = Integer.toHexString(ch); | String s = Integer.toHexString(ch); | ||||
| int nzeros = 5 - s.length(); | int nzeros = 5 - s.length(); | ||||
| char[] result = new char[6]; | char[] result = new char[6]; | ||||
| @@ -75,6 +75,7 @@ public class Jasper41Mangler implements JspMangler { | |||||
| result[i] = s.charAt(j); | result[i] = s.charAt(j); | ||||
| } | } | ||||
| return new String(result); | return new String(result); | ||||
| // CheckStyle:MagicNumber ON | |||||
| } | } | ||||
| @@ -112,7 +112,7 @@ public class JspNameMangler implements JspMangler { | |||||
| String className; | String className; | ||||
| String filename = jspFile.getName(); | String filename = jspFile.getName(); | ||||
| if (filename.endsWith(".jsp")) { | if (filename.endsWith(".jsp")) { | ||||
| className = filename.substring(0, filename.length() - 4); | |||||
| className = filename.substring(0, filename.length() - ".jsp".length()); | |||||
| } else { | } else { | ||||
| className = filename; | className = filename; | ||||
| } | } | ||||
| @@ -127,7 +127,7 @@ public class JspNameMangler implements JspMangler { | |||||
| * @return mangled string; 5 digit hex value | * @return mangled string; 5 digit hex value | ||||
| */ | */ | ||||
| private static String mangleChar(char ch) { | private static String mangleChar(char ch) { | ||||
| // CheckStyle:MagicNumber OFF | |||||
| if (ch == File.separatorChar) { | if (ch == File.separatorChar) { | ||||
| ch = '/'; | ch = '/'; | ||||
| } | } | ||||
| @@ -143,6 +143,7 @@ public class JspNameMangler implements JspMangler { | |||||
| result[i] = s.charAt(resultIndex++); | result[i] = s.charAt(resultIndex++); | ||||
| } | } | ||||
| return new String(result); | return new String(result); | ||||
| // CheckStyle:MagicNumber ON | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -1670,9 +1670,11 @@ public class JUnitTask extends Task { | |||||
| * @return hash code value | * @return hash code value | ||||
| */ | */ | ||||
| public int hashCode() { | public int hashCode() { | ||||
| // CheckStyle:MagicNumber OFF | |||||
| return (filterTrace ? 1 : 0) | return (filterTrace ? 1 : 0) | ||||
| + (haltOnError ? 2 : 0) | + (haltOnError ? 2 : 0) | ||||
| + (haltOnFailure ? 4 : 0); | + (haltOnFailure ? 4 : 0); | ||||
| // CheckStyle:MagicNumber ON | |||||
| } | } | ||||
| } | } | ||||
| @@ -56,7 +56,8 @@ import org.apache.tools.ant.util.ProxySetup; | |||||
| * @ant.task category="network" | * @ant.task category="network" | ||||
| */ | */ | ||||
| public class SetProxy extends Task { | public class SetProxy extends Task { | ||||
| private static final int HTTP_PORT = 80; | |||||
| private static final int SOCKS_PORT = 1080; | |||||
| // CheckStyle:VisibilityModifier OFF - bc | // CheckStyle:VisibilityModifier OFF - bc | ||||
| /** | /** | ||||
| * proxy details | * proxy details | ||||
| @@ -66,7 +67,7 @@ public class SetProxy extends Task { | |||||
| /** | /** | ||||
| * name of proxy port | * name of proxy port | ||||
| */ | */ | ||||
| protected int proxyPort = 80; | |||||
| protected int proxyPort = HTTP_PORT; | |||||
| // CheckStyle:VisibilityModifier ON | // CheckStyle:VisibilityModifier ON | ||||
| @@ -78,7 +79,7 @@ public class SetProxy extends Task { | |||||
| /** | /** | ||||
| * Socks proxy port. Default is 1080. | * Socks proxy port. Default is 1080. | ||||
| */ | */ | ||||
| private int socksProxyPort = 1080; | |||||
| private int socksProxyPort = SOCKS_PORT; | |||||
| /** | /** | ||||
| @@ -35,6 +35,9 @@ import org.apache.tools.ant.Task; | |||||
| */ | */ | ||||
| public class TelnetTask extends Task { | public class TelnetTask extends Task { | ||||
| private static final int QUARTER_SECOND = 250; | |||||
| private static final int TELNET_PORT = 23; | |||||
| /** | /** | ||||
| * The userid to login with, if automated login is used | * The userid to login with, if automated login is used | ||||
| */ | */ | ||||
| @@ -53,7 +56,7 @@ public class TelnetTask extends Task { | |||||
| /** | /** | ||||
| * The tcp port to connect to. | * The tcp port to connect to. | ||||
| */ | */ | ||||
| private int port = 23; | |||||
| private int port = TELNET_PORT; | |||||
| /** | /** | ||||
| * The list of read/write commands for this session | * The list of read/write commands for this session | ||||
| @@ -347,7 +350,7 @@ public class TelnetTask 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(QUARTER_SECOND); | |||||
| } | } | ||||
| if (is.available() == 0) { | if (is.available() == 0) { | ||||
| log("Read before running into timeout: " | log("Read before running into timeout: " | ||||
| @@ -38,13 +38,14 @@ import org.apache.tools.ant.util.Base64Converter; | |||||
| * @since Ant1.5 | * @since Ant1.5 | ||||
| */ | */ | ||||
| public class SplashTask extends Task { | public class SplashTask extends Task { | ||||
| private static final int FIVE_SECONDS = 5000; | |||||
| private String imgurl = null; | private String imgurl = null; | ||||
| private String proxy = null; | private String proxy = null; | ||||
| private String user = null; | private String user = null; | ||||
| private String password = null; | private String password = null; | ||||
| private String port = "80"; | private String port = "80"; | ||||
| private int showDuration = 5000; | |||||
| private int showDuration = FIVE_SECONDS; | |||||
| private boolean useProxy = false; | private boolean useProxy = false; | ||||
| private static SplashScreen splash = null; | private static SplashScreen splash = null; | ||||
| @@ -44,6 +44,9 @@ import com.jcraft.jsch.Session; | |||||
| */ | */ | ||||
| public class SSHExec extends SSHBase { | public class SSHExec extends SSHBase { | ||||
| private static final int BUFFER_SIZE = 8192; | |||||
| private static final int HALF_SECOND = 500; | |||||
| /** the command to execute via ssh */ | /** the command to execute via ssh */ | ||||
| private String command = null; | private String command = null; | ||||
| @@ -192,7 +195,7 @@ public class SSHExec extends SSHBase { | |||||
| return; | return; | ||||
| } | } | ||||
| try { | try { | ||||
| sleep(500); | |||||
| sleep(HALF_SECOND); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| // ignored | // ignored | ||||
| } | } | ||||
| @@ -277,7 +280,7 @@ public class SSHExec extends SSHBase { | |||||
| try { | try { | ||||
| out = new FileWriter(to.getAbsolutePath(), append); | out = new FileWriter(to.getAbsolutePath(), append); | ||||
| StringReader in = new StringReader(from); | StringReader in = new StringReader(from); | ||||
| char[] buffer = new char[8192]; | |||||
| char[] buffer = new char[BUFFER_SIZE]; | |||||
| int bytesRead; | int bytesRead; | ||||
| while (true) { | while (true) { | ||||
| bytesRead = in.read(buffer); | bytesRead = in.read(buffer); | ||||