FileDocCategorySizeDatePackage
PreSetDef.javaAPI DocApache Ant 1.709104Wed Dec 13 06:16:18 GMT 2006org.apache.tools.ant.taskdefs

PreSetDef

public class PreSetDef extends AntlibDefinition implements org.apache.tools.ant.TaskContainer
The preset definition task generates a new definition based on a current definition with some attributes or elements preset.
<presetdef name="my.javac">
<javac deprecation="${deprecation}" debug="${debug}"/>
</presetdef>
<my.javac srcdir="src" destdir="classes"/>
since
Ant 1.6

Fields Summary
private org.apache.tools.ant.UnknownElement
nestedTask
private String
name
Constructors Summary
Methods Summary
public voidaddTask(org.apache.tools.ant.Task nestedTask)
Add a nested task to predefine attributes and elements on.

param
nestedTask Nested task/type to extend.

        if (this.nestedTask != null) {
            throw new BuildException("Only one nested element allowed");
        }
        if (!(nestedTask instanceof UnknownElement)) {
            throw new BuildException(
                "addTask called with a task that is not an unknown element");
        }
        this.nestedTask = (UnknownElement) nestedTask;
    
public voidexecute()
Make a new definition.

        if (nestedTask == null) {
            throw new BuildException("Missing nested element");
        }
        if (name == null) {
            throw new BuildException("Name not specified");
        }
        name = ProjectHelper.genComponentName(getURI(), name);

        ComponentHelper helper = ComponentHelper.getComponentHelper(
            getProject());

        String componentName = ProjectHelper.genComponentName(
            nestedTask.getNamespace(), nestedTask.getTag());

        AntTypeDefinition def = helper.getDefinition(componentName);
        if (def == null) {
            throw new BuildException(
                "Unable to find typedef " + componentName);
        }
        PreSetDefinition newDef = new PreSetDefinition(def, nestedTask);

        newDef.setName(name);

        helper.addDataTypeDefinition(newDef);
        log("defining preset " + name, Project.MSG_VERBOSE);
    
public voidsetName(java.lang.String name)
Set the name of this definition.

param
name the name of the definition.

        this.name = name;