01: package org.slf4j.migrator;
02:
03: import java.io.File;
04: import java.util.ArrayList;
05: import java.util.List;
06:
07: import org.slf4j.migrator.internal.ProgressListener;
08:
09: public class FileSelector {
10:
11: private List<File> javaFileList = new ArrayList<File>();
12:
13: ProgressListener pl;
14:
15: FileSelector(ProgressListener pl) {
16: this .pl = pl;
17: }
18:
19: public List<File> selectJavaFilesInFolder(File folder) {
20: if (folder.isDirectory()) {
21: selectFiles(folder);
22: return javaFileList;
23: } else {
24: throw new IllegalArgumentException("[" + folder
25: + "] is not a directory");
26: }
27: }
28:
29: private void selectFiles(File file) {
30: if (file.isDirectory()) {
31: pl.onDirectory(file);
32: File[] files = file.listFiles();
33: if (files != null) {
34: for (int i = 0; i < files.length; i++) {
35: selectFiles(files[i]);
36: }
37: }
38: } else {
39: if (file.getName().endsWith(".java")) {
40: pl.onFileAddition(file);
41: javaFileList.add(file);
42: }
43:
44: }
45: }
46: }
|