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