FileDocCategorySizeDatePackage
ScriptDefBase.javaAPI DocApache Ant 1.704114Wed Dec 13 06:16:24 GMT 2006org.apache.tools.ant.taskdefs.optional.script

ScriptDefBase

public class ScriptDefBase extends org.apache.tools.ant.Task implements org.apache.tools.ant.DynamicConfigurator
The script execution class. This class finds the defining script task and passes control to that task's executeScript method.
since
Ant 1.6

Fields Summary
private Map
nestedElementMap
Nested elements
private Map
attributes
Attributes
private String
text
Constructors Summary
Methods Summary
public voidaddText(java.lang.String text)
Set the script text.

param
text a component of the script text to be added.
since
ant1.7

        this.text = getProject().replaceProperties(text);
    
public java.lang.ObjectcreateDynamicElement(java.lang.String name)
Create a nested element

param
name the nested element name
return
the element to be configured

        List nestedElementList = (List) nestedElementMap.get(name);
        if (nestedElementList == null) {
            nestedElementList = new ArrayList();
            nestedElementMap.put(name, nestedElementList);
        }
        Object element = getScript().createNestedElement(name);
        nestedElementList.add(element);
        return element;
    
public voidexecute()
Locate the script defining task and execute the script by passing control to it


                       
       
        getScript().executeScript(attributes, nestedElementMap, this);
    
public voidfail(java.lang.String message)
Utility method for nested scripts; throws a BuildException with the given message.

param
message text to pass to the BuildException
throws
BuildException always.
since
ant1.7

        throw new BuildException(message);
    
private ScriptDefgetScript()

        String name = getTaskType();
        Map scriptRepository
            = (Map) getProject().getReference(MagicNames.SCRIPT_REPOSITORY);
        if (scriptRepository == null) {
            throw new BuildException("Script repository not found for " + name);
        }

        ScriptDef definition = (ScriptDef) scriptRepository.get(getTaskType());
        if (definition == null) {
            throw new BuildException("Script definition not found for " + name);
        }
        return definition;
    
public java.lang.StringgetText()
get the text of this element; may be null

return
text or null for no nested text
since
ant1.7

        return text;
    
public voidsetDynamicAttribute(java.lang.String name, java.lang.String value)
Set a task attribute

param
name the attribute name.
param
value the attribute's string value

        ScriptDef definition = getScript();
        if (!definition.isAttributeSupported(name)) {
                throw new BuildException("<" + getTaskType()
                    + "> does not support the \"" + name + "\" attribute");
        }

        attributes.put(name, value);