11package uniandes .tsdl .mutapk ;
22
3+ import java .io .BufferedWriter ;
34import java .io .File ;
45import java .io .FileInputStream ;
6+ import java .io .FileWriter ;
7+ import java .io .IOException ;
58import java .io .InputStreamReader ;
69import java .util .HashMap ;
710import java .util .List ;
@@ -111,6 +114,7 @@ public static void runMutAPK(String[] args) throws Exception {
111114
112115 //3. Build MutationLocation List
113116 List <MutationLocation > mutationLocationList = MutationLocationListBuilder .buildList (locations );
117+ printLocationList (mutationLocationList , mutantsFolder , appName );
114118 System .out .println ("Total Locations: " +mutationLocationList .size ());
115119
116120 //3. Run mutation phase
@@ -124,4 +128,49 @@ public static void runMutAPK(String[] args) throws Exception {
124128
125129 }
126130
131+ private static void printLocationList (List <MutationLocation > mutationLocationList , String mutantsFolder , String appName ) {
132+
133+ try {
134+ BufferedWriter writer = new BufferedWriter (
135+ new FileWriter (mutantsFolder + File .separator + appName + "-locations.json" ));
136+ writer .write ("{" );
137+ writer .newLine ();
138+ writer .flush ();
139+ for (int i = 0 ; i < mutationLocationList .size (); i ++) {
140+ MutationLocation temp = mutationLocationList .get (i );
141+ writer .write (" \" " +(i +1 )+"\" :{" );
142+ writer .newLine ();
143+ writer .write (" \" mutationTypeID\" :\" " +temp .getType ().getId ()+"\" ," );
144+ writer .newLine ();
145+ writer .write (" \" mutationTypeName\" :\" " +temp .getType ().getName ()+"\" ," );
146+ writer .newLine ();
147+ writer .write (" \" filePath\" :\" " +temp .getFilePath ()+"\" ," );
148+ writer .newLine ();
149+ writer .write (" \" line\" :\" " +temp .getLine ()+"\" ," );
150+ writer .newLine ();
151+ writer .write (" \" startLine\" :\" " +temp .getStartLine ()+"\" ," );
152+ writer .newLine ();
153+ writer .write (" \" endLine\" :\" " +temp .getEndLine ()+"\" ," );
154+ writer .newLine ();
155+ writer .write (" \" startColumn\" :\" " +temp .getStartColumn ()+"\" ," );
156+ writer .newLine ();
157+ writer .write (" \" endColumn\" :\" " +temp .getEndColumn ()+"\" ," );
158+ writer .newLine ();
159+ writer .write (" \" length\" :\" " +temp .getLength ()+"\" " );
160+ writer .newLine ();
161+ writer .write ((i ==mutationLocationList .size ()-1 )?" }" :" }," );
162+ writer .newLine ();
163+ writer .flush ();
164+ }
165+ writer .write ("}" );
166+ writer .newLine ();
167+ writer .flush ();
168+ writer .close ();
169+ } catch (IOException e ) {
170+ // TODO Auto-generated catch block
171+ e .printStackTrace ();
172+ }
173+
174+ }
175+
127176}
0 commit comments