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 | * Default no-args constructor | ||||
*/ | */ | ||||
public SecureInputHandler(){} | |||||
public SecureInputHandler() { | |||||
} | |||||
/** | /** | ||||
* Handle the input | * Handle the input | ||||
@@ -44,7 +45,9 @@ public class SecureInputHandler extends DefaultInputHandler { | |||||
Class system = Class.forName("java.lang.System"); | Class system = Class.forName("java.lang.System"); | ||||
Object console = ReflectUtil.invokeStatic(system, "console"); | Object console = ReflectUtil.invokeStatic(system, "console"); | ||||
do { | 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)); | request.setInput(new String(input)); | ||||
/* for security zero char array after retrieving value */ | /* for security zero char array after retrieving value */ | ||||
java.util.Arrays.fill(input, ' '); | java.util.Arrays.fill(input, ' '); | ||||
@@ -60,7 +60,7 @@ public class ResourceContains implements Condition { | |||||
/** | /** | ||||
* Sets the resource to search | * Sets the resource to search | ||||
* @param r | |||||
* @param r the value to use. | |||||
*/ | */ | ||||
public void setResource(String r) { | public void setResource(String r) { | ||||
this.resource = new FileResource(new File(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 | * Sets the refid to search; should indicate a resource directly | ||||
* or by way of a single-element ResourceCollection. | * or by way of a single-element ResourceCollection. | ||||
* @param refid | |||||
* @param refid the value to use. | |||||
*/ | */ | ||||
public void setRefid(String refid) { | public void setRefid(String refid) { | ||||
this.refid = refid; | this.refid = refid; | ||||
@@ -88,8 +88,8 @@ public class ResourceContains implements Condition { | |||||
o = rc.iterator().next(); | o = rc.iterator().next(); | ||||
} | } | ||||
} else { | } 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; | this.resource = (Resource) o; | ||||
@@ -100,15 +100,15 @@ public class ResourceContains implements Condition { | |||||
/** | /** | ||||
* Sets the substring to look for | * Sets the substring to look for | ||||
* @param substring | |||||
* @param substring the value to use. | |||||
*/ | */ | ||||
public void setSubstring(String substring) { | public void setSubstring(String substring) { | ||||
this.substring = substring; | this.substring = substring; | ||||
} | } | ||||
/** | /** | ||||
* Sets case sensitivity | |||||
* @param casesensitive | |||||
* Sets case sensitivity attribute. | |||||
* @param casesensitive the value to use. | |||||
*/ | */ | ||||
public void setCasesensitive(boolean casesensitive) { | public void setCasesensitive(boolean casesensitive) { | ||||
this.casesensitive = 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 { | public synchronized boolean eval() throws BuildException { | ||||
validate(); | validate(); | ||||
if (substring.length() == 0) { | if (substring.length() == 0) { | ||||
if (getProject() != null) { | 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; | return true; | ||||
} | } | ||||
@@ -80,7 +80,7 @@ public class SSHExec extends SSHBase { | |||||
/** | /** | ||||
* Sets a commandResource from a file | * Sets a commandResource from a file | ||||
* @param f | |||||
* @param f the value to use. | |||||
* @since Ant 1.7.1 | * @since Ant 1.7.1 | ||||
*/ | */ | ||||
public void setCommandResource(String f) { | public void setCommandResource(String f) { | ||||
@@ -150,14 +150,15 @@ public class SSHExec extends SSHBase { | |||||
/* called once */ | /* called once */ | ||||
if (command != null) { | if (command != null) { | ||||
log("cmd : "+command, Project.MSG_INFO); | |||||
log("cmd : " + command, Project.MSG_INFO); | |||||
executeCommand(command); | executeCommand(command); | ||||
} else { // read command resource and execute for each command | } else { // read command resource and execute for each command | ||||
try { | try { | ||||
BufferedReader br = new BufferedReader(new InputStreamReader(commandResource.getInputStream())); | |||||
BufferedReader br = new BufferedReader( | |||||
new InputStreamReader(commandResource.getInputStream())); | |||||
String cmd; | 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); | executeCommand(cmd); | ||||
} | } | ||||
FileUtils.close(br); | FileUtils.close(br); | ||||
@@ -215,7 +215,7 @@ public abstract class ScriptRunnerBase { | |||||
in = new BufferedReader(reader); | in = new BufferedReader(reader); | ||||
script += FileUtils.readFully(in); | script += FileUtils.readFully(in); | ||||
} catch (IOException ex) { | } catch (IOException ex) { | ||||
throw new BuildException("Failed to read "+ name,ex); | |||||
throw new BuildException("Failed to read " + name, ex); | |||||
} finally { | } finally { | ||||
FileUtils.close(in); | FileUtils.close(in); | ||||
} | } | ||||
@@ -234,9 +234,10 @@ public abstract class ScriptRunnerBase { | |||||
try { | try { | ||||
in = sourceResource.getInputStream(); | in = sourceResource.getInputStream(); | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
throw new BuildException("Failed to open "+name,e); | |||||
throw new BuildException("Failed to open " + name, e); | |||||
} catch (UnsupportedOperationException 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); | readSource(new InputStreamReader(in), name); | ||||
} | } | ||||