Browse Source

Use isEmpty() in tasks

master
Gintas Grigelionis 7 years ago
parent
commit
73bda1fb17
13 changed files with 25 additions and 28 deletions
  1. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/Ant.java
  2. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Available.java
  3. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/BindTargets.java
  4. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/DefaultExcludes.java
  5. +5
    -8
      src/main/org/apache/tools/ant/taskdefs/Echo.java
  6. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/Jar.java
  7. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Javadoc.java
  8. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/Replace.java
  9. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java
  10. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java
  11. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  12. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTask.java
  13. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java

+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/Ant.java View File

@@ -434,7 +434,7 @@ public class Ant extends Task {
addReferences(); addReferences();


if (!locals.isEmpty() && !(locals.size() == 1 if (!locals.isEmpty() && !(locals.size() == 1
&& "".equals(locals.get(0)))) {
&& locals.get(0) != null && locals.get(0).isEmpty())) {
BuildException be = null; BuildException be = null;
try { try {
log("Entering " + antFile + "...", Project.MSG_VERBOSE); log("Entering " + antFile + "...", Project.MSG_VERBOSE);
@@ -670,7 +670,7 @@ public class Ant extends Task {
* @param targetToAdd the name of the target to invoke. * @param targetToAdd the name of the target to invoke.
*/ */
public void setTarget(String targetToAdd) { public void setTarget(String targetToAdd) {
if ("".equals(targetToAdd)) {
if (targetToAdd.isEmpty()) {
throw new BuildException("target attribute must not be empty"); throw new BuildException("target attribute must not be empty");
} }
targets.add(targetToAdd); targets.add(targetToAdd);
@@ -720,7 +720,7 @@ public class Ant extends Task {
"nested target is incompatible with the target attribute"); "nested target is incompatible with the target attribute");
} }
String name = t.getName(); String name = t.getName();
if ("".equals(name)) {
if (name.isEmpty()) {
throw new BuildException("target name must not be empty"); throw new BuildException("target name must not be empty");
} }
targets.add(name); targets.add(name);


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Available.java View File

@@ -159,7 +159,7 @@ public class Available extends Task implements Condition {
* @param classname the name of the class required. * @param classname the name of the class required.
*/ */
public void setClassname(String classname) { public void setClassname(String classname) {
if (!"".equals(classname)) {
if (!classname.isEmpty()) {
this.classname = classname; this.classname = classname;
} }
} }


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/BindTargets.java View File

@@ -65,7 +65,7 @@ public class BindTargets extends Task {
} }


if (getOwningTarget() == null if (getOwningTarget() == null
|| !"".equals(getOwningTarget().getName())) {
|| getOwningTarget().getName().isEmpty()) {
throw new BuildException("bindtargets only allowed as a top-level task"); throw new BuildException("bindtargets only allowed as a top-level task");
} }




+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/DefaultExcludes.java View File

@@ -47,17 +47,17 @@ public class DefaultExcludes extends Task {
*/ */
@Override @Override
public void execute() throws BuildException { public void execute() throws BuildException {
if (!defaultrequested && "".equals(add) && "".equals(remove) && !echo) {
if (!defaultrequested && add.isEmpty() && remove.isEmpty() && !echo) {
throw new BuildException( throw new BuildException(
"<defaultexcludes> task must set at least one attribute (echo=\"false\" doesn't count since that is the default"); "<defaultexcludes> task must set at least one attribute (echo=\"false\" doesn't count since that is the default");
} }
if (defaultrequested) { if (defaultrequested) {
DirectoryScanner.resetDefaultExcludes(); DirectoryScanner.resetDefaultExcludes();
} }
if (!"".equals(add)) {
if (!add.isEmpty()) {
DirectoryScanner.addDefaultExclude(add); DirectoryScanner.addDefaultExclude(add);
} }
if (!"".equals(remove)) {
if (!remove.isEmpty()) {
DirectoryScanner.removeDefaultExclude(remove); DirectoryScanner.removeDefaultExclude(remove);
} }
if (echo) { if (echo) {


+ 5
- 8
src/main/org/apache/tools/ant/taskdefs/Echo.java View File

@@ -61,15 +61,12 @@ public class Echo extends Task {
* @exception BuildException if something goes wrong with the build * @exception BuildException if something goes wrong with the build
*/ */
public void execute() throws BuildException { public void execute() throws BuildException {
final String msg = "".equals(message) ? StringUtils.LINE_SEP : message;
try { try {
ResourceUtils
.copyResource(new StringResource(msg), output == null
? new LogOutputResource(this, logLevel)
: output,
null, null, false, false, append, null,
"".equals(encoding) ? null : encoding,
getProject(), force);
ResourceUtils.copyResource(
new StringResource(message.isEmpty() ? StringUtils.LINE_SEP : message),
output == null ? new LogOutputResource(this, logLevel) : output,
null, null, false, false, append, null,
encoding.isEmpty() ? null : encoding, getProject(), force);
} catch (IOException ioe) { } catch (IOException ioe) {
throw new BuildException(ioe, getLocation()); throw new BuildException(ioe, getLocation());
} }


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/Jar.java View File

@@ -1108,9 +1108,9 @@ public class Jar extends Zip {
String name = resources[0][j].getName().replace('\\', '/'); String name = resources[0][j].getName().replace('\\', '/');
if (rcs[i] instanceof ArchiveFileSet) { if (rcs[i] instanceof ArchiveFileSet) {
ArchiveFileSet afs = (ArchiveFileSet) rcs[i]; ArchiveFileSet afs = (ArchiveFileSet) rcs[i];
if (!"".equals(afs.getFullpath(getProject()))) {
if (!afs.getFullpath(getProject()).isEmpty()) {
name = afs.getFullpath(getProject()); name = afs.getFullpath(getProject());
} else if (!"".equals(afs.getPrefix(getProject()))) {
} else if (!afs.getPrefix(getProject()).isEmpty()) {
String prefix = afs.getPrefix(getProject()); String prefix = afs.getPrefix(getProject());
if (!prefix.endsWith("/") && !prefix.endsWith("\\")) { if (!prefix.endsWith("/") && !prefix.endsWith("\\")) {
prefix += "/"; prefix += "/";


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Javadoc.java View File

@@ -2375,7 +2375,7 @@ public class Javadoc extends Task {
&& name.equals("package.html"))); && name.equals("package.html")));


if (files.length > 0) { if (files.length > 0) {
if ("".equals(dir)) {
if (dir.isEmpty()) {
log(baseDir log(baseDir
+ " contains source files in the default package, you must specify them as source files not packages.", + " contains source files in the default package, you must specify them as source files not packages.",
Project.MSG_WARN); Project.MSG_WARN);


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/Replace.java View File

@@ -149,7 +149,7 @@ public class Replace extends MatchingTask {
"token is a mandatory for replacefilter."); "token is a mandatory for replacefilter.");
} }


if ("".equals(token.getText())) {
if (token.getText().isEmpty()) {
throw new BuildException( throw new BuildException(
"The token must not be an empty string."); "The token must not be an empty string.");
} }
@@ -586,7 +586,7 @@ public class Replace extends MatchingTask {
"Either token or a nested replacefilter must be specified", "Either token or a nested replacefilter must be specified",
getLocation()); getLocation());
} }
if (token != null && "".equals(token.getText())) {
if (token != null && token.getText().isEmpty()) {
throw new BuildException( throw new BuildException(
"The token attribute must not be an empty string.", "The token attribute must not be an empty string.",
getLocation()); getLocation());


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java View File

@@ -103,7 +103,7 @@ public abstract class Continuus extends Task {
*/ */
protected final String getCcmCommand() { protected final String getCcmCommand() {
String toReturn = ccmDir; String toReturn = ccmDir;
if (!"".equals(toReturn) && !toReturn.endsWith("/")) {
if (!toReturn.isEmpty() && !toReturn.endsWith("/")) {
toReturn += "/"; toReturn += "/";
} }




+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java View File

@@ -128,7 +128,7 @@ public abstract class ClearCase extends Task {
*/ */
protected final String getClearToolCommand() { protected final String getClearToolCommand() {
String toReturn = mClearToolDir; String toReturn = mClearToolDir;
if (!"".equals(toReturn) && !toReturn.endsWith("/")) {
if (!toReturn.isEmpty() && !toReturn.endsWith("/")) {
toReturn += "/"; toReturn += "/";
} }




+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java View File

@@ -2633,7 +2633,7 @@ public class FTP extends Task implements FTPTaskConfig {
*/ */
public long getMilliseconds(int action) { public long getMilliseconds(int action) {
String granularityU = getValue().toUpperCase(Locale.ENGLISH); String granularityU = getValue().toUpperCase(Locale.ENGLISH);
if ("".equals(granularityU)) {
if (granularityU.isEmpty()) {
if (action == SEND_FILES) { if (action == SEND_FILES) {
return GRANULARITY_MINUTE; return GRANULARITY_MINUTE;
} }


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTask.java View File

@@ -941,7 +941,7 @@ public class FTPTask extends Task implements FTPTaskConfig {
*/ */
public long getMilliseconds(int action) { public long getMilliseconds(int action) {
String granularityU = getValue().toUpperCase(Locale.ENGLISH); String granularityU = getValue().toUpperCase(Locale.ENGLISH);
if ("".equals(granularityU)) {
if (granularityU.isEmpty()) {
if (action == SEND_FILES) { if (action == SEND_FILES) {
return GRANULARITY_MINUTE; return GRANULARITY_MINUTE;
} }


+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java View File

@@ -395,11 +395,11 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
return; return;
} }
String completePath; String completePath;
if (!"".equals(vpath)) {
if (vpath.isEmpty()) {
completePath = rootPath;
} else {
completePath = rootPath + task.getSeparator() completePath = rootPath + task.getSeparator()
+ vpath.replace(File.separatorChar, task.getSeparator().charAt(0)); + vpath.replace(File.separatorChar, task.getSeparator().charAt(0));
} else {
completePath = rootPath;
} }
FTPFile[] newfiles = listFiles(completePath, false); FTPFile[] newfiles = listFiles(completePath, false);




Loading…
Cancel
Save