11
11
12
12
public class ResultsWriter {
13
13
14
- private CSVWriter classCSVWriter , methodCSVWriter ;
14
+ private CSVWriter classCSVWriter , methodCSVWriter , xmlCSVWriter ;
15
15
16
16
public static ResultsWriter createResultsWriter () throws IOException {
17
17
return new ResultsWriter ();
@@ -21,13 +21,31 @@ private ResultsWriter() throws IOException {
21
21
String time = String .valueOf (Calendar .getInstance ().getTimeInMillis ());
22
22
String classFileName = MessageFormat .format ("{0}_{1}_{2}.{3}" , "Output" , "Class" , time , "csv" );
23
23
String methodFileName = MessageFormat .format ("{0}_{1}_{2}.{3}" , "Output" , "Method" , time , "csv" );
24
+ String xmlFileName = MessageFormat .format ("{0}_{1}_{2}.{3}" , "Output" , "Xml" , time , "csv" );
25
+
24
26
methodCSVWriter = new CSVWriter (new FileWriter (methodFileName ), ',' );
25
27
classCSVWriter = new CSVWriter (new FileWriter (classFileName ), ',' );
28
+ xmlCSVWriter = new CSVWriter (new FileWriter (xmlFileName ), ',' );
26
29
27
30
createClassFile ();
28
31
createMethodFile ();
32
+ createXmlFile ();
29
33
}
30
34
35
+ private void createXmlFile () throws IOException {
36
+ List <String []> fileLines = new ArrayList <String []>();
37
+ String [] columnNames = {
38
+ "App" ,
39
+ "Tag" ,
40
+ "FilePath" ,
41
+ "RelativeFilePath" ,
42
+ "FileName"
43
+ };
44
+ fileLines .add (columnNames );
45
+
46
+ xmlCSVWriter .writeAll (fileLines , false );
47
+ xmlCSVWriter .flush ();
48
+ }
31
49
private void createClassFile () throws IOException {
32
50
List <String []> fileLines = new ArrayList <String []>();
33
51
String [] columnNames = {
@@ -39,7 +57,7 @@ private void createClassFile() throws IOException {
39
57
"ClassName" ,
40
58
"TotalImports" ,
41
59
"TotalMethods" ,
42
- "TotalMethodStatements"
60
+ "TotalMethodStatements" , "LayoutName"
43
61
};
44
62
fileLines .add (columnNames );
45
63
@@ -61,6 +79,7 @@ private void createMethodFile() throws IOException {
61
79
"TotalParameters" ,
62
80
"ReturnType" ,
63
81
"AccessModifier"
82
+
64
83
};
65
84
fileLines .add (columnNames );
66
85
@@ -72,10 +91,13 @@ public void outputToCSV(ClassEntity classEntity) throws IOException {
72
91
outputClassDetails (classEntity );
73
92
outputMethodDetails (classEntity );
74
93
}
75
-
94
+ public void outputXmlToCSV (ClassEntity classEntity ) throws IOException {
95
+ outputXmlDetails (classEntity );
96
+ }
76
97
public void closeOutputFiles () throws IOException {
77
98
classCSVWriter .close ();
78
99
methodCSVWriter .close ();
100
+
79
101
}
80
102
81
103
private void outputMethodDetails (ClassEntity classEntity ) throws IOException {
@@ -102,11 +124,11 @@ private void outputMethodDetails(ClassEntity classEntity) throws IOException {
102
124
methodCSVWriter .flush ();
103
125
}
104
126
105
- private void outputClassDetails (ClassEntity classEntity ) throws IOException {
127
+ private void outputClassDetails (ClassEntity classEntity ) throws IOException {
106
128
List <String []> fileLines = new ArrayList <String []>();
107
129
String [] dataLine ;
108
130
109
- dataLine = new String [9 ];
131
+ dataLine = new String [10 ];
110
132
dataLine [0 ] = classEntity .getAppName ();
111
133
dataLine [1 ] = classEntity .getTagName ();
112
134
dataLine [2 ] = classEntity .getFilePath ();
@@ -116,10 +138,28 @@ private void outputClassDetails(ClassEntity classEntity) throws IOException {
116
138
dataLine [6 ] = String .valueOf (classEntity .getTotalImports ());
117
139
dataLine [7 ] = String .valueOf (classEntity .getTotalMethods ());
118
140
dataLine [8 ] = String .valueOf (classEntity .getTotalMethodStatement ());
141
+ dataLine [9 ] = classEntity .getLayoutName ();
119
142
120
143
fileLines .add (dataLine );
121
144
122
145
classCSVWriter .writeAll (fileLines , false );
123
146
classCSVWriter .flush ();
124
147
}
148
+
149
+ private void outputXmlDetails (ClassEntity classEntity ) throws IOException {
150
+ List <String []> fileLines = new ArrayList <String []>();
151
+ String [] dataLine ;
152
+
153
+ dataLine = new String [5 ];
154
+ dataLine [0 ] = classEntity .getAppName ();
155
+ dataLine [1 ] = classEntity .getTagName ();
156
+ dataLine [2 ] = classEntity .getFilePath ();
157
+ dataLine [3 ] = classEntity .getRelativeFilePath ();
158
+ dataLine [4 ] = classEntity .getFileName ();
159
+
160
+ fileLines .add (dataLine );
161
+
162
+ xmlCSVWriter .writeAll (fileLines , false );
163
+ xmlCSVWriter .flush ();
164
+ }
125
165
}
0 commit comments