1 18 19 package org.apache.tools.ant.taskdefs; 20 21 import java.io.File ; 22 import java.util.Enumeration ; 23 import java.util.StringTokenizer ; 24 import org.apache.tools.ant.DirectoryScanner; 25 import org.apache.tools.ant.Project; 26 import org.apache.tools.ant.Task; 27 import org.apache.tools.ant.types.FileSet; 28 import org.apache.tools.ant.types.PatternSet; 29 import org.apache.tools.ant.types.selectors.AndSelector; 30 import org.apache.tools.ant.types.selectors.ContainsRegexpSelector; 31 import org.apache.tools.ant.types.selectors.ContainsSelector; 32 import org.apache.tools.ant.types.selectors.DateSelector; 33 import org.apache.tools.ant.types.selectors.DependSelector; 34 import org.apache.tools.ant.types.selectors.DepthSelector; 35 import org.apache.tools.ant.types.selectors.DifferentSelector; 36 import org.apache.tools.ant.types.selectors.ExtendSelector; 37 import org.apache.tools.ant.types.selectors.FileSelector; 38 import org.apache.tools.ant.types.selectors.FilenameSelector; 39 import org.apache.tools.ant.types.selectors.MajoritySelector; 40 import org.apache.tools.ant.types.selectors.NoneSelector; 41 import org.apache.tools.ant.types.selectors.NotSelector; 42 import org.apache.tools.ant.types.selectors.OrSelector; 43 import org.apache.tools.ant.types.selectors.PresentSelector; 44 import org.apache.tools.ant.types.selectors.SelectSelector; 45 import org.apache.tools.ant.types.selectors.SelectorContainer; 46 import org.apache.tools.ant.types.selectors.SizeSelector; 47 import org.apache.tools.ant.types.selectors.TypeSelector; 48 import org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector; 49 50 56 57 public abstract class MatchingTask extends Task implements SelectorContainer { 58 59 protected FileSet fileset = new FileSet(); 61 63 64 public void setProject(Project project) { 65 super.setProject(project); 66 fileset.setProject(project); 67 } 68 69 73 public PatternSet.NameEntry createInclude() { 74 return fileset.createInclude(); 75 } 76 77 81 public PatternSet.NameEntry createIncludesFile() { 82 return fileset.createIncludesFile(); 83 } 84 85 89 public PatternSet.NameEntry createExclude() { 90 return fileset.createExclude(); 91 } 92 93 97 public PatternSet.NameEntry createExcludesFile() { 98 return fileset.createExcludesFile(); 99 } 100 101 105 public PatternSet createPatternSet() { 106 return fileset.createPatternSet(); 107 } 108 109 115 public void setIncludes(String includes) { 116 fileset.setIncludes(includes); 117 } 118 119 127 public void XsetItems(String itemString) { 128 log("The items attribute is deprecated. " 129 + "Please use the includes attribute.", Project.MSG_WARN); 130 if (itemString == null || itemString.equals("*") 131 || itemString.equals(".")) { 132 createInclude().setName("**"); 133 } else { 134 StringTokenizer tok = new StringTokenizer (itemString, ", "); 135 while (tok.hasMoreTokens()) { 136 String pattern = tok.nextToken().trim(); 137 if (pattern.length() > 0) { 138 createInclude().setName(pattern + "/**"); 139 } 140 } 141 } 142 } 143 144 150 public void setExcludes(String excludes) { 151 fileset.setExcludes(excludes); 152 } 153 154 160 public void XsetIgnore(String ignoreString) { 161 log("The ignore attribute is deprecated." 162 + "Please use the excludes attribute.", Project.MSG_WARN); 163 if (ignoreString != null && ignoreString.length() > 0) { 164 StringTokenizer tok = new StringTokenizer (ignoreString, ", ", 165 false); 166 while (tok.hasMoreTokens()) { 167 createExclude().setName("**/" + tok.nextToken().trim() + "/**"); 168 } 169 } 170 } 171 172 174 181 public void setDefaultexcludes(boolean useDefaultExcludes) { 182 fileset.setDefaultexcludes(useDefaultExcludes); 183 } 184 185 190 protected DirectoryScanner getDirectoryScanner(File baseDir) { 191 fileset.setDir(baseDir); 192 return fileset.getDirectoryScanner(getProject()); 193 } 194 195 201 public void setIncludesfile(File includesfile) { 202 fileset.setIncludesfile(includesfile); 203 } 204 205 211 public void setExcludesfile(File excludesfile) { 212 fileset.setExcludesfile(excludesfile); 213 } 214 215 221 public void setCaseSensitive(boolean isCaseSensitive) { 222 fileset.setCaseSensitive(isCaseSensitive); 223 } 224 225 230 public void setFollowSymlinks(boolean followSymlinks) { 231 fileset.setFollowSymlinks(followSymlinks); 232 } 233 234 239 public boolean hasSelectors() { 240 return fileset.hasSelectors(); 241 } 242 243 248 public int selectorCount() { 249 return fileset.selectorCount(); 250 } 251 252 257 public FileSelector[] getSelectors(Project p) { 258 return fileset.getSelectors(p); 259 } 260 261 266 public Enumeration selectorElements() { 267 return fileset.selectorElements(); 268 } 269 270 275 public void appendSelector(FileSelector selector) { 276 fileset.appendSelector(selector); 277 } 278 279 280 281 285 public void addSelector(SelectSelector selector) { 286 fileset.addSelector(selector); 287 } 288 289 293 public void addAnd(AndSelector selector) { 294 fileset.addAnd(selector); 295 } 296 297 301 public void addOr(OrSelector selector) { 302 fileset.addOr(selector); 303 } 304 305 309 public void addNot(NotSelector selector) { 310 fileset.addNot(selector); 311 } 312 313 317 public void addNone(NoneSelector selector) { 318 fileset.addNone(selector); 319 } 320 321 325 public void addMajority(MajoritySelector selector) { 326 fileset.addMajority(selector); 327 } 328 329 333 public void addDate(DateSelector selector) { 334 fileset.addDate(selector); 335 } 336 337 341 public void addSize(SizeSelector selector) { 342 fileset.addSize(selector); 343 } 344 345 349 public void addFilename(FilenameSelector selector) { 350 fileset.addFilename(selector); 351 } 352 353 357 public void addCustom(ExtendSelector selector) { 358 fileset.addCustom(selector); 359 } 360 361 365 public void addContains(ContainsSelector selector) { 366 fileset.addContains(selector); 367 } 368 369 373 public void addPresent(PresentSelector selector) { 374 fileset.addPresent(selector); 375 } 376 377 381 public void addDepth(DepthSelector selector) { 382 fileset.addDepth(selector); 383 } 384 385 389 public void addDepend(DependSelector selector) { 390 fileset.addDepend(selector); 391 } 392 393 397 public void addContainsRegexp(ContainsRegexpSelector selector) { 398 fileset.addContainsRegexp(selector); 399 } 400 401 406 public void addDifferent(DifferentSelector selector) { 407 fileset.addDifferent(selector); 408 } 409 410 415 public void addType(TypeSelector selector) { 416 fileset.addType(selector); 417 } 418 419 424 public void addModified(ModifiedSelector selector) { 425 fileset.addModified(selector); 426 } 427 428 433 public void add(FileSelector selector) { 434 fileset.add(selector); 435 } 436 437 442 protected final FileSet getImplicitFileSet() { 443 return fileset; 444 } 445 } 446 | Popular Tags |