diff --git a/docs/manual/develop.html b/docs/manual/develop.html index a19e1c198..b3544f406 100644 --- a/docs/manual/develop.html +++ b/docs/manual/develop.html @@ -188,7 +188,9 @@ three options:
For the options 2 and 3, Ant has to create an instance ofNestedInner
before it can pass it to the task, this
means, NestedInner
must have a public
no-arg
-constructor. This is the only difference between options 1 and 2.
+ constructor or a public
one-arg constructor
+ taking a Project class as a parameter.
+This is the only difference between options 1 and 2.
The difference between 2 and 3 is what Ant has done to the object
before it passes it to the method. addInner
will receive
@@ -201,6 +203,106 @@ handled.
public void add(Type type)
public void addConfigured(Type type)
+ For example suppose one wanted to handle objects object of type + org.apache.tools.ant.taskdefs.condition.Condition, one may + have a class: +
++++public class MyTask extends Task { + private List conditions = new ArrayList(); + public void add(Condition c) { + conditions.add(c); + } + public void execute() { + // iterator over the conditions + } +} ++
+ One may define and use this class like this: +
++++<taskdef name="mytask" classname="MyTask" classpath="classes"/> +<typedef name="condition.equals" + classname="org.apache.tools.ant.taskdefs.conditions.Equals"/> +<mytask> + <condition.equals arg1="${debug}" arg2="true"/> +</mytask> ++
+ A more complicated example follows: +
++++public class Sample { + public static class MyFileSelector implements FileSelector { + public void setAttrA(int a) {} + public void setAttrB(int b) {} + public void add(Path path) {} + public boolean isSelected(File basedir, String filename, File file) { + return true; + } + } + + interface MyInterface { + void setVerbose(boolean val); + } + + public static class BuildPath extends Path { + public BuildPath(Project project) { + super(project); + } + + public void add(MyInterface inter) {} + public void setUrl(String url) {} + } + + public static class XInterface implements MyInterface { + public void setVerbose(boolean x) {} + public void setCount(int c) {} + } +} ++
+ This class defines a number of static classes that implement/extend + Path, MyFileSelector and MyInterface. These may be defined and used + as follows: +
+++<typedef name="myfileselector" classname="Sample$MyFileSelector" + classpath="classes" loaderref="classes"/> +<typedef name="buildpath" classname="Sample$BuildPath" + classpath="classes" loaderref="classes"/> +<typedef name="xinterface" classname="Sample$XInterface" + classpath="classes" loaderref="classes"/> + +<copy todir="copy-classes"> + <fileset dir="classes"> + <myfileselector attra="10" attrB="-10"> + <buildpath path="." url="abc"> + <xinterface count="4"/> + </buildpath> + </myfileselector> + </fileset> +</copy> ++
The TaskContainer
consists of a single method,