ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Tchepannou <melli...@gmail.com>
Subject What is the difference between a nested element and a nested type?
Date Thu, 09 Jun 2005 08:51:11 GMT
Hi all,

I was wondering if someone could enlighten me on this?
I tried to implement a custom type and use it in my build file but
everytime I get the error message that the nested "Element" is not
supported by the task.
Basically, I have something like this:

public class MyTask extends Task {
    private List myTypes = new ArrayList();

    public void add(MyTypeBase c) {
        myTypes.add(c);
    }

    public void execute() {
     ...
    }
}

I use it as follow in the buildfile:

<target ...>
    <taskdef name="mytask".../>
    <typedef name="mytype" class="MyConcreteType" />
    <mytask>
        <mytype .../>
    </mytask>
</target>

where MyConcreteType is a subclass of MyBaseType. This donot work. I
can only make it work if I write it as

public class MyTask extends Task {
    private List myTypes = new ArrayList();

    public MyConcreteType createConcreteType() {
        MyConcreteType c = new ...
        myTypes.add(c);
        return c;
    }

    public void execute() {
     ...
    }
}

As far as I understand the short tutorial in the manual, the second
implementation is the implementation of nested elements and the first
is the one of the nested types. I am a little bit confused about what
is an element, a type in the ant context.
The deal is that I would rather have a type and not an element,
because with an element, I would have to write for each concrete type
the corresponding createXXX() method.

-- 
Best Regards,
Eric Tchepannou

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message