Package org.apache.tools.ant.util

# Class ScriptRunnerHelper

java.lang.Object
org.apache.tools.ant.util.ScriptRunnerHelper

public class ScriptRunnerHelper extends Object
A class to help in creating, setting and getting script runners.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ScriptRunnerHelper()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `add(ResourceCollection resource)`
  Add any source resource.
  `void`
  `addText(String text)`
  Add script text.
  `Path`
  `createClasspath()`
  Classpath to be used when searching for classes and resources.
  `boolean`
  `getCompiled()`
  Get the compilation feature.
  `String`
  `getEncoding()`
  Get the external file encoding.
  `String`
  `getLanguage()`
  Get the language.
  `ScriptRunnerBase`
  `getScriptRunner()`
  Create and set text on a script.
  `File`
  `getSrc()`
  Get the external script file; optional.
  `void`
  `setClassLoader(ClassLoader loader)`
  Used when called by scriptdef.
  `void`
  `setClasspath(Path classpath)`
  Set the classpath to be used when searching for classes and resources.
  `void`
  `setClasspathRef(Reference r)`
  Set the classpath by reference.
  `void`
  `setCompiled(boolean compiled)`
  Enable the compilation of the script if possible.
  `void`
  `setEncoding(String encoding)`
  Set the encoding of the script from an external file; optional.
  `void`
  `setLanguage(String language)`
  Defines the language (required).
  `void`
  `setManager(String manager)`
  Deprecated.
  `void`
  `setManager(ScriptManager manager)`
  Set the manager.
  `void`
  `setProjectComponent(ProjectComponent component)`
  Set the project component associated with this helper.
  `void`
  `setSetBeans(boolean setBeans)`
  Set the setbeans attribute.
  `void`
  `setSrc(File file)`
  Load the script from an external file; optional.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ScriptRunnerHelper

    public ScriptRunnerHelper()

- ## Method Details

  - ### setProjectComponent

    public void setProjectComponent(ProjectComponent component)
    Set the project component associated with this helper.
    Parameters:
      `component` - the project component that owns this helper.

  - ### getScriptRunner

    public ScriptRunnerBase getScriptRunner()
    Create and set text on a script.
    Returns:
      the created or reused script runner.

  - ### createClasspath

    public Path createClasspath()
    Classpath to be used when searching for classes and resources.
    Returns:
      an empty Path instance to be configured by Ant.

  - ### setClasspath

    public void setClasspath(Path classpath)
    Set the classpath to be used when searching for classes and resources.
    Parameters:
      `classpath` - an Ant Path object containing the search path.

  - ### setClasspathRef

    public void setClasspathRef(Reference r)
    Set the classpath by reference.
    Parameters:
      `r` - a Reference to a Path instance to be used as the classpath value.

  - ### setSrc

    public void setSrc(File file)
    Load the script from an external file; optional.
    Parameters:
      `file` - the file containing the script source.

  - ### getSrc

    public File getSrc()
    Get the external script file; optional.
    Returns:
      the file containing the script source.
    Since:
      Ant 1.10.2

  - ### setEncoding

    public void setEncoding(String encoding)
    Set the encoding of the script from an external file; optional.
    Parameters:
      `encoding` - the encoding of the file containing the script source.
    Since:
      Ant 1.10.2

  - ### getEncoding

    public String getEncoding()
    Get the external file encoding.
    Returns:
      the encoding of the file containing the script source.
    Since:
      Ant 1.10.2

  - ### addText

    public void addText(String text)
    Add script text.
    Parameters:
      `text` - a component of the script text to be added.

  - ### setManager

    @Deprecated public void setManager(String manager)
    Deprecated.
    Defines the script manager - defaults to "auto".
    Parameters:
      `manager` - the scripting manager - "bsf" or "javax" or "auto"

  - ### setManager

    public void setManager(ScriptManager manager)
    Set the manager.
    Parameters:
      `manager` -

  - ### setLanguage

    public void setLanguage(String language)
    Defines the language (required).
    Parameters:
      `language` - the scripting language name for the script.

  - ### getLanguage

    public String getLanguage()
    Get the language.
    Returns:
      the scripting language.

  - ### setCompiled

    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` - the value to set.

  - ### getCompiled

    public boolean getCompiled()
    Get the compilation feature.
    Returns:
      the compilation feature.

  - ### setSetBeans

    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` - the value to set.

  - ### setClassLoader

    public void setClassLoader(ClassLoader loader)
    Used when called by scriptdef.
    Parameters:
      `loader` - the loader used by scriptdef.

  - ### add

    public void add(ResourceCollection resource)
    Add any source resource.
    Parameters:
      `resource` - source of script
    Since:
      Ant 1.7.1