You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Calvin Yu <cy...@yahoo.com> on 2002/08/18 20:55:17 UTC
[PATCH][JELLY] directory support for fileScanner
Patch to fileScanner for iterating through included directories.
Calvin
Re: [PATCH][JELLY] directory support for fileScanner
Posted by James Strachan <ja...@yahoo.co.uk>.
Thanks Calvin. Patches applied.
James
-------
http://james.weblogger.com/
----- Original Message -----
From: "Calvin Yu" <cy...@yahoo.com>
To: "Jakarta Commons Developers List" <co...@jakarta.apache.org>
Sent: Sunday, August 18, 2002 7:55 PM
Subject: [PATCH][JELLY] directory support for fileScanner
>
> Patch to fileScanner for iterating through included directories.
>
> Calvin
>
----------------------------------------------------------------------------
----
> Index: src/java/org/apache/commons/jelly/tags/ant/FileIterator.java
> ===================================================================
> RCS file:
/home/cvspublic/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/je
lly/tags/ant/FileIterator.java,v
> retrieving revision 1.1
> diff -u -r1.1 FileIterator.java
> --- src/java/org/apache/commons/jelly/tags/ant/FileIterator.java 2 Jun
2002 17:29:02 -0000 1.1
> +++ src/java/org/apache/commons/jelly/tags/ant/FileIterator.java 18 Aug
2002 18:51:42 -0000
> @@ -100,9 +100,20 @@
> /** Have we set a next object? */
> private boolean nextObjectSet = false;
>
> - public FileIterator(Project project, Iterator fileSetIterator) {
> + /** Return only directories? */
> + private boolean iterateDirectories = false;
> +
> + public FileIterator(Project project,
> + Iterator fileSetIterator) {
> + this( project, fileSetIterator, false);
> + }
> +
> + public FileIterator(Project project,
> + Iterator fileSetIterator,
> + boolean iterateDirectories) {
> this.project = project;
> this.fileSetIterator = fileSetIterator;
> + this.iterateDirectories = iterateDirectories;
> }
>
> // Iterator interface
> @@ -152,7 +163,11 @@
> FileSet fs = (FileSet) fileSetIterator.next();
> ds = fs.getDirectoryScanner(project);
> ds.scan();
> - files = ds.getIncludedFiles();
> + if (iterateDirectories) {
> + files = ds.getIncludedDirectories();
> + } else {
> + files = ds.getIncludedFiles();
> + }
> if ( files.length > 0 ) {
> fileIndex = -1;
> break;
>
----------------------------------------------------------------------------
----
> Index: src/java/org/apache/commons/jelly/tags/ant/FileScanner.java
> ===================================================================
> RCS file:
/home/cvspublic/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/je
lly/tags/ant/FileScanner.java,v
> retrieving revision 1.4
> diff -u -r1.4 FileScanner.java
> --- src/java/org/apache/commons/jelly/tags/ant/FileScanner.java 1 Aug 2002
09:53:18 -0000 1.4
> +++ src/java/org/apache/commons/jelly/tags/ant/FileScanner.java 18 Aug
2002 18:53:50 -0000
> @@ -91,6 +91,10 @@
> return new FileIterator(project, filesets.iterator());
> }
>
> + public Iterator directories() {
> + return new FileIterator(project, filesets.iterator(), true);
> + }
> +
> public boolean hasFiles() {
> return filesets.size() > 0;
> }
>
----------------------------------------------------------------------------
----
> Index: src/test/org/apache/commons/jelly/ant/filescanner.jelly
> ===================================================================
> RCS file:
/home/cvspublic/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/je
lly/ant/filescanner.jelly,v
> retrieving revision 1.4
> diff -u -r1.4 filescanner.jelly
> --- src/test/org/apache/commons/jelly/ant/filescanner.jelly 28 Jun 2002
11:05:06 -0000 1.4
> +++ src/test/org/apache/commons/jelly/ant/filescanner.jelly 18 Aug 2002
18:52:21 -0000
> @@ -14,4 +14,18 @@
>
> Found ${file.absolutePath}
> </j:forEach>
> +
> + <fileScanner var="dirscanner">
> + <fileset dir="src/test" includes="org/apache/commons/jelly/**"/>
> + </fileScanner>
> +
> + Iterating through test directories
> +
> + <j:forEach var="dir" items="${dirscanner.directories()}">
> + <!-- here we could process the directory in some way -->
> + <!-- such as creating a similar directory in a different base
path -->
> +
> + Found ${dir.absolutePath}
> + </j:forEach>
> +
> </j:jelly>
>
>
----------------------------------------------------------------------------
----
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>