Top Description Fields Constructors Methods
org.apache.tools.ant.types.optional

public Class ScriptSelector

extends BaseSelector
Class Inheritance
Imports
java.io.File, org.apache.tools.ant.BuildException, .Project, org.apache.tools.ant.types.Path, .Reference, org.apache.tools.ant.types.selectors.BaseSelector, org.apache.tools.ant.util.ScriptManager, .ScriptRunnerBase, .ScriptRunnerHelper

Selector that lets you run a script with selection logic inline
Since
Ant1.7

Field Summary

Modifier and TypeField and Description
private File
basedir

fields updated for every selection

private File
private String
private ScriptRunnerHelper
helper

script runner helper

private ScriptRunnerBase
runner

script runner

private boolean
selected

selected flag

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addText(String
a component of the script text to be added.
text
)

The script text.

public Path

Returns:

an empty Path instance to be configured by Ant.
createClasspath
()

Classpath to be used when searching for classes and resources.

public File

Returns:

the base directory
getBasedir
()

get the base directory

public File

Returns:

the file that is currently been tested
getFile
()

get the file that is currently to be tested

public String

Returns:

the filename of the file that is currently been tested
getFilename
()

get the filename of the file

private void
init()

Initialize on demand.

public boolean

Returns:

whether the file should be selected or not
isSelected
(File
A java.io.File object for the base directory
basedir
,
String
The name of the file to check
filename
,
File
A File object for this filename
file
)

Implements abstract org.apache.tools.ant.types.selectors.BaseSelector.isSelected.

Implements org.apache.tools.ant.types.selectors.FileSelector.isSelected.

Method that each selector will implement to create their selection behaviour.
public boolean

Returns:

the selected flag
isSelected
()

get state of selected flag

public void
setClasspath(Path
an Ant Path object containing the search path.
classpath
)

Set the classpath to be used when searching for classes and resources.

public void
setClasspathRef(Reference
a Reference to a Path instance to be used as the classpath value.
r
)

Set the classpath by reference.

public void
setEncoding(String
the encoding of the file containing the script source.
encoding
)

Set the encoding of the script from an external file; optional.

public void
setLanguage(String
the scripting language name for the script.
language
)

Defines the language (required).

public void
setManager(String
the scripting manager.
manager
)

Deprecated
Defines the manager.
public void
setManager(ScriptManager manager)

Set the script manager.

public void
setProject(Project
the owner of this component.
project
)

Overrides org.apache.tools.ant.ProjectComponent.setProject.

Set the project.
public void
setSelected(boolean
the selected state
selected
)

set the selected state Intended for script use, not as an Ant attribute

public void
setSetBeans(boolean
the value to set.
setBeans
)

Set the setbeans attribute.

public void
setSrc(File
the file containing the script source.
file
)

Load the script from an external file; optional.

Inherited from org.apache.tools.ant.types.selectors.BaseSelector:
getErrorsetErrorsetErrorvalidateverifySettings

Field Detail

basedirback to summary
private File basedir

fields updated for every selection

fileback to summary
private File file
filenameback to summary
private String filename
helperback to summary
private ScriptRunnerHelper helper

script runner helper

runnerback to summary
private ScriptRunnerBase runner

script runner

selectedback to summary
private boolean selected

selected flag

Constructor Detail

ScriptSelectorback to summary
public ScriptSelector()

Method Detail

addTextback to summary
public void addText(String text)

The script text.

Parameters
text:String

a component of the script text to be added.

createClasspathback to summary
public Path createClasspath()

Classpath to be used when searching for classes and resources.

Returns:Path

an empty Path instance to be configured by Ant.

getBasedirback to summary
public File getBasedir()

get the base directory

Returns:File

the base directory

getFileback to summary
public File getFile()

get the file that is currently to be tested

Returns:File

the file that is currently been tested

getFilenameback to summary
public String getFilename()

get the filename of the file

Returns:String

the filename of the file that is currently been tested

initback to summary
private void init() throws BuildException

Initialize on demand.

Exceptions
BuildException:
if something goes wrong
isSelectedback to summary
public boolean isSelected(File basedir, String filename, File file)

Implements abstract org.apache.tools.ant.types.selectors.BaseSelector.isSelected.

Implements org.apache.tools.ant.types.selectors.FileSelector.isSelected.

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.

Parameters
basedir:File

A java.io.File object for the base directory

filename:String

The name of the file to check

file:File

A File object for this filename

Returns:boolean

whether the file should be selected or not

Annotations
@Override
isSelectedback to summary
public boolean isSelected()

get state of selected flag

Returns:boolean

the selected flag

setClasspathback to summary
public void setClasspath(Path classpath)

Set the classpath to be used when searching for classes and resources.

Parameters
classpath:Path

an Ant Path object containing the search path.

setClasspathRefback to summary
public void setClasspathRef(Reference r)

Set the classpath by reference.

Parameters
r:Reference

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

setEncodingback to summary
public void setEncoding(String encoding)

Set the encoding of the script from an external file; optional.

Parameters
encoding:String

the encoding of the file containing the script source.

Since
Ant 1.10.2
setLanguageback to summary
public void setLanguage(String language)

Defines the language (required).

Parameters
language:String

the scripting language name for the script.

setManagerback to summary
public void setManager(String manager)

Deprecated

Defines the manager.

Parameters
manager:String

the scripting manager.

Annotations
@Deprecated
setManagerback to summary
public void setManager(ScriptManager manager)

Set the script manager.

setProjectback to summary
public void setProject(Project project)

Overrides org.apache.tools.ant.ProjectComponent.setProject.

Set the project.

Parameters
project:Project

the owner of this component.

Annotations
@Override
setSelectedback to summary
public void setSelected(boolean selected)

set the selected state Intended for script use, not as an Ant attribute

Parameters
selected:boolean

the selected state

setSetBeansback to summary
public void setSetBeans(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.

Parameters
setBeans:boolean

the value to set.

setSrcback to summary
public void setSrc(File file)

Load the script from an external file; optional.

Parameters
file:File

the file containing the script source.