git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@564923 13f79535-47bb-0310-9956-ffa450edef68master
@@ -31,7 +31,8 @@ public class SecureInputHandler extends DefaultInputHandler { | |||
/** | |||
* Default no-args constructor | |||
*/ | |||
public SecureInputHandler(){} | |||
public SecureInputHandler() { | |||
} | |||
/** | |||
* Handle the input | |||
@@ -44,7 +45,9 @@ public class SecureInputHandler extends DefaultInputHandler { | |||
Class system = Class.forName("java.lang.System"); | |||
Object console = ReflectUtil.invokeStatic(system, "console"); | |||
do { | |||
char[] input = (char[])ReflectUtil.invoke(console, "readPassword", String.class, prompt, Object[].class, (Object[]) null); | |||
char[] input = (char[]) ReflectUtil.invoke( | |||
console, "readPassword", String.class, prompt, | |||
Object[].class, (Object[]) null); | |||
request.setInput(new String(input)); | |||
/* for security zero char array after retrieving value */ | |||
java.util.Arrays.fill(input, ' '); | |||
@@ -60,7 +60,7 @@ public class ResourceContains implements Condition { | |||
/** | |||
* Sets the resource to search | |||
* @param r | |||
* @param r the value to use. | |||
*/ | |||
public void setResource(String r) { | |||
this.resource = new FileResource(new File(r)); | |||
@@ -69,7 +69,7 @@ public class ResourceContains implements Condition { | |||
/** | |||
* Sets the refid to search; should indicate a resource directly | |||
* or by way of a single-element ResourceCollection. | |||
* @param refid | |||
* @param refid the value to use. | |||
*/ | |||
public void setRefid(String refid) { | |||
this.refid = refid; | |||
@@ -88,8 +88,8 @@ public class ResourceContains implements Condition { | |||
o = rc.iterator().next(); | |||
} | |||
} else { | |||
throw new BuildException("Illegal value at '" + refid +"': " | |||
+ String.valueOf(o)); | |||
throw new BuildException( | |||
"Illegal value at '" + refid + "': " + String.valueOf(o)); | |||
} | |||
} | |||
this.resource = (Resource) o; | |||
@@ -100,15 +100,15 @@ public class ResourceContains implements Condition { | |||
/** | |||
* Sets the substring to look for | |||
* @param substring | |||
* @param substring the value to use. | |||
*/ | |||
public void setSubstring(String substring) { | |||
this.substring = substring; | |||
} | |||
/** | |||
* Sets case sensitivity | |||
* @param casesensitive | |||
* Sets case sensitivity attribute. | |||
* @param casesensitive the value to use. | |||
*/ | |||
public void setCasesensitive(boolean casesensitive) { | |||
this.casesensitive = casesensitive; | |||
@@ -128,15 +128,17 @@ public class ResourceContains implements Condition { | |||
} | |||
/** | |||
* Evaluates | |||
* Returns true if the substring is contained in the resource | |||
* Evaluates the condition. | |||
* @return true if the substring is contained in the resource | |||
* @throws BuildException if there is a problem. | |||
*/ | |||
public synchronized boolean eval() throws BuildException { | |||
validate(); | |||
if (substring.length() == 0) { | |||
if (getProject() != null) { | |||
getProject().log("Substring is empty; returning true", Project.MSG_VERBOSE); | |||
getProject().log("Substring is empty; returning true", | |||
Project.MSG_VERBOSE); | |||
} | |||
return true; | |||
} | |||
@@ -80,7 +80,7 @@ public class SSHExec extends SSHBase { | |||
/** | |||
* Sets a commandResource from a file | |||
* @param f | |||
* @param f the value to use. | |||
* @since Ant 1.7.1 | |||
*/ | |||
public void setCommandResource(String f) { | |||
@@ -150,14 +150,15 @@ public class SSHExec extends SSHBase { | |||
/* called once */ | |||
if (command != null) { | |||
log("cmd : "+command, Project.MSG_INFO); | |||
log("cmd : " + command, Project.MSG_INFO); | |||
executeCommand(command); | |||
} else { // read command resource and execute for each command | |||
try { | |||
BufferedReader br = new BufferedReader(new InputStreamReader(commandResource.getInputStream())); | |||
BufferedReader br = new BufferedReader( | |||
new InputStreamReader(commandResource.getInputStream())); | |||
String cmd; | |||
while((cmd = br.readLine()) != null) { | |||
log("cmd : "+cmd, Project.MSG_INFO); | |||
while ((cmd = br.readLine()) != null) { | |||
log("cmd : " + cmd, Project.MSG_INFO); | |||
executeCommand(cmd); | |||
} | |||
FileUtils.close(br); | |||
@@ -215,7 +215,7 @@ public abstract class ScriptRunnerBase { | |||
in = new BufferedReader(reader); | |||
script += FileUtils.readFully(in); | |||
} catch (IOException ex) { | |||
throw new BuildException("Failed to read "+ name,ex); | |||
throw new BuildException("Failed to read " + name, ex); | |||
} finally { | |||
FileUtils.close(in); | |||
} | |||
@@ -234,9 +234,10 @@ public abstract class ScriptRunnerBase { | |||
try { | |||
in = sourceResource.getInputStream(); | |||
} catch (IOException e) { | |||
throw new BuildException("Failed to open "+name,e); | |||
throw new BuildException("Failed to open " + name, e); | |||
} catch (UnsupportedOperationException e) { | |||
throw new BuildException("Failed to open " + name+ " -it is not readable",e); | |||
throw new BuildException( | |||
"Failed to open " + name + " -it is not readable", e); | |||
} | |||
readSource(new InputStreamReader(in), name); | |||
} | |||