Package org.apache.tools.ant.taskdefs

# Class MacroInstance

java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.tools.ant.taskdefs.MacroInstance

All Implemented Interfaces:
  `Cloneable`, `DynamicAttribute`, `TaskContainer`

public class MacroInstance extends Task implements DynamicAttribute, TaskContainer
The class to be placed in the ant type definition. It is given a pointer to the template definition, and makes a copy of the unknown element, substituting the parameter values in attributes and text.

Since:
  Ant 1.6

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `MacroInstance.Element`
  Embedded element in macro instance

- ## Field Summary

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

  `target, taskName, taskType, wrapper`

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

  `description, location, project`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MacroInstance()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addTask(Task nestedTask)`
  Add a unknownElement for the macro instances nested elements.
  `void`
  `addText(String text)`
  Set the text contents for the macro.
  `Object`
  `createDynamicElement(String name)`
  Deprecated.
  since 1.6.x.
  `void`
  `execute()`
  Execute the templates instance.
  `MacroDef`
  `getMacroDef()`
  `void`
  `setDynamicAttribute(String name, String value)`
  A parameter name value pair as a xml attribute.
  `void`
  `setMacroDef(MacroDef macroDef)`
  Called from MacroDef.MyAntTypeDefinition#create()

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

  `bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType`

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

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

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

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

- ## Constructor Details

  - ### MacroInstance

    public MacroInstance()

- ## Method Details

  - ### setMacroDef

    public void setMacroDef(MacroDef macroDef)
    Called from MacroDef.MyAntTypeDefinition#create()
    Parameters:
      `macroDef` - a `MacroDef` value

  - ### getMacroDef

    public MacroDef getMacroDef()
    Returns:
      the macro definition object for this macro instance.

  - ### setDynamicAttribute

    public void setDynamicAttribute(String name, String value)
    A parameter name value pair as a xml attribute.
    Specified by:
      `setDynamicAttribute` in interface `DynamicAttribute`
    Parameters:
      `name` - the name of the attribute
      `value` - the value of the attribute

  - ### createDynamicElement

    @Deprecated public Object createDynamicElement(String name) throws BuildException
    Deprecated.
    since 1.6.x.
    Method present for BC purposes.
    Parameters:
      `name` - not used
    Returns:
      nothing
    Throws:
      `BuildException` - always

  - ### addTask

    public void addTask(Task nestedTask)
    Add a unknownElement for the macro instances nested elements.
    Specified by:
      `addTask` in interface `TaskContainer`
    Parameters:
      `nestedTask` - a nested element.

  - ### addText

    public void addText(String text)
    Set the text contents for the macro.
    Parameters:
      `text` - the text to be added to the macro.

  - ### execute

    public void execute()
    Execute the templates instance. Copies the unknown element, substitutes the attributes, and calls perform on the unknown element.
    Overrides:
      `execute` in class `Task`