1 7 package com.inversoft.savant.ant.types; 8 9 10 import java.io.File ; 11 import java.util.ArrayList ; 12 import java.util.Iterator ; 13 import java.util.List ; 14 15 import org.apache.tools.ant.BuildException; 16 import org.apache.tools.ant.DirectoryScanner; 17 import org.apache.tools.ant.Project; 18 import org.apache.tools.ant.types.FileSet; 19 import org.apache.tools.ant.types.Resource; 20 import org.apache.tools.ant.types.selectors.FileSelector; 21 import org.apache.tools.ant.util.FileUtils; 22 23 24 32 public class CompositeFileset extends FileSet { 33 34 List filesets = new ArrayList (); 35 36 37 public CompositeFileset() { 38 } 39 40 protected CompositeFileset(FileSet fileSet) { 41 super(fileSet); 42 } 43 44 45 public void addFileset(FileSet fs) throws BuildException { 46 filesets.add(fs); 47 } 48 49 public DirectoryScanner getDirectoryScanner(Project p) { 50 return new CompositeDirectoryScanner(filesets, p); 51 } 52 53 54 public static class CompositeDirectoryScanner extends DirectoryScanner { 55 56 private List fileList = new ArrayList (); 57 58 59 public CompositeDirectoryScanner(List filesets, Project p) { 60 Iterator iter = filesets.iterator(); 61 FileSet fs; 62 DirectoryScanner ds; 63 String [] files; 64 File dir; 65 while (iter.hasNext()) { 66 fs = (FileSet) iter.next(); 67 ds = fs.getDirectoryScanner(p); 68 69 files = ds.getIncludedFiles(); 70 dir = ds.getBasedir(); 71 for (int i = 0; i < files.length; i++) { 72 fileList.add(dir.getAbsolutePath() + File.separator + files[i]); 73 p.log("Added file: " + dir.getAbsolutePath() + File.separator + 74 files[i], Project.MSG_DEBUG); 75 } 76 } 77 } 78 79 80 81 public File getBasedir() { 82 File here = new File ("."); 83 File parent = null; 84 while (here.getParentFile() != null) { 85 parent = here.getParentFile(); 86 } 87 88 return parent; 89 } 90 91 public void setBasedir(String basedir) { 92 } 94 95 public void setBasedir(File basedir) { 96 } 98 99 public boolean isCaseSensitive() { 100 return true; 101 } 102 103 public void setCaseSensitive(boolean isCaseSensitive) { 104 } 106 107 public boolean isFollowSymlinks() { 108 return true; 109 } 110 111 public void setFollowSymlinks(boolean followSymlinks) { 112 } 114 115 public void setIncludes(String [] includes) { 116 } 118 119 public void setExcludes(String [] excludes) { 120 } 122 123 public void setSelectors(FileSelector[] selectors) { 124 } 126 127 public boolean isEverythingIncluded() { 128 return true; 129 } 130 131 protected boolean isIncluded(String name) { 132 return fileList.contains(name); 133 } 134 135 protected boolean isExcluded(String name) { 136 return !fileList.contains(name); 137 } 138 139 protected boolean isSelected(String name, File file) { 140 return false; 141 } 142 143 public String [] getIncludedFiles() { 144 return (String []) fileList.toArray(new String [fileList.size()]); 145 } 146 147 public String [] getNotIncludedFiles() { 148 return new String [0]; 149 } 150 151 public String [] getExcludedFiles() { 152 return new String [0]; 153 } 154 155 public String [] getDeselectedFiles() { 156 return new String [0]; 157 } 158 159 public String [] getIncludedDirectories() { 160 return new String [0]; 161 } 162 163 public String [] getNotIncludedDirectories() { 164 return new String [0]; 165 } 166 167 public String [] getExcludedDirectories() { 168 return new String [0]; 169 } 170 171 public String [] getDeselectedDirectories() { 172 return new String [0]; 173 } 174 175 public Resource getResource(String name) { 176 File f = FileUtils.newFileUtils().resolveFile(basedir, name); 177 return new Resource(name, f.exists(), f.lastModified(), 178 f.isDirectory()); 179 } 180 181 public void addDefaultExcludes() { 182 } 184 185 protected boolean couldHoldIncluded(String name) { 186 return false; 187 } 188 189 public void scan() throws IllegalStateException { 190 } 192 193 protected void slowScan() { 194 } 196 197 protected void scandir(File dir, String vpath, boolean fast) { 198 } 200 } 201 } | Popular Tags |