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
29 private static final String FS = File.separator;
30
31 public SimpleScanner() {
32 this((File) null, (String) null, (String) null);
33 }
34
35 public SimpleScanner(File baseDir, String include, String exclude) {
36 this(baseDir, CollectionUtils.toEmptyList(include), CollectionUtils.toEmptyList(exclude));
37 }
38
39 public SimpleScanner(File baseDir, List<String> includes, List<String> excludes) {
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
66
67
68
69 public List<String> getDirectories() {
70 scan();
71 String[] includedDirectories = getIncludedDirectories();
72 List<String> directories = new ArrayList<String>();
73 for (String includedDirectory : includedDirectories) {
74 directories.add(includedDirectory);
75 }
76 return directories;
77 }
78 }