ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marko van Dooren <Marko.vanDoo...@cs.kuleuven.ac.be>
Subject Internal Iterators for FileSet, and AbstractFileSetTask
Date Sat, 16 Feb 2002 13:53:57 GMT
Hi,

I just added an inner class Visitor to org.apache.tools.ant.types.FileSet, to 
act as an internal iterator. An internal iterator makes it very easy to 
perform a certain action on all elements of a certain structure. I've added a 
piece of class documentation that shows how to use it.

I also created AbstractFileSetTask that can be subclassed by tasks that work 
with FileSets. It also provides an internal iterator to perform a certain 
action on all files in all its filesets.

I didn't provide methods to perform actions on directories since I didn't 
need that. You can add it yourself, in which case, the abstract visit(File) 
methods probably needs a default implementation that does NOP (otherwise you 
also have to implement that one if you only do something with directories).

The modified FileSet.java, a patch for that file, and 
AbstractFileSetVisitor.java can be found here :

http://www.cs.kuleuven.ac.be/~marko/ant/FileSet.java
http://www.cs.kuleuven.ac.be/~marko/ant/FileSet.patch
http://www.cs.kuleuven.ac.be/~marko/ant/AbstractFileSetTask.java

I've tested it with a task I'm writing for replacing regular expressions in 
files, and it works fine.

The specifications are partly JML (www.jmlspecs.org). I didn't use the 
Jutil.org Visitor class to avoid a dependency. If you wish to use more 
iterators, you can find them in the org.jutil.java.collections package (link 
below).

Hope you like it, and thanx very much for a great build tool.


Marko No. 5
--
Jutil.org - Programming as you know it is over
http://org-jutil.sourceforge.net

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message