Top Description Fields Constructors Methods
org.apache.tools.ant.util

public Class ScriptRunnerHelper

extends Object
Class Inheritance
Imports
java.io.File, org.apache.tools.ant.ProjectComponent, org.apache.tools.ant.types.Path, .Reference, .ResourceCollection, org.apache.tools.ant.types.resources.Union

A class to help in creating, setting and getting script runners.

Field Summary

Modifier and TypeField and Description
private boolean
private ClasspathUtils.Delegate
private String
private String
private ScriptManager
private ProjectComponent
private Union
private ClassLoader
private boolean
private File
private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
add(ResourceCollection
source of script
resource
)

Add any source resource.

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

Add 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.

private synchronized ClassLoader
private ClasspathUtils.Delegate
public boolean

Returns:

the compilation feature.
getCompiled
()

Get the compilation feature.

public String

Returns:

the encoding of the file containing the script source.
getEncoding
()

Get the external file encoding.

public String

Returns:

the scripting language.
getLanguage
()

Get the language.

private ScriptRunnerBase
getRunner()

Get a script runner.

public ScriptRunnerBase

Returns:

the created or reused script runner.
getScriptRunner
()

Create and set text on a script.

public File

Returns:

the file containing the script source.
getSrc
()

Get the external script file; optional.

public void
setClassLoader(ClassLoader
the loader used by scriptdef.
loader
)

Used when called by scriptdef.

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
setCompiled(boolean
the value to set.
compiled
)

Enable the compilation of the script if possible.

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 - "bsf" or "javax" or "auto"
manager
)

Deprecated
Defines the script manager - defaults to "auto".
public void
setManager(ScriptManager manager)

Set the manager.

public void
setProjectComponent(ProjectComponent
the project component that owns this helper.
component
)

Set the project component associated with this helper.

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 java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

compiledback to summary
private boolean compiled
cpDelegateback to summary
private ClasspathUtils.Delegate cpDelegate
encodingback to summary
private String encoding
languageback to summary
private String language
managerback to summary
private ScriptManager manager
projectComponentback to summary
private ProjectComponent projectComponent
resourcesback to summary
private Union resources
scriptLoaderback to summary
private ClassLoader scriptLoader
setBeansback to summary
private boolean setBeans
srcFileback to summary
private File srcFile
textback to summary
private String text

Constructor Detail

ScriptRunnerHelperback to summary
public ScriptRunnerHelper()

Method Detail

addback to summary
public void add(ResourceCollection resource)

Add any source resource.

Parameters
resource:ResourceCollection

source of script

Since
Ant 1.7.1
addTextback to summary
public void addText(String text)

Add 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.

generateClassLoaderback to summary
private synchronized ClassLoader generateClassLoader()
getClassPathDelegateback to summary
private ClasspathUtils.Delegate getClassPathDelegate()
getCompiledback to summary
public boolean getCompiled()

Get the compilation feature.

Returns:boolean

the compilation feature.

getEncodingback to summary
public String getEncoding()

Get the external file encoding.

Returns:String

the encoding of the file containing the script source.

Since
Ant 1.10.2
getLanguageback to summary
public String getLanguage()

Get the language.

Returns:String

the scripting language.

getRunnerback to summary
private ScriptRunnerBase getRunner()

Get a script runner.

getScriptRunnerback to summary
public ScriptRunnerBase getScriptRunner()

Create and set text on a script.

Returns:ScriptRunnerBase

the created or reused script runner.

getSrcback to summary
public File getSrc()

Get the external script file; optional.

Returns:File

the file containing the script source.

Since
Ant 1.10.2
setClassLoaderback to summary
public void setClassLoader(ClassLoader loader)

Used when called by scriptdef.

Parameters
loader:ClassLoader

the loader used by scriptdef.

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.

setCompiledback to summary
public void setCompiled(boolean compiled)

Enable the compilation of the script if possible. If this is true and the compilation feature is available in the script engine, the script is compiled before the first evaluation, and should be cached for future evaluations. Otherwise, the script is evaluated each time. The default is false.

Parameters
compiled:boolean

the value to set.

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 script manager - defaults to "auto".

Parameters
manager:String

the scripting manager - "bsf" or "javax" or "auto"

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

Set the manager.

setProjectComponentback to summary
public void setProjectComponent(ProjectComponent component)

Set the project component associated with this helper.

Parameters
component:ProjectComponent

the project component that owns this helper.

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.