Package org.apache.tools.ant.types.optional

# Class ScriptFilter

java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.filters.TokenFilter.ChainableReaderFilter
org.apache.tools.ant.types.optional.ScriptFilter

All Implemented Interfaces:
  `Cloneable`, `ChainableReader`, `TokenFilter.Filter`

public class ScriptFilter extends TokenFilter.ChainableReaderFilter
Most of this is CAP (Cut And Paste) from the Script task ScriptFilter class, implements TokenFilter.Filter for scripts to use. This provides the same beans as the Script Task to a script. The script is meant to use get self.token and set self.token in the reply.

Since:
  Ant 1.6

- ## Field Summary

  ### Fields inherited from class org.apache.tools.ant.ProjectComponent

  `description, location, project`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ScriptFilter()`

- ## 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.
  `String`
  `filter(String token)`
  Called filter the token.
  `String`
  `getToken()`
  The current token
  `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.
  `void`
  `setToken(String token)`
  The current token

  ### Methods inherited from class org.apache.tools.ant.filters.TokenFilter.ChainableReaderFilter

  `chain, setByLine`

  ### Methods inherited from class org.apache.tools.ant.ProjectComponent

  `clone, getDescription, getLocation, getProject, log, log, setDescription, setLocation`

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

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

- ## Constructor Details

  - ### ScriptFilter

    public ScriptFilter()

- ## Method Details

  - ### setProject

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

  - ### setLanguage

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

  - ### setToken

    public void setToken(String token)
    The current token
    Parameters:
      `token` - the string filtered by the script

  - ### getToken

    public String getToken()
    The current token
    Returns:
      the string filtered by the script

  - ### filter

    public String filter(String token)
    Called filter the token. This sets the token in this object, calls the script and returns the token.
    Parameters:
      `token` - the token to be filtered
    Returns:
      the filtered token

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

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

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