1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly.tags.ant;
17
18 import java.util.ArrayList;
19 import java.util.Iterator;
20 import java.util.List;
21
22 import org.apache.tools.ant.Project;
23 import org.apache.tools.ant.types.FileSet;
24
25 /***
26 * <p><code>FileScanner</code> is a bean which allows the iteration
27 * over a number of files from a colleciton of FileSet instances.
28 *
29 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
30 * @version $Revision: 155420 $
31 */
32 public class FileScanner {
33
34 /*** FileSets */
35 private List filesets = new ArrayList();
36
37 /*** The Ant project */
38 private Project project;
39
40 public void setProject(Project project)
41 {
42 this.project = project;
43 }
44
45 public Iterator iterator() {
46 return new FileIterator(project, filesets.iterator());
47 }
48
49 public Iterator directories() {
50 return new FileIterator(project, filesets.iterator(), true);
51 }
52
53 public boolean hasFiles() {
54 return filesets.size() > 0;
55 }
56
57 /***
58 * Clears any file sets that have been added to this scanner
59 */
60 public void clear() {
61 filesets.clear();
62 }
63
64
65
66
67 /***
68 * Adds a set of files (nested fileset attribute).
69 */
70 public void addFileset(FileSet set) {
71 filesets.add(set);
72 }
73
74 }
75
76