@@ -24,84 +24,97 @@ public static void main(String[] args) throws IOException {
24
24
XmlFileAnalyzer xmlfileAnalyzer = XmlFileAnalyzer .createFileAnalyzer ();
25
25
26
26
ResultsWriter resultsWriter = ResultsWriter .createResultsWriter ();
27
- ClassEntity classEntity ;
28
- XmlEntity xmlEntity ;
29
27
30
28
31
- File rootDirectory = new File ("G:\\ Android\\ Apps" );
32
- FileFilter filter = new FileFilter () {
33
- @ Override
34
- public boolean accept (File pathname ) {
35
- return pathname .isDirectory ();
36
- }
37
- };
38
- File [] directorie = rootDirectory .listFiles ( filter );
39
- // System.out.println(directorie.length);
40
- //
41
- File [] p1 = Arrays .copyOfRange (directorie , Integer .valueOf (args [0 ]), Integer .valueOf (args [1 ]));
29
+ File [] dictList = getDirectoriesList ();
30
+
42
31
43
- File [] directories = p1 ;
32
+
33
+ File [] RangeOfDirectoriesList = Arrays .copyOfRange (dictList , Integer .valueOf (args [0 ]), Integer .valueOf (args [1 ]));
34
+
35
+ File [] directories = RangeOfDirectoriesList ;
44
36
45
37
for (File dir : directories ){
46
38
47
39
//recursively identify all files with the specified extension in the specified directory
48
40
49
- Util .writeOperationLogEntry ("Identify all '" +fileExtension +"' test files" , Util .OperationStatus .Started );
41
+ Util .writeOperationLogEntry ("Identify all '" +fileExtension +"' java files" , Util .OperationStatus .Started );
50
42
FileWalker fw = new FileWalker ();
51
43
List <List <Path >> files = fw .getFiles (dir .getPath (),true ,fileExtension ,secondFileExtension );
52
- Util .writeOperationLogEntry ("Identify all '" +fileExtension +"' test files" , Util .OperationStatus .Completed );
44
+ Util .writeOperationLogEntry ("Identify all '" +fileExtension +"' java files" , Util .OperationStatus .Completed );
45
+
46
+
47
+ // foreach of the identified 'java' files, obtain details about the methods that they contain
48
+ Util .writeOperationLogEntry ("Obtain method details" , Util .OperationStatus .Started );
49
+ for (Path file : files .get (0 )) {
53
50
51
+ checkJavaFiles (fileAnalyzer , resultsWriter , file );
52
+
53
+ }
54
+ Util .writeOperationLogEntry ("Obtain method details" , Util .OperationStatus .Completed );
54
55
55
- //foreach of the identified 'java' files, obtain details about the methods that they contain
56
- // Util.writeOperationLogEntry("Obtain method details", Util.OperationStatus.Started);
57
- // for (Path file : files.get(0)) {
58
- // try {
59
- // classEntity = fileAnalyzer.runAnalysis(file);
60
- // resultsWriter.outputToCSV(classEntity);
61
- // } catch (Exception e) {
62
- // Util.writeException(e, "File: " + file.toAbsolutePath().toString());
63
- // }
64
- // }
65
- // Util.writeOperationLogEntry("Obtain method details", Util.OperationStatus.Completed);
66
56
67
57
Util .writeOperationLogEntry ("Obtain Xml details" +files .get (1 ).size (), Util .OperationStatus .Started );
68
58
for (Path file : files .get (1 )) {
69
- try {
70
59
60
+ checkXmlFiles (xmlfileAnalyzer , resultsWriter , file );
61
+ }
62
+ Util .writeOperationLogEntry ("Obtain Xml details" , Util .OperationStatus .Completed );
71
63
72
- if (file .toAbsolutePath ().toString ().toLowerCase ().contains ("\\ res\\ " )
73
- || file .getFileName ().toString ().equalsIgnoreCase ("AndroidManifest.xml" )
74
- || file .toAbsolutePath ().toString ().toLowerCase ().contains ("\\ resources\\ " )) {
75
64
65
+ }
76
66
77
- if (file .toAbsolutePath ().toString ().toLowerCase ().contains ("\\ layout\\ " )
78
- || file .getFileName ().toString ().equalsIgnoreCase ("AndroidManifest.xml" )){
79
67
80
- xmlEntity = xmlfileAnalyzer .runAnalysis (file );
81
68
82
- resultsWriter .outputXmlToCSV (xmlEntity );
83
69
84
- }
85
70
86
- }
87
71
88
72
89
- } catch (Exception e ) {
90
- Util .writeException (e , "XML: " + file .toAbsolutePath ().toString ());
91
- }
92
- }
93
- Util .writeOperationLogEntry ("Obtain Xml details" , Util .OperationStatus .Completed );
94
73
74
+ resultsWriter .closeOutputFiles ();
75
+ }
76
+
77
+ public static File [] getDirectoriesList () {
78
+ File rootDirectory = new File ("E:\\ P" );
79
+ FileFilter filter = pathname -> pathname .isDirectory ();
80
+
81
+ return rootDirectory .listFiles ( filter );
82
+ }
95
83
84
+ private static void checkJavaFiles (FileAnalyzer fileAnalyzer , ResultsWriter resultsWriter , Path file ) throws IOException {
85
+ ClassEntity classEntity ;
86
+ try {
87
+ classEntity = fileAnalyzer .runAnalysis (file );
88
+ resultsWriter .outputToCSV (classEntity );
89
+ } catch (Exception e ) {
90
+ Util .writeException (e , "File: " + file .toAbsolutePath ().toString ());
96
91
}
92
+ }
97
93
94
+ private static void checkXmlFiles (XmlFileAnalyzer xmlfileAnalyzer , ResultsWriter resultsWriter , Path file ) throws IOException {
95
+ XmlEntity xmlEntity ;
96
+ try {
98
97
99
98
99
+ if (file .toAbsolutePath ().toString ().toLowerCase ().contains ("\\ res\\ " )
100
+ || file .getFileName ().toString ().equalsIgnoreCase ("AndroidManifest.xml" )
101
+ || file .toAbsolutePath ().toString ().toLowerCase ().contains ("\\ resources\\ " )) {
100
102
101
103
104
+ if (file .toAbsolutePath ().toString ().toLowerCase ().contains ("\\ layout\\ " )
105
+ || file .getFileName ().toString ().equalsIgnoreCase ("AndroidManifest.xml" )){
102
106
107
+ xmlEntity = xmlfileAnalyzer .runAnalysis (file );
103
108
109
+ resultsWriter .outputXmlToCSV (xmlEntity );
104
110
105
- resultsWriter .closeOutputFiles ();
111
+ }
112
+
113
+ }
114
+
115
+
116
+ } catch (Exception e ) {
117
+ Util .writeException (e , "XML: " + file .toAbsolutePath ().toString ());
118
+ }
106
119
}
107
120
}
0 commit comments