1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.torque.util;
17
18 import java.io.File;
19 import java.util.ArrayList;
20 import java.util.Collections;
21 import java.util.List;
22
23 import org.codehaus.plexus.util.DirectoryScanner;
24
25
26
27
28 public class SimpleScanner extends DirectoryScanner {
29 private static final String FS = System.getProperty("file.separator");
30
31 public SimpleScanner() {
32 this(null, getArray(null), getArray(null));
33 }
34
35 public SimpleScanner(File baseDir, String include, String exclude) {
36 this(baseDir, getArray(include), getArray(exclude));
37 }
38
39 public SimpleScanner(File baseDir, String[] includes, String[] excludes) {
40 super();
41 setBasedir(baseDir);
42 setIncludes(includes);
43 setExcludes(excludes);
44 }
45
46 protected static final String[] getArray(String s) {
47 if (s == null) {
48 return null;
49 } else {
50 return new String[] { s };
51 }
52 }
53
54
55
56
57 public List<File> getFiles() {
58 scan();
59 String[] includedFiles = getIncludedFiles();
60 List<File> files = new ArrayList<File>();
61 for (String includedFile : includedFiles) {
62 String filename = getBasedir().getAbsolutePath() + FS + includedFile;
63 File file = new File(filename);
64 files.add(file);
65 }
66 Collections.sort(files);
67 return files;
68 }
69 }