FileDocCategorySizeDatePackage
IsFileSelected.javaAPI DocApache Ant 1.702630Wed Dec 13 06:16:18 GMT 2006org.apache.tools.ant.taskdefs.condition

IsFileSelected

public class IsFileSelected extends org.apache.tools.ant.types.selectors.AbstractSelectorContainer implements Condition
This is a condition that checks to see if a file passes an embedded selector.

Fields Summary
private static final org.apache.tools.ant.util.FileUtils
FILE_UTILS
private File
file
private File
baseDir
Constructors Summary
Methods Summary
public booleaneval()
Evaluate the selector with the file.

return
true if the file is selected by the embedded selector.

        if (file == null) {
            throw new BuildException("file attribute not set");
        }
        validate();
        File myBaseDir = baseDir;
        if (myBaseDir == null) {
            myBaseDir = getProject().getBaseDir();
        }

        FileSelector f = getSelectors(getProject())[0];
        return f.isSelected(
            myBaseDir, FILE_UTILS.removeLeadingPath(myBaseDir, file), file);
    
public voidsetBaseDir(java.io.File baseDir)
The base directory to use.

param
baseDir the base directory to use, if null use the project's basedir.

        this.baseDir = baseDir;
    
public voidsetFile(java.io.File file)
The file to check.

param
file the file to check if if passes the embedded selector.


                         
        
        this.file = file;
    
public voidvalidate()
validate the parameters.

        if (selectorCount() != 1) {
            throw new BuildException("Only one selector allowed");
        }
        super.validate();