commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/ant FileIterator.java FileScanner.java
Date Mon, 19 Aug 2002 07:07:01 GMT
jstrachan    2002/08/19 00:07:01

  Modified:    jelly/src/test/org/apache/commons/jelly/ant
                        filescanner.jelly
               jelly/src/java/org/apache/commons/jelly/tags/ant
                        FileIterator.java FileScanner.java
  Log:
  Applied Calvin Yu's patches that <fileScanner> can be used to iterate through just
directories rather than files.
  
  Revision  Changes    Path
  1.5       +31 -17    jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/ant/filescanner.jelly
  
  Index: filescanner.jelly
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/ant/filescanner.jelly,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- filescanner.jelly	28 Jun 2002 11:05:06 -0000	1.4
  +++ filescanner.jelly	19 Aug 2002 07:07:00 -0000	1.5
  @@ -1,17 +1,31 @@
  -<?xml version="1.0"?>
  -<j:jelly xmlns:j="jelly:core" xmlns="jelly:ant">
  -
  -  <fileScanner var="scanner">
  -    <fileset dir="src/test" includes="**/*.jelly"/>
  -  </fileScanner>
  -    
  -  Iterating through build files
  -  
  -  <j:forEach var="file" items="${scanner.iterator()}">
  -  
  -    <!-- here we could parse the file or process it in some way -->
  -    <!-- such as by calling <ant> with the given build.xml file -->
  -      
  -    Found ${file.absolutePath}
  -  </j:forEach>
  -</j:jelly>
  +<?xml version="1.0"?>
  +<j:jelly xmlns:j="jelly:core" xmlns="jelly:ant">
  +
  +  <fileScanner var="scanner">
  +    <fileset dir="src/test" includes="**/*.jelly"/>
  +  </fileScanner>
  +    
  +  Iterating through build files
  +  
  +  <j:forEach var="file" items="${scanner.iterator()}">
  +  
  +    <!-- here we could parse the file or process it in some way -->
  +    <!-- such as by calling <ant> with the given build.xml file -->
  +      
  +    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>
  
  
  
  1.2       +18 -2     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/ant/FileIterator.java
  
  Index: FileIterator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/ant/FileIterator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FileIterator.java	2 Jun 2002 17:29:02 -0000	1.1
  +++ FileIterator.java	19 Aug 2002 07:07:00 -0000	1.2
  @@ -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,12 @@
                   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;
  
  
  
  1.5       +4 -0      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/ant/FileScanner.java
  
  Index: FileScanner.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/ant/FileScanner.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FileScanner.java	1 Aug 2002 09:53:18 -0000	1.4
  +++ FileScanner.java	19 Aug 2002 07:07:00 -0000	1.5
  @@ -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;
       }        
  
  
  

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


Mime
View raw message