package org.jboss.loom.utils;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.tools.ant.DirectoryScanner;

/**
 *  Usage:
 * 
 *    <pre><code>files = new DirScanner("** /foo/*.bar").list( baseDir );</code></pre>
 * 
 *  @author Ondrej Zizka, ozizka at redhat.com
 */
public class DirScanner {

    private String pattern;
    
    public DirScanner( String pattern ) {
        if( pattern == null )
            throw new IllegalArgumentException("pattern can't be null.");
        this.pattern = pattern;
    }

    public List<File> list( File dirToScan ) throws IOException {
        if( dirToScan == null )
            throw new IllegalArgumentException("dirToScan can't be null.");

        DirectoryScanner ds = new DirectoryScanner();
        String[] includes = { this.pattern };
        //String[] excludes = {"modules\\*\\**"};
        ds.setIncludes(includes);
        //ds.setExcludes(excludes);
        ds.setBasedir( dirToScan );
        //ds.setCaseSensitive(true);
        ds.scan();

        String[] matches = ds.getIncludedFiles();
        List<File> files = new ArrayList(matches.length);
        for (int i = 0; i < matches.length; i++) {
            files.add( new File(matches[i]) );
        }
        return files;
    }

}// class

@@ -97,24 +97,49 @@
 .ArrayList;%0A
+import java.util.Arrays;%0A
 import java.
@@ -145,24 +145,24 @@
 .util.List;%0A
-
 import org.a
@@ -618,20 +618,22 @@
 ic List%3C
-File
+String
 %3E list( 
@@ -1138,24 +1138,204 @@
 dedFiles();%0A
+        return Arrays.asList( matches );%0A    %7D%0A    %0A    public List%3CFile%3E listAsFiles( File dirToScan ) throws IOException %7B%0A        List%3CString%3E matches = this.list( dirToScan );%0A
         List
@@ -1371,22 +1371,22 @@
 matches.
-length
+size()
 );%0A     
@@ -1395,44 +1395,32 @@
  for
- (int i = 0; i %3C matches.length; i++
+( String path : matches 
 ) %7B%0A
@@ -1455,18 +1455,14 @@
 ile(
-matches%5Bi%5D
+ path 
 ) );

Split the transformation to File's.