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

BaseSelector

public abstract class BaseSelector extends org.apache.tools.ant.types.DataType implements FileSelector
A convenience base class that you can subclass Selectors from. It provides some helpful common behaviour. Note that there is no need for Selectors to inherit from this class, it is only necessary that they implement FileSelector.
since
1.5

Fields Summary
private String
errmsg
Constructors Summary
public BaseSelector()
Do nothing constructor.



            
      
    
Methods Summary
public java.lang.StringgetError()
Returns any error messages that have been set.

return
the error condition

        return errmsg;
    
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. If there is a problem with the setup of a selector, it can throw a BuildException to indicate the problem.

param
basedir A java.io.File object for the base directory
param
filename The name of the file to check
param
file A File object for this filename
return
whether the file should be selected or not

public voidsetError(java.lang.String msg)
Allows all selectors to indicate a setup error. Note that only the first error message is recorded.

param
msg The error message any BuildException should throw.

        if (errmsg == null) {
            errmsg = msg;
        }
    
public voidvalidate()
Subclasses can use this to throw the requisite exception in isSelected() in the case of an error condition.

        if (getError() == null) {
            verifySettings();
        }
        if (getError() != null) {
            throw new BuildException(errmsg);
        }
    
public voidverifySettings()

Subclasses can override this method to provide checking of their state. So long as they call validate() from isSelected(), this will be called automatically (unless they override validate()).

Implementations should check for incorrect settings and call setError() as necessary.

        if (isReference()) {
            ((BaseSelector) getCheckedRef()).verifySettings();
        }