ScriptRunnerHelper (Apache Ant API)
Description: declaration: package: org.apache.tools.ant.util, class: ScriptRunnerHelper

Package org.apache.tools.ant.util

# Class ScriptRunnerHelper

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

    public class ScriptRunnerHelper
    extends java.lang.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​(java.lang.String text)` | Add script text.
  `Path` | `createClasspath()` | Classpath to be used when searching for classes and resources.
  `boolean` | `getCompiled()` | Get the compilation feature.
  `java.lang.String` | `getEncoding()` | Get the external file encoding.
  `java.lang.String` | `getLanguage()` | Get the language.
  `ScriptRunnerBase` | `getScriptRunner()` | Create and set text on a script.
  `java.io.File` | `getSrc()` | Get the external script file; optional.
  `void` | `setClassLoader​(java.lang.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​(java.lang.String encoding)` | Set the encoding of the script from an external file; optional.
  `void` | `setLanguage​(java.lang.String language)` | Defines the language (required).
  `void` | `setManager​(java.lang.String manager)` | Defines the script manager - defaults to "auto".
  `void` | `setProjectComponent​(ProjectComponent component)` | Set the project component associated with this helper.
  `void` | `setSetBeans​(boolean setBeans)` | Set the setbeans attribute.
  `void` | `setSrc​(java.io.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​(java.io.File file)
    Load the script from an external file; optional.
    Parameters:
      `file` - the file containing the script source.

  - ### getSrc

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

  - ### setEncoding

    public void setEncoding​(java.lang.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 java.lang.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​(java.lang.String text)
    Add script text.
    Parameters:
      `text` - a component of the script text to be added.

  - ### setManager

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

  - ### setLanguage

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

  - ### getLanguage

    public java.lang.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​(java.lang.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