Browse Source

early exit for empty substring with optional verbose log message

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@537880 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 18 years ago
parent
commit
b1a4d51f9f
1 changed files with 25 additions and 0 deletions
  1. +25
    -0
      src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java

+ 25
- 0
src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java View File

@@ -23,6 +23,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Resource;
import org.apache.tools.ant.types.resources.FileResource;
import org.apache.tools.ant.util.FileUtils;
@@ -34,10 +35,27 @@ import org.apache.tools.ant.util.FileUtils;
*/
public class ResourceContains implements Condition {
private Project project;
private String substring;
private Resource resource;
private boolean casesensitive = true;
/**
* Set this condition's Project.
* @param project Project
*/
public void setProject(Project project) {
this.project = project;
}
/**
* Get this condition's Project.
* @return Project
*/
public Project getProject() {
return project;
}
/**
* Sets the resource to search
* @param r
@@ -72,6 +90,13 @@ public class ResourceContains implements Condition {
+ "in <resourcecontains>");
}
if (substring.length() == 0) {
if (getProject() != null) {
getProject().log("ResourceContains: substring is empty; returning true", Project.MSG_VERBOSE);
}
return true;
}
if (resource.getSize() == 0) {
return false;
}


Loading…
Cancel
Save