AbstractScriptComponent (Apache Ant API)
Description: declaration: package: org.apache.tools.ant.types.optional, class: AbstractScriptComponent

# Class AbstractScriptComponent

java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.types.optional.AbstractScriptComponent

All Implemented Interfaces:
  `Cloneable`

Direct Known Subclasses:
  `ScriptCondition, ScriptMapper`

public abstract class AbstractScriptComponent extends ProjectComponent
This is a `ProjectComponent` that has script support built in Use it as a foundation for scriptable things.

- ## Field Summary

  ### Fields inherited from class ProjectComponent

  `description, location, project`
  Modifier and Type
  Field
  Description
  `protected String`
  `description`
  Deprecated.
  since 1.6.x.
  `protected Location`
  `location`
  Deprecated.
  since 1.6.x.
  `protected Project`
  `project`
  Deprecated.
  since 1.6.x.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AbstractScriptComponent()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addText(String text)`
  The script text.
  `Path`
  `createClasspath()`
  Classpath to be used when searching for classes and resources.
  `protected void`
  `executeScript(String execName)`
  Run a script
  `ScriptRunnerBase`
  `getRunner()`
  Get our script runner
  `protected void`
  `initScriptRunner()`
  Initialize the script runner.
  `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`
  `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 script manager.
  `void`
  `setProject(Project project)`
  Set the project.
  `void`
  `setSetBeans(boolean setBeans)`
  Set the setbeans attribute.
  `void`
  `setSrc(File file)`
  Load the script from an external file; optional.

  ### Methods inherited from class ProjectComponent

  `clone, getDescription, getLocation, getProject, log, log, setDescription, setLocation`
  Modifier and Type
  Method
  Description
  `Object`
  `clone()`
  `String`
  `getDescription()`
  Returns the description of the current action.
  `Location`
  `getLocation()`
  Returns the file/location where this task was defined.
  `Project`
  `getProject()`
  Returns the project to which this component belongs.
  `void`
  `log(String msg)`
  Logs a message with the default (INFO) priority.
  `void`
  `log(String msg, int msgLevel)`
  Logs a message with the given priority.
  `void`
  `setDescription(String desc)`
  Sets a description of the current action.
  `void`
  `setLocation(Location location)`
  Sets the file/location where this task was defined.

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### AbstractScriptComponent

    public AbstractScriptComponent()

- ## Method Details

  - ### setProject

    public void setProject(Project project)
    Set the project.
    Overrides:
      `setProject` in class `ProjectComponent`
    Parameters:
      `project` - the owner of this component.

  - ### getRunner

    public ScriptRunnerBase getRunner()
    Get our script runner
    Returns:
      the runner

  - ### setSrc

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

  - ### addText

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

  - ### setManager

    @Deprecated public void setManager(String manager)
    Deprecated.
    Defines the manager.
    Parameters:
      `manager` - the scripting manager.

  - ### setManager

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

  - ### setLanguage

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

  - ### initScriptRunner

    protected void initScriptRunner()
    Initialize the script runner. Calls this before running the system

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

  - ### createClasspath

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

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

  - ### executeScript

    protected void executeScript(String execName)
    Run a script
    Parameters:
      `execName` - name of the script

  - ### 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.
    Since:
      Ant 1.8.0

  - ### 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