FileDocCategorySizeDatePackage
ScriptSelector.javaAPI DocApache Ant 1.706066Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.types.optional

ScriptSelector

public class ScriptSelector extends org.apache.tools.ant.types.selectors.BaseSelector
Selector that lets you run a script with selection logic inline
since
Ant1.7

Fields Summary
private org.apache.tools.ant.util.ScriptRunnerHelper
helper
script runner helper
private org.apache.tools.ant.util.ScriptRunnerBase
runner
script runner
private File
basedir
fields updated for every selection
private String
filename
private File
file
private boolean
selected
selected flag
Constructors Summary
Methods Summary
public voidaddText(java.lang.String text)
The script text.

param
text a component of the script text to be added.

        helper.addText(text);
    
public org.apache.tools.ant.types.PathcreateClasspath()
Classpath to be used when searching for classes and resources.

return
an empty Path instance to be configured by Ant.

        return helper.createClasspath();
    
public java.io.FilegetBasedir()
get the base directory

return
the base directory

        return basedir;
    
public java.io.FilegetFile()
get the file that is currently to be tested

return
the file that is currently been tested

        return file;
    
public java.lang.StringgetFilename()
get the filename of the file

return
the filename of the file that is currently been tested

        return filename;
    
private voidinit()
Initialize on demand.

throws
org.apache.tools.ant.BuildException if someting goes wrong

        if (runner != null) {
            return;
        }
        runner = helper.getScriptRunner();
    
public 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

        init();
        setSelected(true);
        this.file = file;
        this.basedir = basedir;
        this.filename = filename;
        runner.addBean("basedir", basedir);
        runner.addBean("filename", filename);
        runner.addBean("file", file);
        runner.executeScript("ant_selector");
        return isSelected();
    
public booleanisSelected()
get state of selected flag

return
the selected flag

        return selected;
    
public voidsetClasspath(org.apache.tools.ant.types.Path classpath)
Set the classpath to be used when searching for classes and resources.

param
classpath an Ant Path object containing the search path.

        helper.setClasspath(classpath);
    
public voidsetClasspathRef(org.apache.tools.ant.types.Reference r)
Set the classpath by reference.

param
r a Reference to a Path instance to be used as the classpath value.

        helper.setClasspathRef(r);
    
public voidsetLanguage(java.lang.String language)
Defines the language (required).

param
language the scripting language name for the script.

        helper.setLanguage(language);
    
public voidsetManager(java.lang.String manager)
Defines the manager.

param
manager the scripting manager.

        helper.setManager(manager);
    
public voidsetProject(org.apache.tools.ant.Project project)
Set the project.

param
project the owner of this component.


                   
        
        super.setProject(project);
        helper.setProjectComponent(this);
    
public voidsetSelected(boolean selected)
set the selected state Intended for script use, not as an Ant attribute

param
selected the selected state

        this.selected = selected;
    
public voidsetSetBeans(boolean setBeans)
Set the setbeans attribute. If this is true, <script> will create variables in the script instance for all properties, targets and references of the current project. It this is false, only the project and self variables will be set. The default is true.

param
setBeans the value to set.

        helper.setSetBeans(setBeans);
    
public voidsetSrc(java.io.File file)
Load the script from an external file ; optional.

param
file the file containing the script source.

        helper.setSrc(file);