Browse Source

style

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274971 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 22 years ago
parent
commit
d70354a617
18 changed files with 250 additions and 68 deletions
  1. +23
    -0
      src/main/org/apache/tools/ant/types/selectors/BaseSelectorContainer.java
  2. +10
    -3
      src/main/org/apache/tools/ant/types/selectors/ContainsRegexpSelector.java
  3. +16
    -4
      src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java
  4. +23
    -6
      src/main/org/apache/tools/ant/types/selectors/DateSelector.java
  5. +10
    -3
      src/main/org/apache/tools/ant/types/selectors/DependSelector.java
  6. +22
    -13
      src/main/org/apache/tools/ant/types/selectors/DepthSelector.java
  7. +5
    -4
      src/main/org/apache/tools/ant/types/selectors/DifferentSelector.java
  8. +6
    -0
      src/main/org/apache/tools/ant/types/selectors/ExtendSelector.java
  9. +14
    -3
      src/main/org/apache/tools/ant/types/selectors/FilenameSelector.java
  10. +10
    -0
      src/main/org/apache/tools/ant/types/selectors/MajoritySelector.java
  11. +9
    -1
      src/main/org/apache/tools/ant/types/selectors/MappingSelector.java
  12. +12
    -0
      src/main/org/apache/tools/ant/types/selectors/PresentSelector.java
  13. +11
    -0
      src/main/org/apache/tools/ant/types/selectors/SelectSelector.java
  14. +42
    -24
      src/main/org/apache/tools/ant/types/selectors/SelectorContainer.java
  15. +2
    -2
      src/main/org/apache/tools/ant/types/selectors/SelectorScanner.java
  16. +1
    -1
      src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java
  17. +19
    -3
      src/main/org/apache/tools/ant/types/selectors/SizeSelector.java
  18. +15
    -1
      src/main/org/apache/tools/ant/types/selectors/TypeSelector.java

+ 23
- 0
src/main/org/apache/tools/ant/types/selectors/BaseSelectorContainer.java View File

@@ -80,6 +80,7 @@ public abstract class BaseSelectorContainer extends BaseSelector


/** /**
* Indicates whether there are any selectors here. * Indicates whether there are any selectors here.
* @return true if there are selectors
*/ */
public boolean hasSelectors() { public boolean hasSelectors() {
return !(selectorsList.isEmpty()); return !(selectorsList.isEmpty());
@@ -87,6 +88,7 @@ public abstract class BaseSelectorContainer extends BaseSelector


/** /**
* Gives the count of the number of selectors in this container * Gives the count of the number of selectors in this container
* @return the number of selectors
*/ */
public int selectorCount() { public int selectorCount() {
return selectorsList.size(); return selectorsList.size();
@@ -94,6 +96,8 @@ public abstract class BaseSelectorContainer extends BaseSelector


/** /**
* Returns the set of selectors as an array. * Returns the set of selectors as an array.
* @param p the current project
* @return an array of selectors
*/ */
public FileSelector[] getSelectors(Project p) { public FileSelector[] getSelectors(Project p) {
FileSelector[] result = new FileSelector[selectorsList.size()]; FileSelector[] result = new FileSelector[selectorsList.size()];
@@ -103,6 +107,7 @@ public abstract class BaseSelectorContainer extends BaseSelector


/** /**
* Returns an enumerator for accessing the set of selectors. * Returns an enumerator for accessing the set of selectors.
* @return an enumerator for the selectors
*/ */
public Enumeration selectorElements() { public Enumeration selectorElements() {
return selectorsList.elements(); return selectorsList.elements();
@@ -189,6 +194,7 @@ public abstract class BaseSelectorContainer extends BaseSelector


/** /**
* add a "Select" selector entry on the selector list * add a "Select" selector entry on the selector list
* @param selector the selector to add
*/ */
public void addSelector(SelectSelector selector) { public void addSelector(SelectSelector selector) {
appendSelector(selector); appendSelector(selector);
@@ -196,6 +202,7 @@ public abstract class BaseSelectorContainer extends BaseSelector


/** /**
* add an "And" selector entry on the selector list * add an "And" selector entry on the selector list
* @param selector the selector to add
*/ */
public void addAnd(AndSelector selector) { public void addAnd(AndSelector selector) {
appendSelector(selector); appendSelector(selector);
@@ -203,6 +210,7 @@ public abstract class BaseSelectorContainer extends BaseSelector


/** /**
* add an "Or" selector entry on the selector list * add an "Or" selector entry on the selector list
* @param selector the selector to add
*/ */
public void addOr(OrSelector selector) { public void addOr(OrSelector selector) {
appendSelector(selector); appendSelector(selector);
@@ -210,6 +218,7 @@ public abstract class BaseSelectorContainer extends BaseSelector


/** /**
* add a "Not" selector entry on the selector list * add a "Not" selector entry on the selector list
* @param selector the selector to add
*/ */
public void addNot(NotSelector selector) { public void addNot(NotSelector selector) {
appendSelector(selector); appendSelector(selector);
@@ -217,6 +226,7 @@ public abstract class BaseSelectorContainer extends BaseSelector


/** /**
* add a "None" selector entry on the selector list * add a "None" selector entry on the selector list
* @param selector the selector to add
*/ */
public void addNone(NoneSelector selector) { public void addNone(NoneSelector selector) {
appendSelector(selector); appendSelector(selector);
@@ -224,6 +234,7 @@ public abstract class BaseSelectorContainer extends BaseSelector


/** /**
* add a majority selector entry on the selector list * add a majority selector entry on the selector list
* @param selector the selector to add
*/ */
public void addMajority(MajoritySelector selector) { public void addMajority(MajoritySelector selector) {
appendSelector(selector); appendSelector(selector);
@@ -231,6 +242,7 @@ public abstract class BaseSelectorContainer extends BaseSelector


/** /**
* add a selector date entry on the selector list * add a selector date entry on the selector list
* @param selector the selector to add
*/ */
public void addDate(DateSelector selector) { public void addDate(DateSelector selector) {
appendSelector(selector); appendSelector(selector);
@@ -238,6 +250,7 @@ public abstract class BaseSelectorContainer extends BaseSelector


/** /**
* add a selector size entry on the selector list * add a selector size entry on the selector list
* @param selector the selector to add
*/ */
public void addSize(SizeSelector selector) { public void addSize(SizeSelector selector) {
appendSelector(selector); appendSelector(selector);
@@ -245,6 +258,7 @@ public abstract class BaseSelectorContainer extends BaseSelector


/** /**
* add a selector filename entry on the selector list * add a selector filename entry on the selector list
* @param selector the selector to add
*/ */
public void addFilename(FilenameSelector selector) { public void addFilename(FilenameSelector selector) {
appendSelector(selector); appendSelector(selector);
@@ -252,6 +266,7 @@ public abstract class BaseSelectorContainer extends BaseSelector


/** /**
* add an extended selector entry on the selector list * add an extended selector entry on the selector list
* @param selector the selector to add
*/ */
public void addCustom(ExtendSelector selector) { public void addCustom(ExtendSelector selector) {
appendSelector(selector); appendSelector(selector);
@@ -259,6 +274,7 @@ public abstract class BaseSelectorContainer extends BaseSelector


/** /**
* add a contains selector entry on the selector list * add a contains selector entry on the selector list
* @param selector the selector to add
*/ */
public void addContains(ContainsSelector selector) { public void addContains(ContainsSelector selector) {
appendSelector(selector); appendSelector(selector);
@@ -266,6 +282,7 @@ public abstract class BaseSelectorContainer extends BaseSelector


/** /**
* add a present selector entry on the selector list * add a present selector entry on the selector list
* @param selector the selector to add
*/ */
public void addPresent(PresentSelector selector) { public void addPresent(PresentSelector selector) {
appendSelector(selector); appendSelector(selector);
@@ -273,6 +290,7 @@ public abstract class BaseSelectorContainer extends BaseSelector


/** /**
* add a depth selector entry on the selector list * add a depth selector entry on the selector list
* @param selector the selector to add
*/ */
public void addDepth(DepthSelector selector) { public void addDepth(DepthSelector selector) {
appendSelector(selector); appendSelector(selector);
@@ -280,6 +298,7 @@ public abstract class BaseSelectorContainer extends BaseSelector


/** /**
* add a depends selector entry on the selector list * add a depends selector entry on the selector list
* @param selector the selector to add
*/ */
public void addDepend(DependSelector selector) { public void addDepend(DependSelector selector) {
appendSelector(selector); appendSelector(selector);
@@ -287,6 +306,7 @@ public abstract class BaseSelectorContainer extends BaseSelector


/** /**
* adds a different selector to the selector list * adds a different selector to the selector list
* @param selector the selector to add
*/ */
public void addDifferent(DifferentSelector selector) { public void addDifferent(DifferentSelector selector) {
appendSelector(selector); appendSelector(selector);
@@ -294,6 +314,7 @@ public abstract class BaseSelectorContainer extends BaseSelector


/** /**
* adds a type selector to the selector list * adds a type selector to the selector list
* @param selector the selector to add
*/ */
public void addType(TypeSelector selector) { public void addType(TypeSelector selector) {
appendSelector(selector); appendSelector(selector);
@@ -301,6 +322,7 @@ public abstract class BaseSelectorContainer extends BaseSelector


/** /**
* add a regular expression selector entry on the selector list * add a regular expression selector entry on the selector list
* @param selector the selector to add
*/ */
public void addContainsRegexp(ContainsRegexpSelector selector) { public void addContainsRegexp(ContainsRegexpSelector selector) {
appendSelector(selector); appendSelector(selector);
@@ -309,6 +331,7 @@ public abstract class BaseSelectorContainer extends BaseSelector


/** /**
* add an arbitary selector * add an arbitary selector
* @param selector the selector to add
* @since Ant 1.6 * @since Ant 1.6
*/ */
public void add(FileSelector selector) { public void add(FileSelector selector) {


+ 10
- 3
src/main/org/apache/tools/ant/types/selectors/ContainsRegexpSelector.java View File

@@ -76,11 +76,18 @@ public class ContainsRegexpSelector extends BaseExtendSelector {
private String userProvidedExpression = null; private String userProvidedExpression = null;
private RegularExpression myRegExp = null; private RegularExpression myRegExp = null;
private Regexp myExpression = null; private Regexp myExpression = null;
public final static String EXPRESSION_KEY = "expression";
/** Key to used for parameterized custom selector */
public static final String EXPRESSION_KEY = "expression";


/**
* Creates a new <code>ContainsRegexpSelector</code> instance.
*/
public ContainsRegexpSelector() { public ContainsRegexpSelector() {
} }


/**
* @return a string describing this object
*/
public String toString() { public String toString() {
StringBuffer buf = new StringBuffer( StringBuffer buf = new StringBuffer(
"{containsregexpselector expression: "); "{containsregexpselector expression: ");
@@ -162,7 +169,7 @@ public class ContainsRegexpSelector extends BaseExtendSelector {


while (teststr != null) { while (teststr != null) {


if (myExpression.matches(teststr) == true) {
if (myExpression.matches(teststr)) {
return true; return true;
} }
teststr = in.readLine(); teststr = in.readLine();
@@ -176,7 +183,7 @@ public class ContainsRegexpSelector extends BaseExtendSelector {
try { try {
in.close(); in.close();
} catch (Exception e) { } catch (Exception e) {
throw new BuildException("Could not close file "
throw new BuildException("Could not close file "
+ filename); + filename);
} }
} }


+ 16
- 4
src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java View File

@@ -76,14 +76,26 @@ public class ContainsSelector extends BaseExtendSelector {
private String contains = null; private String contains = null;
private boolean casesensitive = true; private boolean casesensitive = true;
private boolean ignorewhitespace = false; private boolean ignorewhitespace = false;
public final static String CONTAINS_KEY = "text";
public final static String CASE_KEY = "casesensitive";
public final static String WHITESPACE_KEY = "ignorewhitespace";
/** Key to used for parameterized custom selector */
public static final String EXPRESSION_KEY = "expression";
/** Used for parameterized custom selector */
public static final String CONTAINS_KEY = "text";
/** Used for parameterized custom selector */
public static final String CASE_KEY = "casesensitive";
/** Used for parameterized custom selector */
public static final String WHITESPACE_KEY = "ignorewhitespace";




/**
* Creates a new <code>ContainsSelector</code> instance.
*
*/
public ContainsSelector() { public ContainsSelector() {
} }


/**
* @return a string describing this object
*/
public String toString() { public String toString() {
StringBuffer buf = new StringBuffer("{containsselector text: "); StringBuffer buf = new StringBuffer("{containsselector text: ");
buf.append(contains); buf.append(contains);
@@ -218,7 +230,7 @@ public class ContainsSelector extends BaseExtendSelector {
try { try {
in.close(); in.close();
} catch (Exception e) { } catch (Exception e) {
throw new BuildException("Could not close file "
throw new BuildException("Could not close file "
+ filename); + filename);
} }
} }


+ 23
- 6
src/main/org/apache/tools/ant/types/selectors/DateSelector.java View File

@@ -77,18 +77,30 @@ public class DateSelector extends BaseExtendSelector {
private boolean includeDirs = false; private boolean includeDirs = false;
private int granularity = 0; private int granularity = 0;
private int cmp = 2; private int cmp = 2;
public final static String MILLIS_KEY = "millis";
public final static String DATETIME_KEY = "datetime";
public final static String CHECKDIRS_KEY = "checkdirs";
public final static String GRANULARITY_KEY = "granularity";
public final static String WHEN_KEY = "when";
/** Key to used for parameterized custom selector */
public static final String MILLIS_KEY = "millis";
/** Key to used for parameterized custom selector */
public static final String DATETIME_KEY = "datetime";
/** Key to used for parameterized custom selector */
public static final String CHECKDIRS_KEY = "checkdirs";
/** Key to used for parameterized custom selector */
public static final String GRANULARITY_KEY = "granularity";
/** Key to used for parameterized custom selector */
public static final String WHEN_KEY = "when";


/**
* Creates a new <code>DateSelector</code> instance.
*
*/
public DateSelector() { public DateSelector() {
if (Os.isFamily("dos")) { if (Os.isFamily("dos")) {
granularity = 2000; granularity = 2000;
} }
} }


/**
* @return a string describing this object
*/
public String toString() { public String toString() {
StringBuffer buf = new StringBuffer("{dateselector date: "); StringBuffer buf = new StringBuffer("{dateselector date: ");
buf.append(dateTime); buf.append(dateTime);
@@ -118,6 +130,7 @@ public class DateSelector extends BaseExtendSelector {


/** /**
* Returns the millisecond value the selector is set for. * Returns the millisecond value the selector is set for.
* @return the millisecond value
*/ */
public long getMillis() { public long getMillis() {
return millis; return millis;
@@ -163,6 +176,7 @@ public class DateSelector extends BaseExtendSelector {
/** /**
* Sets the number of milliseconds leeway we will give before we consider * Sets the number of milliseconds leeway we will give before we consider
* a file not to have matched a date. * a file not to have matched a date.
* @param granularity the number of milliconds leeway
*/ */
public void setGranularity(int granularity) { public void setGranularity(int granularity) {
this.granularity = granularity; this.granularity = granularity;
@@ -246,7 +260,7 @@ public class DateSelector extends BaseExtendSelector {
*/ */
public boolean isSelected(File basedir, String filename, File file) { public boolean isSelected(File basedir, String filename, File file) {
validate(); validate();
if (file.isDirectory() && (includeDirs == false)) {
if (file.isDirectory() && (!includeDirs)) {
return true; return true;
} }
if (cmp == 0) { if (cmp == 0) {
@@ -263,6 +277,9 @@ public class DateSelector extends BaseExtendSelector {
* <p> * <p>
*/ */
public static class TimeComparisons extends EnumeratedAttribute { public static class TimeComparisons extends EnumeratedAttribute {
/**
* @return the values as an array of strings
*/
public String[] getValues() { public String[] getValues() {
return new String[]{"before", "after", "equal"}; return new String[]{"before", "after", "equal"};
} }


+ 10
- 3
src/main/org/apache/tools/ant/types/selectors/DependSelector.java View File

@@ -67,10 +67,17 @@ import java.io.File;
*/ */
public class DependSelector extends MappingSelector { public class DependSelector extends MappingSelector {


/**
* Creates a new <code>DependSelector</code> instance.
*
*/
public DependSelector() { public DependSelector() {


} }


/**
* @return a string describing this object
*/
public String toString() { public String toString() {
StringBuffer buf = new StringBuffer("{dependselector targetdir: "); StringBuffer buf = new StringBuffer("{dependselector targetdir: ");
if (targetdir == null) { if (targetdir == null) {
@@ -94,9 +101,9 @@ public class DependSelector extends MappingSelector {


/** /**
* this test is our selection test that compared the file with the destfile * this test is our selection test that compared the file with the destfile
* @param srcfile
* @param destfile
* @return
* @param srcfile the source file
* @param destfile the destination file
* @return true if destination is out of date
*/ */
public boolean selectionTest(File srcfile, File destfile) { public boolean selectionTest(File srcfile, File destfile) {
boolean selected = SelectorUtils.isOutOfDate(srcfile, destfile, boolean selected = SelectorUtils.isOutOfDate(srcfile, destfile,


+ 22
- 13
src/main/org/apache/tools/ant/types/selectors/DepthSelector.java View File

@@ -71,12 +71,21 @@ public class DepthSelector extends BaseExtendSelector {


public int min = -1; public int min = -1;
public int max = -1; public int max = -1;
public final static String MIN_KEY = "min";
public final static String MAX_KEY = "max";
/** Used for parameterized custom selector */
public static final String MIN_KEY = "min";
/** Used for parameterized custom selector */
public static final String MAX_KEY = "max";


/**
* Creates a new <code>DepthSelector</code> instance.
*
*/
public DepthSelector() { public DepthSelector() {
} }


/**
* @return a string describing this object
*/
public String toString() { public String toString() {
StringBuffer buf = new StringBuffer("{depthselector min: "); StringBuffer buf = new StringBuffer("{depthselector min: ");
buf.append(min); buf.append(min);
@@ -169,20 +178,20 @@ public class DepthSelector extends BaseExtendSelector {


int depth = -1; int depth = -1;
// If you felt daring, you could cache the basedir absolute path // If you felt daring, you could cache the basedir absolute path
String abs_base = basedir.getAbsolutePath();
String abs_file = file.getAbsolutePath();
StringTokenizer tok_base = new StringTokenizer(abs_base,
String absBase = basedir.getAbsolutePath();
String absFile = file.getAbsolutePath();
StringTokenizer tokBase = new StringTokenizer(absBase,
File.separator); File.separator);
StringTokenizer tok_file = new StringTokenizer(abs_file,
StringTokenizer tokFile = new StringTokenizer(absFile,
File.separator); File.separator);
while (tok_file.hasMoreTokens()) {
String filetoken = tok_file.nextToken();
if (tok_base.hasMoreTokens()) {
String basetoken = tok_base.nextToken();
while (tokFile.hasMoreTokens()) {
String filetoken = tokFile.nextToken();
if (tokBase.hasMoreTokens()) {
String basetoken = tokBase.nextToken();
// Sanity check. Ditch it if you want faster performance // Sanity check. Ditch it if you want faster performance
if (!basetoken.equals(filetoken)) { if (!basetoken.equals(filetoken)) {
throw new BuildException("File " + filename throw new BuildException("File " + filename
+ " does not appear within " + abs_base
+ " does not appear within " + absBase
+ "directory"); + "directory");
} }
} else { } else {
@@ -192,9 +201,9 @@ public class DepthSelector extends BaseExtendSelector {
} }
} }
} }
if (tok_base.hasMoreTokens()) {
if (tokBase.hasMoreTokens()) {
throw new BuildException("File " + filename throw new BuildException("File " + filename
+ " is outside of " + abs_base + "directory tree");
+ " is outside of " + absBase + "directory tree");
} }
if (min > -1 && depth < min) { if (min > -1 && depth < min) {
return false; return false;


+ 5
- 4
src/main/org/apache/tools/ant/types/selectors/DifferentSelector.java View File

@@ -78,6 +78,7 @@ import java.io.IOException;
* over as few files as possible, perhaps following it with an &lt;uptodate;&gt * over as few files as possible, perhaps following it with an &lt;uptodate;&gt
* to keep the descendent routines conditional. * to keep the descendent routines conditional.
* *
* @author not specified
*/ */
public class DifferentSelector extends MappingSelector { public class DifferentSelector extends MappingSelector {


@@ -88,7 +89,7 @@ public class DifferentSelector extends MappingSelector {


/** /**
* This flag tells the selector to ignore file times in the comparison * This flag tells the selector to ignore file times in the comparison
* @param ignoreFileTimes
* @param ignoreFileTimes if true ignore file times
*/ */
public void setIgnoreFileTimes(boolean ignoreFileTimes) { public void setIgnoreFileTimes(boolean ignoreFileTimes) {
this.ignoreFileTimes = ignoreFileTimes; this.ignoreFileTimes = ignoreFileTimes;
@@ -96,9 +97,9 @@ public class DifferentSelector extends MappingSelector {


/** /**
* this test is our selection test that compared the file with the destfile * this test is our selection test that compared the file with the destfile
* @param srcfile
* @param destfile
* @return
* @param srcfile the source file
* @param destfile the destination file
* @return true if the files are different
*/ */
protected boolean selectionTest(File srcfile, File destfile) { protected boolean selectionTest(File srcfile, File destfile) {




+ 6
- 0
src/main/org/apache/tools/ant/types/selectors/ExtendSelector.java View File

@@ -138,6 +138,7 @@ public class ExtendSelector extends BaseSelector {


/** /**
* Set the classpath to load the classname specified using an attribute. * Set the classpath to load the classname specified using an attribute.
* @param classpath the classpath to use
*/ */
public final void setClasspath(Path classpath) { public final void setClasspath(Path classpath) {
if (isReference()) { if (isReference()) {
@@ -152,6 +153,7 @@ public class ExtendSelector extends BaseSelector {


/** /**
* Specify the classpath to use to load the Selector (nested element). * Specify the classpath to use to load the Selector (nested element).
* @return a classpath to be configured
*/ */
public final Path createClasspath() { public final Path createClasspath() {
if (isReference()) { if (isReference()) {
@@ -165,6 +167,7 @@ public class ExtendSelector extends BaseSelector {


/** /**
* Get the classpath * Get the classpath
* @return the classpath
*/ */
public final Path getClasspath() { public final Path getClasspath() {
return classpath; return classpath;
@@ -173,6 +176,7 @@ public class ExtendSelector extends BaseSelector {
/** /**
* Set the classpath to use for loading a custom selector by using * Set the classpath to use for loading a custom selector by using
* a reference. * a reference.
* @param r a reference to the classpath
*/ */
public void setClasspathref(Reference r) { public void setClasspathref(Reference r) {
if (isReference()) { if (isReference()) {
@@ -211,6 +215,8 @@ public class ExtendSelector extends BaseSelector {
* since we know we must have them all by now. And since we must know * since we know we must have them all by now. And since we must know
* both classpath and classname, creating the class is deferred to here * both classpath and classname, creating the class is deferred to here
* as well. * as well.
*
* @exception BuildException if an error occurs
*/ */
public boolean isSelected(File basedir, String filename, File file) public boolean isSelected(File basedir, String filename, File file)
throws BuildException { throws BuildException {


+ 14
- 3
src/main/org/apache/tools/ant/types/selectors/FilenameSelector.java View File

@@ -69,14 +69,25 @@ public class FilenameSelector extends BaseExtendSelector {


private String pattern = null; private String pattern = null;
private boolean casesensitive = true; private boolean casesensitive = true;

private boolean negated = false; private boolean negated = false;
public final static String NAME_KEY = "name";
public final static String CASE_KEY = "casesensitive";
public final static String NEGATE_KEY = "negate";
/** Used for parameterized custom selector */
public static final String NAME_KEY = "name";
/** Used for parameterized custom selector */
public static final String CASE_KEY = "casesensitive";
/** Used for parameterized custom selector */
public static final String NEGATE_KEY = "negate";


/**
* Creates a new <code>FilenameSelector</code> instance.
*
*/
public FilenameSelector() { public FilenameSelector() {
} }


/**
* @return a string describing this object
*/
public String toString() { public String toString() {
StringBuffer buf = new StringBuffer("{filenameselector name: "); StringBuffer buf = new StringBuffer("{filenameselector name: ");
buf.append(pattern); buf.append(pattern);


+ 10
- 0
src/main/org/apache/tools/ant/types/selectors/MajoritySelector.java View File

@@ -79,6 +79,9 @@ public class MajoritySelector extends BaseSelectorContainer {
public MajoritySelector() { public MajoritySelector() {
} }


/**
* @return a string describing this object
*/
public String toString() { public String toString() {
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
if (hasSelectors()) { if (hasSelectors()) {
@@ -89,6 +92,13 @@ public class MajoritySelector extends BaseSelectorContainer {
return buf.toString(); return buf.toString();
} }


/**
* A attribute to specify what will happen if number
* of yes votes is the same as the number of no votes
* defaults to true
*
* @param tiebreaker the value to give if there is a tie
*/
public void setAllowtie(boolean tiebreaker) { public void setAllowtie(boolean tiebreaker) {
allowtie = tiebreaker; allowtie = tiebreaker;
} }


+ 9
- 1
src/main/org/apache/tools/ant/types/selectors/MappingSelector.java View File

@@ -65,6 +65,7 @@ import java.io.File;
/** /**
* A mapping selector is an abstract class adding mapping support to the base * A mapping selector is an abstract class adding mapping support to the base
* selector * selector
* @author not specified
*/ */
public abstract class MappingSelector extends BaseSelector { public abstract class MappingSelector extends BaseSelector {
protected File targetdir = null; protected File targetdir = null;
@@ -72,6 +73,10 @@ public abstract class MappingSelector extends BaseSelector {
protected FileNameMapper map = null; protected FileNameMapper map = null;
protected int granularity = 0; protected int granularity = 0;


/**
* Creates a new <code>MappingSelector</code> instance.
*
*/
public MappingSelector() { public MappingSelector() {
if (Os.isFamily("dos")) { if (Os.isFamily("dos")) {
granularity = 2000; granularity = 2000;
@@ -91,6 +96,8 @@ public abstract class MappingSelector extends BaseSelector {


/** /**
* Defines the FileNameMapper to use (nested mapper element). * Defines the FileNameMapper to use (nested mapper element).
* @return a mapper to be configured
* @throws BuildException if more that one mapper defined
*/ */
public Mapper createMapper() throws BuildException { public Mapper createMapper() throws BuildException {
if (mapperElement != null) { if (mapperElement != null) {
@@ -155,7 +162,7 @@ public abstract class MappingSelector extends BaseSelector {
* this test is our selection test that compared the file with the destfile * this test is our selection test that compared the file with the destfile
* @param srcfile file to test; may be null * @param srcfile file to test; may be null
* @param destfile destination file * @param destfile destination file
* @return
* @return true if source file compares with destination file
*/ */
protected abstract boolean selectionTest(File srcfile, File destfile); protected abstract boolean selectionTest(File srcfile, File destfile);


@@ -163,6 +170,7 @@ public abstract class MappingSelector extends BaseSelector {
* Sets the number of milliseconds leeway we will give before we consider * Sets the number of milliseconds leeway we will give before we consider
* a file out of date. Defaults to 2000 on MS-DOS derivatives as the FAT * a file out of date. Defaults to 2000 on MS-DOS derivatives as the FAT
* file system. * file system.
* @param granularity the leeway in milliseconds
*/ */
public void setGranularity(int granularity) { public void setGranularity(int granularity) {
this.granularity = granularity; this.granularity = granularity;


+ 12
- 0
src/main/org/apache/tools/ant/types/selectors/PresentSelector.java View File

@@ -78,9 +78,16 @@ public class PresentSelector extends BaseSelector {
private FileNameMapper map = null; private FileNameMapper map = null;
private boolean destmustexist = true; private boolean destmustexist = true;


/**
* Creates a new <code>PresentSelector</code> instance.
*
*/
public PresentSelector() { public PresentSelector() {
} }


/**
* @return a string describing this object
*/
public String toString() { public String toString() {
StringBuffer buf = new StringBuffer("{presentselector targetdir: "); StringBuffer buf = new StringBuffer("{presentselector targetdir: ");
if (targetdir == null) { if (targetdir == null) {
@@ -115,6 +122,8 @@ public class PresentSelector extends BaseSelector {


/** /**
* Defines the FileNameMapper to use (nested mapper element). * Defines the FileNameMapper to use (nested mapper element).
* @return a mapper to be configured
* @throws BuildException if more that one mapper defined
*/ */
public Mapper createMapper() throws BuildException { public Mapper createMapper() throws BuildException {
if (mapperElement != null) { if (mapperElement != null) {
@@ -197,6 +206,9 @@ public class PresentSelector extends BaseSelector {
* presence is allowed and required. * presence is allowed and required.
*/ */
public static class FilePresence extends EnumeratedAttribute { public static class FilePresence extends EnumeratedAttribute {
/**
* @return the values as an array of strings
*/
public String[] getValues() { public String[] getValues() {
return new String[]{"srconly", "both"}; return new String[]{"srconly", "both"};
} }


+ 11
- 0
src/main/org/apache/tools/ant/types/selectors/SelectSelector.java View File

@@ -81,6 +81,9 @@ public class SelectSelector extends BaseSelectorContainer {
public SelectSelector() { public SelectSelector() {
} }


/**
* @return a string describing this object
*/
public String toString() { public String toString() {
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
if (hasSelectors()) { if (hasSelectors()) {
@@ -111,6 +114,7 @@ public class SelectSelector extends BaseSelectorContainer {


/** /**
* Indicates whether there are any selectors here. * Indicates whether there are any selectors here.
* @return whether any selectors are in this container
*/ */
public boolean hasSelectors() { public boolean hasSelectors() {
if (isReference()) { if (isReference()) {
@@ -121,6 +125,7 @@ public class SelectSelector extends BaseSelectorContainer {


/** /**
* Gives the count of the number of selectors in this container * Gives the count of the number of selectors in this container
* @return the number of selectors in this container
*/ */
public int selectorCount() { public int selectorCount() {
if (isReference()) { if (isReference()) {
@@ -131,6 +136,8 @@ public class SelectSelector extends BaseSelectorContainer {


/** /**
* Returns the set of selectors as an array. * Returns the set of selectors as an array.
* @param p the current project
* @return an array of selectors in this container
*/ */
public FileSelector[] getSelectors(Project p) { public FileSelector[] getSelectors(Project p) {
if (isReference()) { if (isReference()) {
@@ -141,6 +148,7 @@ public class SelectSelector extends BaseSelectorContainer {


/** /**
* Returns an enumerator for accessing the set of selectors. * Returns an enumerator for accessing the set of selectors.
* @return an enumerator that goes through each of the selectors
*/ */
public Enumeration selectorElements() { public Enumeration selectorElements() {
if (isReference()) { if (isReference()) {
@@ -177,6 +185,7 @@ public class SelectSelector extends BaseSelectorContainer {
/** /**
* Ensures that the selector passes the conditions placed * Ensures that the selector passes the conditions placed
* on it with <code>if</code> and <code>unless</code>. * on it with <code>if</code> and <code>unless</code>.
* @return true if conditions are passed
*/ */
public boolean passesConditions() { public boolean passesConditions() {
if (ifProperty != null if (ifProperty != null
@@ -192,6 +201,7 @@ public class SelectSelector extends BaseSelectorContainer {
/** /**
* Sets the if attribute to a property which must exist for the * Sets the if attribute to a property which must exist for the
* selector to select any files. * selector to select any files.
* @param ifProperty the property to check
*/ */
public void setIf(String ifProperty) { public void setIf(String ifProperty) {
this.ifProperty = ifProperty; this.ifProperty = ifProperty;
@@ -200,6 +210,7 @@ public class SelectSelector extends BaseSelectorContainer {
/** /**
* Sets the unless attribute to a property which cannot exist for the * Sets the unless attribute to a property which cannot exist for the
* selector to select any files. * selector to select any files.
* @param unlessProperty the property to check
*/ */
public void setUnless(String unlessProperty) { public void setUnless(String unlessProperty) {
this.unlessProperty = unlessProperty; this.unlessProperty = unlessProperty;


+ 42
- 24
src/main/org/apache/tools/ant/types/selectors/SelectorContainer.java View File

@@ -71,129 +71,147 @@ public interface SelectorContainer {
* *
* @return whether any selectors are in this container * @return whether any selectors are in this container
*/ */
public boolean hasSelectors();
boolean hasSelectors();


/** /**
* Gives the count of the number of selectors in this container * Gives the count of the number of selectors in this container
* *
* @return the number of selectors in this container * @return the number of selectors in this container
*/ */
public int selectorCount();
int selectorCount();


/** /**
* Returns the set of selectors as an array. * Returns the set of selectors as an array.
*
* @param p the current project
* @return an array of selectors in this container * @return an array of selectors in this container
*/ */
public FileSelector[] getSelectors(Project p);
FileSelector[] getSelectors(Project p);


/** /**
* Returns an enumerator for accessing the set of selectors. * Returns an enumerator for accessing the set of selectors.
* *
* @return an enumerator that goes through each of the selectors * @return an enumerator that goes through each of the selectors
*/ */
public Enumeration selectorElements();
Enumeration selectorElements();


/** /**
* Add a new selector into this container. * Add a new selector into this container.
* *
* @param selector the new selector to add * @param selector the new selector to add
*/ */
public void appendSelector(FileSelector selector);
void appendSelector(FileSelector selector);


/* Methods below all add specific selectors */ /* Methods below all add specific selectors */


/** /**
* add a "Select" selector entry on the selector list * add a "Select" selector entry on the selector list
* @param selector the selector to add
*/ */
public void addSelector(SelectSelector selector);
void addSelector(SelectSelector selector);


/** /**
* add an "And" selector entry on the selector list * add an "And" selector entry on the selector list
* @param selector the selector to add
*/ */
public void addAnd(AndSelector selector);
void addAnd(AndSelector selector);


/** /**
* add an "Or" selector entry on the selector list * add an "Or" selector entry on the selector list
* @param selector the selector to add
*/ */
public void addOr(OrSelector selector);
void addOr(OrSelector selector);


/** /**
* add a "Not" selector entry on the selector list * add a "Not" selector entry on the selector list
* @param selector the selector to add
*/ */
public void addNot(NotSelector selector);
void addNot(NotSelector selector);


/** /**
* add a "None" selector entry on the selector list * add a "None" selector entry on the selector list
* @param selector the selector to add
*/ */
public void addNone(NoneSelector selector);
void addNone(NoneSelector selector);


/** /**
* add a majority selector entry on the selector list * add a majority selector entry on the selector list
* @param selector the selector to add
*/ */
public void addMajority(MajoritySelector selector);
void addMajority(MajoritySelector selector);


/** /**
* add a selector date entry on the selector list * add a selector date entry on the selector list
* @param selector the selector to add
*/ */
public void addDate(DateSelector selector);
void addDate(DateSelector selector);


/** /**
* add a selector size entry on the selector list * add a selector size entry on the selector list
* @param selector the selector to add
*/ */
public void addSize(SizeSelector selector);
void addSize(SizeSelector selector);


/** /**
* add a selector filename entry on the selector list * add a selector filename entry on the selector list
* @param selector the selector to add
*/ */
public void addFilename(FilenameSelector selector);
void addFilename(FilenameSelector selector);


/** /**
* add an extended selector entry on the selector list * add an extended selector entry on the selector list
* @param selector the selector to add
*/ */
public void addCustom(ExtendSelector selector);
void addCustom(ExtendSelector selector);


/** /**
* add a contains selector entry on the selector list * add a contains selector entry on the selector list
* @param selector the selector to add
*/ */
public void addContains(ContainsSelector selector);
void addContains(ContainsSelector selector);


/** /**
* add a present selector entry on the selector list * add a present selector entry on the selector list
* @param selector the selector to add
*/ */
public void addPresent(PresentSelector selector);
void addPresent(PresentSelector selector);


/** /**
* add a depth selector entry on the selector list * add a depth selector entry on the selector list
* @param selector the selector to add
*/ */
public void addDepth(DepthSelector selector);
void addDepth(DepthSelector selector);


/** /**
* add a depends selector entry on the selector list * add a depends selector entry on the selector list
* @param selector the selector to add
*/ */
public void addDepend(DependSelector selector);
void addDepend(DependSelector selector);


/** /**
* add a regular expression selector entry on the selector list * add a regular expression selector entry on the selector list
* @param selector the selector to add
*/ */
public void addContainsRegexp(ContainsRegexpSelector selector);
void addContainsRegexp(ContainsRegexpSelector selector);


/** /**
* add the type selector * add the type selector
* @param selector the selector to add
* @since ant 1.6 * @since ant 1.6
*/ */
public void addType(TypeSelector selector);
void addType(TypeSelector selector);


/** /**
* add the different selector * add the different selector
* @param selector the selector to add
* @since ant 1.6 * @since ant 1.6
*/ */
public void addDifferent(DifferentSelector selector);
void addDifferent(DifferentSelector selector);


/** /**
* add an arbitary selector * add an arbitary selector
* @param selector the selector to add
* @since Ant 1.6 * @since Ant 1.6
*/ */
public void add(FileSelector selector);
void add(FileSelector selector);
} }



+ 2
- 2
src/main/org/apache/tools/ant/types/selectors/SelectorScanner.java View File

@@ -73,14 +73,14 @@ public interface SelectorScanner {
* *
* @return list of directories not selected * @return list of directories not selected
*/ */
public String[] getDeselectedDirectories();
String[] getDeselectedDirectories();


/** /**
* Files which were selected out of a scan. * Files which were selected out of a scan.
* *
* @return list of files not selected * @return list of files not selected
*/ */
public String[] getDeselectedFiles();
String[] getDeselectedFiles();




} }

+ 1
- 1
src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java View File

@@ -674,7 +674,7 @@ public final class SelectorUtils {


/** /**
* removes from a pattern all tokens to the right containing wildcards * removes from a pattern all tokens to the right containing wildcards
* @param input
* @param input the input string
* @return the leftmost part of the pattern without wildcards * @return the leftmost part of the pattern without wildcards
*/ */
public static String rtrimWildcardTokens(String input) { public static String rtrimWildcardTokens(String input) {


+ 19
- 3
src/main/org/apache/tools/ant/types/selectors/SizeSelector.java View File

@@ -71,13 +71,23 @@ public class SizeSelector extends BaseExtendSelector {
private long multiplier = 1; private long multiplier = 1;
private long sizelimit = -1; private long sizelimit = -1;
private int cmp = 2; private int cmp = 2;
public final static String SIZE_KEY = "value";
public final static String UNITS_KEY = "units";
public final static String WHEN_KEY = "when";
/** Used for parameterized custom selector */
public static final String SIZE_KEY = "value";
/** Used for parameterized custom selector */
public static final String UNITS_KEY = "units";
/** Used for parameterized custom selector */
public static final String WHEN_KEY = "when";


/**
* Creates a new <code>SizeSelector</code> instance.
*
*/
public SizeSelector() { public SizeSelector() {
} }


/**
* @return a string describing this object
*/
public String toString() { public String toString() {
StringBuffer buf = new StringBuffer("{sizeselector value: "); StringBuffer buf = new StringBuffer("{sizeselector value: ");
buf.append(sizelimit); buf.append(sizelimit);
@@ -270,6 +280,9 @@ public class SizeSelector extends BaseExtendSelector {
* standard. It disambiguates things for us, though. * standard. It disambiguates things for us, though.
*/ */
public static class ByteUnits extends EnumeratedAttribute { public static class ByteUnits extends EnumeratedAttribute {
/**
* @return the values as an array of strings
*/
public String[] getValues() { public String[] getValues() {
return new String[]{"K", "k", "kilo", "KILO", return new String[]{"K", "k", "kilo", "KILO",
"Ki", "KI", "ki", "kibi", "KIBI", "Ki", "KI", "ki", "kibi", "KIBI",
@@ -287,6 +300,9 @@ public class SizeSelector extends BaseExtendSelector {
* Enumerated attribute with the values for size comparison. * Enumerated attribute with the values for size comparison.
*/ */
public static class SizeComparisons extends EnumeratedAttribute { public static class SizeComparisons extends EnumeratedAttribute {
/**
* @return the values as an array of strings
*/
public String[] getValues() { public String[] getValues() {
return new String[]{"less", "more", "equal"}; return new String[]{"less", "more", "equal"};
} }


+ 15
- 1
src/main/org/apache/tools/ant/types/selectors/TypeSelector.java View File

@@ -69,11 +69,19 @@ public class TypeSelector extends BaseExtendSelector {


private String type = null; private String type = null;


public final static String TYPE_KEY = "type";
/** Key to used for parameterized custom selector */
public static final String TYPE_KEY = "type";


/**
* Creates a new <code>TypeSelector</code> instance.
*
*/
public TypeSelector() { public TypeSelector() {
} }


/**
* @return a string describing this object
*/
public String toString() { public String toString() {
StringBuffer buf = new StringBuffer("{typeselector type: "); StringBuffer buf = new StringBuffer("{typeselector type: ");
buf.append(type); buf.append(type);
@@ -83,6 +91,7 @@ public class TypeSelector extends BaseExtendSelector {


/** /**
* Set the type of file to require. * Set the type of file to require.
* @param fileTypes the type of file - file or dir
*/ */
public void setType(FileType fileTypes) { public void setType(FileType fileTypes) {
this.type = fileTypes.getValue(); this.type = fileTypes.getValue();
@@ -146,9 +155,14 @@ public class TypeSelector extends BaseExtendSelector {
* Enumerated attribute with the values for types of file * Enumerated attribute with the values for types of file
*/ */
public static class FileType extends EnumeratedAttribute { public static class FileType extends EnumeratedAttribute {
/** the string value for file */
public static final String FILE = "file"; public static final String FILE = "file";
/** the string value for dir */
public static final String DIR = "dir"; public static final String DIR = "dir";


/**
* @return the values as an array of strings
*/
public String[] getValues() { public String[] getValues() {
return new String[]{FILE, DIR}; return new String[]{FILE, DIR};
} }


Loading…
Cancel
Save