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

# Class ScriptMapper

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

All Implemented Interfaces:
  `Cloneable, FileNameMapper`

public class ScriptMapper extends AbstractScriptComponent implements FileNameMapper
Script support at map time.

Since:
  Ant1.7

- ## 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
  `ScriptMapper()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addMappedName(String mapping)`
  Add a mapped name
  `void`
  `clear()`
  Reset the list of files
  `String[]`
  `mapFileName(String sourceFileName)`
  Returns an array containing the target filename(s) for the given source file.
  `void`
  `setFrom(String from)`
  Sets the from part of the transformation rule.
  `void`
  `setTo(String to)`
  Sets the to part of the transformation rule.

  ### Methods inherited from class AbstractScriptComponent

  `addText, createClasspath, executeScript, getRunner, initScriptRunner, setClasspath, setClasspathRef, setEncoding, setLanguage, setManager, setManager, setProject, setSetBeans, setSrc`
  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

  - ### ScriptMapper

    public ScriptMapper()

- ## Method Details

  - ### setFrom

    public void setFrom(String from)
    Sets the from part of the transformation rule.
    Specified by:
      `setFrom` in interface `FileNameMapper`
    Parameters:
      `from` - a string.

  - ### setTo

    public void setTo(String to)
    Sets the to part of the transformation rule.
    Specified by:
      `setTo` in interface `FileNameMapper`
    Parameters:
      `to` - a string.

  - ### clear

    public void clear()
    Reset the list of files

  - ### addMappedName

    public void addMappedName(String mapping)
    Add a mapped name
    Parameters:
      `mapping` - the value to use.

  - ### mapFileName

    public String[] mapFileName(String sourceFileName)
    Returns an array containing the target filename(s) for the given source file.

    if the given rule doesn't apply to the source file, implementation must return null. SourceFileScanner will then omit the source file in question.

    Specified by:
      `mapFileName` in interface `FileNameMapper`
    Parameters:
      `sourceFileName` - the name of the source file relative to some given basedirectory.
    Returns:
      an array of strings if the rule applies to the source file, or null if it does not.