From 27d3bb5e6f9d1fee0a08b7640d39bf8819168f7b Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Wed, 13 Aug 2003 09:05:22 +0000 Subject: [PATCH] fix selector example git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275062 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/CoreTypes/custom-programming.html | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/docs/manual/CoreTypes/custom-programming.html b/docs/manual/CoreTypes/custom-programming.html index f75d4b065..48e63b37b 100644 --- a/docs/manual/CoreTypes/custom-programming.html +++ b/docs/manual/CoreTypes/custom-programming.html @@ -75,7 +75,7 @@ public class AllUpperCaseCondition extends Condition {

- Adding the condition to the system is achieved as follows: + Adding the condition to the system is achieved as follows:

@@ -100,13 +100,14 @@ public class AllUpperCaseCondition extends Condition {
     

Custom selectors are datatypes that implement org.apache.tools.ant.types.selectors.FileSelector. -

There is only one method required. - public boolean isSelected(File basedir, String filename, - File file). - It returns true - or false depending on whether the given file should be - selected or not. -

+

+

There is only one method required. + public boolean isSelected(File basedir, String filename, + File file). + It returns true + or false depending on whether the given file should be + selected or not. +

An example of a custom selection that selects filenames ending in ".java" would be: @@ -114,16 +115,15 @@ public class AllUpperCaseCondition extends Condition {

 package com.mydomain;
+import java.io.File;
 import org.apache.tools.ant.types.selectors.FileSelector;
-public class JavaSelector {
+public class JavaSelector implements FileSelector {
     public boolean isSelected(File b, String filename, File f) {
        return filename.toLowerCase().endsWith(".java");
     }
 }
       
-

-

Adding the selector to the system is achieved as follows:

@@ -135,10 +135,20 @@ public class JavaSelector { classpath="${mydomain.classes"/>
-

+

This selector can now be used wherever a Core Ant selector - is used. + is used, for example:

+
+
+<copy todir="to">
+   <fileset dir="src">
+      <javaselector/>
+   </fileset>
+</copy>
+      
+
+

One may use org.apache.tools.ant.types.selectors.BaseSelector,