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