Date: 2004-02-28T21:52:09 Editor: 218.214.49.176 <> Wiki: Ant Wiki Page: NewAntFeaturesInDetail/NewIntrospectionRules URL: http://wiki.apache.org/ant/NewAntFeaturesInDetail/NewIntrospectionRules
no comment Change Log: ------------------------------------------------------------------------------ @@ -1,32 +1,38 @@ -Tasks and data-types can now accept arbitrary classes that implement a certain interface or extend a certain class as nested elements by using <code>add(Type)</code> as the adder method. Details can be found [http://ant.apache.org/manual-1.6beta/develop.html#nestedtype here]. +Tasks and data-types can now accept arbitrary classes that implement a certain interface or extend a certain class as nested elements by using `add(Type)` as the adder method. Details can be found [http://ant.apache.org/manual/develop.html#nestedtype here]. -Some of the built-in tasks/types have been enhanced with interface adders of that kind, you can now add a new condtion by <typedef>ing the class (to give it a name) and nesting it into the <condition> task. The same is possible for selectors and filterreaders, it is described in more detail [http://ant.apache.org/manual-1.6beta/CoreTypes/custom-programming.html here]. +Some of the built-in tasks/types have been enhanced with interface adders of that kind, you can now add a new condtion by <typedef>ing the class (to give it a name) and nesting it into the <condition> task. The same is possible for selectors and filterreaders, it is described in more detail [http://ant.apache.org/manual/CoreTypes/custom-programming.html here]. The short version looks like this Define a condition that checks whether a given value ends with FOO. -{{{ package org.example; }}} -{{{ import org.apache.tools.ant.taskdefs.condition.Condition; }}} - -{{{ public class EndsWithFoo implements Condition { }}} -{{{ private String value; }}} - -{{{ public void setValue(String value) { }}} -{{{ this.value = value; }}} -{{{ } }}} - -{{{ public boolean eval() { }}} -{{{ return value.endsWith("FOO"); }}} -{{{ } }}} -{{{ } }}} +{{{ + package org.example; + import org.apache.tools.ant.taskdefs.condition.Condition; + + public class EndsWithFoo implements Condition { + private String value; + + public void setValue(String value) { + this.value = value; + } + + public boolean eval() { + return value.endsWith("FOO"); + } + } +}}} name it -{{{ <typedef name="endswithfoo" classname="org.example.EndsWithFoo"/> }}} +{{{ + <typedef name="endswithfoo" classname="org.example.EndsWithFoo"/> +}}} and simply use it -{{{ <condition property="fooEndsWithFoo"> }}} -{{{ <endswithfoo value="foo"/> }}} -{{{ </condition> }}} +{{{ + <condition property="fooEndsWithFoo"> + <endswithfoo value="foo"/> + </condition> +}}} --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]