FileDocCategorySizeDatePackage
BaseSelectorContainer.javaAPI DocApache Ant 1.709035Wed Dec 13 06:16:22 GMT 2006org.apache.tools.ant.types.selectors

BaseSelectorContainer

public abstract class BaseSelectorContainer extends BaseSelector implements SelectorContainer
This is the base class for selectors that can contain other selectors.
since
1.5

Fields Summary
private Vector
selectorsList
Constructors Summary
public BaseSelectorContainer()
Default constructor.


           
      
    
Methods Summary
public voidadd(FileSelector selector)
add an arbitary selector

param
selector the selector to add
since
Ant 1.6

        appendSelector(selector);
    
public voidaddAnd(AndSelector selector)
add an "And" selector entry on the selector list

param
selector the selector to add

        appendSelector(selector);
    
public voidaddContains(ContainsSelector selector)
add a contains selector entry on the selector list

param
selector the selector to add

        appendSelector(selector);
    
public voidaddContainsRegexp(ContainsRegexpSelector selector)
add a regular expression selector entry on the selector list

param
selector the selector to add

        appendSelector(selector);
    
public voidaddCustom(ExtendSelector selector)
add an extended selector entry on the selector list

param
selector the selector to add

        appendSelector(selector);
    
public voidaddDate(DateSelector selector)
add a selector date entry on the selector list

param
selector the selector to add

        appendSelector(selector);
    
public voidaddDepend(DependSelector selector)
add a depends selector entry on the selector list

param
selector the selector to add

        appendSelector(selector);
    
public voidaddDepth(DepthSelector selector)
add a depth selector entry on the selector list

param
selector the selector to add

        appendSelector(selector);
    
public voidaddDifferent(DifferentSelector selector)
adds a different selector to the selector list

param
selector the selector to add

        appendSelector(selector);
    
public voidaddFilename(FilenameSelector selector)
add a selector filename entry on the selector list

param
selector the selector to add

        appendSelector(selector);
    
public voidaddMajority(MajoritySelector selector)
add a majority selector entry on the selector list

param
selector the selector to add

        appendSelector(selector);
    
public voidaddModified(org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector selector)
add the modified selector

param
selector the selector to add
since
ant 1.6

        appendSelector(selector);
    
public voidaddNone(NoneSelector selector)
add a "None" selector entry on the selector list

param
selector the selector to add

        appendSelector(selector);
    
public voidaddNot(NotSelector selector)
add a "Not" selector entry on the selector list

param
selector the selector to add

        appendSelector(selector);
    
public voidaddOr(OrSelector selector)
add an "Or" selector entry on the selector list

param
selector the selector to add

        appendSelector(selector);
    
public voidaddPresent(PresentSelector selector)
add a present selector entry on the selector list

param
selector the selector to add

        appendSelector(selector);
    
public voidaddSelector(SelectSelector selector)
add a "Select" selector entry on the selector list

param
selector the selector to add

        appendSelector(selector);
    
public voidaddSize(SizeSelector selector)
add a selector size entry on the selector list

param
selector the selector to add

        appendSelector(selector);
    
public voidaddType(TypeSelector selector)
adds a type selector to the selector list

param
selector the selector to add

        appendSelector(selector);
    
public voidappendSelector(FileSelector selector)
Add a new selector into this container.

param
selector the new selector to add

        selectorsList.addElement(selector);
    
public FileSelector[]getSelectors(org.apache.tools.ant.Project p)
Returns the set of selectors as an array.

param
p the current project
return
an array of selectors

        FileSelector[] result = new FileSelector[selectorsList.size()];
        selectorsList.copyInto(result);
        return result;
    
public booleanhasSelectors()
Indicates whether there are any selectors here.

return
true if there are selectors

        return !(selectorsList.isEmpty());
    
public abstract booleanisSelected(java.io.File basedir, java.lang.String filename, java.io.File file)
Method that each selector will implement to create their selection behaviour. This is what makes SelectorContainer abstract.

param
basedir the base directory the scan is being done from
param
filename the name of the file to check
param
file a java.io.File object for the filename that the selector can use
return
whether the file should be selected or not

public intselectorCount()
Gives the count of the number of selectors in this container

return
the number of selectors

        return selectorsList.size();
    
public java.util.EnumerationselectorElements()
Returns an enumerator for accessing the set of selectors.

return
an enumerator for the selectors

        return selectorsList.elements();
    
public java.lang.StringtoString()
Convert the Selectors within this container to a string. This will just be a helper class for the subclasses that put their own name around the contents listed here.

return
comma separated list of Selectors contained in this one

        StringBuffer buf = new StringBuffer();
        Enumeration e = selectorElements();
        if (e.hasMoreElements()) {
            while (e.hasMoreElements()) {
                buf.append(e.nextElement().toString());
                if (e.hasMoreElements()) {
                    buf.append(", ");
                }
            }
        }

        return buf.toString();
    
public voidvalidate()

This implementation validates the container by calling verifySettings() and then validates each contained selector provided that the selector implements the validate interface.

Ordinarily, this will validate all the elements of a selector container even if the isSelected() method of some elements is never called. This has two effects:

  • Validation will often occur twice.
  • Since it is not required that selectors derive from BaseSelector, there could be selectors in the container whose error conditions are not detected if their isSelected() call is never made.

        verifySettings();
        String errmsg = getError();
        if (errmsg != null) {
            throw new BuildException(errmsg);
        }
        Enumeration e = selectorElements();
        while (e.hasMoreElements()) {
            Object o = e.nextElement();
            if (o instanceof BaseSelector) {
                ((BaseSelector) o).validate();
            }
        }