Skip to content
Snippets Groups Projects
Commit 1231b5a1 authored by Lange, Dr. Herbert's avatar Lange, Dr. Herbert
Browse files

add method to dump report to json

parent 75458ca4
No related branches found
No related tags found
1 merge request!6add feature to load criteria file from resource and place all criteria files...
......@@ -9,10 +9,18 @@
*/
package de.uni_hamburg.corpora;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import de.uni_hamburg.corpora.ReportItem.Severity;
import java.io.File;
import java.io.IOException;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import org.jdom.JDOMException;
/**
......@@ -679,4 +687,20 @@ public class Report {
return line;
}
/**
* Dumps the complete report into a JSON file
* @param filename the filename of the target JSON file
*/
public void dump(String filename) {
// Generate pretty-printed json
ObjectMapper mapper = new ObjectMapper();
// Allows serialization even when getters are missing
mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
mapper.configure(SerializationFeature.INDENT_OUTPUT,true);
try {
mapper.writeValue(new File(filename),this.getRawStatistics());
} catch (IOException e) {
e.printStackTrace();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment