1111
1212public class ResultsWriter {
1313
14- private CSVWriter classCSVWriter , methodCSVWriter ;
14+ private CSVWriter classCSVWriter , methodCSVWriter , debtCSVWriter ;
1515
1616 public static ResultsWriter createResultsWriter () throws IOException {
1717 return new ResultsWriter ();
@@ -21,11 +21,30 @@ private ResultsWriter() throws IOException {
2121 String time = String .valueOf (Calendar .getInstance ().getTimeInMillis ());
2222 String classFileName = MessageFormat .format ("{0}_{1}_{2}.{3}" , "Output" , "Class" , time , "csv" );
2323 String methodFileName = MessageFormat .format ("{0}_{1}_{2}.{3}" , "Output" , "Method" , time , "csv" );
24+ String debtFileName = MessageFormat .format ("{0}_{1}_{2}.{3}" , "Output" , "Debt" , time , "csv" );
2425 methodCSVWriter = new CSVWriter (new FileWriter (methodFileName ), ',' );
2526 classCSVWriter = new CSVWriter (new FileWriter (classFileName ), ',' );
27+ debtCSVWriter = new CSVWriter (new FileWriter (debtFileName ), ',' );
2628
2729 createClassFile ();
2830 createMethodFile ();
31+ createDebtFile ();
32+ }
33+ private void createDebtFile () throws IOException {
34+ List <String []> fileLines = new ArrayList <String []>();
35+ String [] columnNames = {
36+ "App" ,
37+ "Tag" ,
38+ "FilePath" ,
39+ "RelativeFilePath" ,
40+ "FileName" ,
41+ "ClassName" ,
42+ "Comment"
43+ };
44+ fileLines .add (columnNames );
45+
46+ debtCSVWriter .writeAll (fileLines , false );
47+ debtCSVWriter .flush ();
2948 }
3049
3150 private void createClassFile () throws IOException {
@@ -88,11 +107,33 @@ private void createMethodFile() throws IOException {
88107 public void outputToCSV (ClassEntity classEntity ) throws IOException {
89108 outputClassDetails (classEntity );
90109 outputMethodDetails (classEntity );
110+ outputDebtDetails (classEntity );
111+ }
112+
113+ private void outputDebtDetails (ClassEntity classEntity ) throws IOException {
114+ List <String []> fileLines = new ArrayList <String []>();
115+ String [] dataLine ;
116+ for (String comment : classEntity .getTechnicalDebtComments ()) {
117+
118+ dataLine = new String [7 ];
119+ dataLine [0 ] = classEntity .getAppName ();
120+ dataLine [1 ] = classEntity .getTagName ();
121+ dataLine [2 ] = classEntity .getFilePath ();
122+ dataLine [3 ] = classEntity .getRelativeFilePath ();
123+ dataLine [4 ] = classEntity .getFileName ();
124+ dataLine [5 ] = classEntity .getClassName ();
125+ dataLine [6 ] = "\" " +comment .replace ('"' ,' ' )+"\" " ;
126+
127+ fileLines .add (dataLine );
128+ }
129+ debtCSVWriter .writeAll (fileLines , false );
130+ debtCSVWriter .flush ();
91131 }
92132
93133 public void closeOutputFiles () throws IOException {
94134 classCSVWriter .close ();
95135 methodCSVWriter .close ();
136+ debtCSVWriter .close ();
96137 }
97138
98139 private void outputMethodDetails (ClassEntity classEntity ) throws IOException {
0 commit comments