View Javadoc
1 package net.sf.cglib.transform; 2 3 4 5 import java.io.File; 6 7 import java.util.*; 8 9 import org.apache.tools.ant.BuildException; 10 11 import org.apache.tools.ant.DirectoryScanner; 12 13 import org.apache.tools.ant.Project; 14 15 import org.apache.tools.ant.Task; 16 17 import org.apache.tools.ant.types.FileSet; 18 19 20 21 abstract public class AbstractProcessTask extends Task { 22 23 private Vector filesets = new Vector(); 24 25 26 27 public void addFileset(FileSet set) { 28 29 filesets.addElement(set); 30 31 } 32 33 34 35 private Collection getFiles() { 36 37 Map fileMap = new HashMap(); 38 39 Project p = getProject(); 40 41 for (int i = 0; i < filesets.size(); i++) { 42 43 FileSet fs = (FileSet)filesets.elementAt(i); 44 45 DirectoryScanner ds = fs.getDirectoryScanner(p); 46 47 String[] srcFiles = ds.getIncludedFiles(); 48 49 File dir = fs.getDir(p); 50 51 for (int j = 0; j < srcFiles.length; j++) { 52 53 File src = new File(dir, srcFiles[j]); 54 55 fileMap.put(src.getAbsolutePath(), src); 56 57 } 58 59 } 60 61 return fileMap.values(); 62 63 } 64 65 66 67 public void execute() throws BuildException { 68 69 beforeExecute(); 70 71 for (Iterator it = getFiles().iterator(); it.hasNext();) { 72 73 try { 74 75 processFile((File)it.next()); 76 77 } catch (Exception e) { 78 79 throw new BuildException(e); 80 81 } 82 83 } 84 85 } 86 87 88 89 protected void beforeExecute() throws BuildException { } 90 91 abstract protected void processFile(File file) throws Exception; 92 93 } 94

This page was automatically generated by Maven