Browse Source

Remove the portion of MatchingTask that duplicates logic present in

the Available task.  This isn't Perl - we want only one clean way to
do things here.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267624 13f79535-47bb-0310-9956-ffa450edef68
master
Sam Ruby 25 years ago
parent
commit
847348d801
1 changed files with 17 additions and 13 deletions
  1. +17
    -13
      src/main/org/apache/tools/ant/taskdefs/MatchingTask.java

+ 17
- 13
src/main/org/apache/tools/ant/taskdefs/MatchingTask.java View File

@@ -65,6 +65,7 @@ import java.util.*;
*
* @author Arnout J. Kuiper <a href="mailto:ajkuiper@wxs.nl">ajkuiper@wxs.nl</a>
* @author Stefano Mazzocchi <a href="mailto:stefano@apache.org">stefano@apache.org</a>
* @author Sam Ruby <a href="mailto:rubys@us.ibm.com">rubys@us.ibm.com</a>
* @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a>
*/

@@ -74,7 +75,18 @@ public abstract class MatchingTask extends Task {
protected Vector excludeList = new Vector();
protected boolean useDefaultExcludes = true;

// inner class to hold a name on list
/**
* provide access to properties from within the inner class
*/
protected String getProperty(String name) {
return project.getProperty(name);
}

/**
* inner class to hold a name on list. "If" and "Unless" attributes
* may be used to invalidate the entry based on the existence of a
* property (typically set thru the use of the Available task).
*/
public class NameEntry {
private boolean valid = true;
private String name;
@@ -82,20 +94,12 @@ public abstract class MatchingTask extends Task {
public String getName() { return valid ? name : null; }
public void setName(String name) { this.name = name; }

public void setIfClassFound(String name) {
try {
Class.forName(name);
} catch (ClassNotFoundException cnf) {
valid = false;
}
public void setIf(String name) {
if (getProperty(name) == null) valid = false;
}

public void setUnlessClassFound(String name) {
try {
Class.forName(name);
valid = false;
} catch (ClassNotFoundException cnf) {
}
public void setUnless(String name) {
if (getProperty(name) != null) valid = false;
}
}



Loading…
Cancel
Save