10 package de.uni_hamburg.corpora;
13 import org.xml.sax.SAXParseException;
14 import java.io.StringWriter;
15 import java.io.PrintWriter;
16 import java.sql.Timestamp;
17 import java.util.Collection;
63 private String filename;
70 private String columns;
72 private String
function;
79 what =
"Totally unknown error";
80 howto =
"No known fixes";
82 function =
"Unknown function";
88 this.
function =
"Unknown function";
95 this.
function =
"Unknown function";
102 this.filename = filename;
103 this.
function =
"Unknown function";
109 this.filename = filename;
110 this.
function =
function;
123 this.filename = saxpe.getSystemId();
124 this.lines =
"" + saxpe.getLineNumber();
125 this.columns =
"" + saxpe.getColumnNumber();
126 this.
function =
"Unknown function";
135 String what, String
function, String howto) {
137 this.filename = filename;
140 this.
function =
function;
147 return this.severity;
162 System.out.println(
"Missed a severity case in isGood :-(");
179 System.out.println(
"Missed a severity case in isBad :-(");
196 System.out.println(
"Missed a severity case in isSevere :-(");
213 System.out.println(
"Missed a severity case in isFix :-(");
222 String loc =
new String();
223 if (filename != null) {
229 if (columns != null) {
230 loc +=
":" + lines +
"." + columns;
249 if (this.howto != null) {
260 if (this.
function != null) {
261 return this.
function;
272 return e.getLocalizedMessage();
304 StringWriter sw =
new StringWriter();
305 PrintWriter pw =
new PrintWriter(sw);
306 e.printStackTrace(pw);
307 return sw.toString();
323 String report =
new String();
329 switch (error.getSeverity()) {
346 report +=
"Messages (" + errors.size() +
"), of which: ";
348 report += criticals +
" critical, " + warnings +
" warnings, " +
349 notes +
" notes and " + unknowns +
" not classified\n";
351 report += criticals +
" critical and " + warnings +
352 " warnings (and " + (notes + unknowns) +
353 " hidden as non-problems or unknown)\n";
357 report +=
" " + error +
"\n";
360 report +=
" " + error.getLocation() +
": " +
361 error.getWhat() +
"\n" +
362 " " + error.getHowto() +
"\n";
373 String report =
new String();
379 switch (error.getSeverity()) {
396 report =
"Total of " + (criticals + warnings + notes + unknowns) +
397 " menssages: " + criticals +
" critical errors, " +
398 warnings +
" warnings, " + notes +
" notes and " + unknowns +
415 switch (error.getSeverity()) {
432 String report =
new String();
434 report +=
"<script type='text/javascript'>\n" +
435 "function showClick(clicksource, stuff) {\n\t" +
436 " var elems = document.getElementsByClassName(stuff);\n" +
437 " for (i = 0; i < elems.length; i++) {\n" +
438 " if (clicksource.checked) {\n" +
439 " elems[i].style.display = 'table-row';\n" +
441 " elems[i].style.display = 'none';\n" +
445 report +=
"<form>\n" +
446 " <input type='checkbox' id='critical' name='critical' value='show' checked='checked' onclick='showClick(this, 'critical')'>" 447 +
"Show criticals (" + criticals +
")</input>" +
448 " <input type='checkbox' name='warning' value='show' checked='checked' onclick='showClick(this, 'warning')'>" 449 +
"Show warnings (" + warnings +
")</input>" +
450 " <input type='checkbox' name='note' value='show' onclick='showClick(this, 'note')'>" 451 +
"Show notes (" + notes +
")</input>" +
452 " <input type='checkbox' name='unknown' value='show' onclick='showClick(this, 'unknown')'>" 453 +
"Show unknowns (" + unknowns +
")</input>" +
455 report +=
"<table>\n <thead><tr>" +
456 "<th>File:line.column</th><th>Error</th>" +
457 "<th>Fix</th><th>Original</th>" +
459 report +=
" <tbody>\n";
461 switch (error.getSeverity()) {
463 report +=
"<tr class='critical'><td style='border-left: red solid 3px'>";
466 report +=
"<tr class='warning'><td style='border-left: yellow solid 3px'>";
469 report +=
"<tr class='note' style='display: none;'><td style='border-left: green solid 3px'>";
472 report +=
"<tr class='unknown' style='display: none;'><td style='border-left: orange solid 3px'>";
475 report +=
"<tr class='other' style='display: none;'><td style='border-left: black solid 3px'>";
478 report += error.getLocation() +
"</td>";
479 report +=
"<td style='border: red solid 1px; white-space: pre'>" +
482 report +=
"<td style='border: green solid 1px; white-space: pre'>" +
485 report +=
"<td style='font-face: monospace; color: gray; border: gray solid 1px; white-space: pre'>(" +
486 error.getLocalisedMessage() +
488 report +=
"<!-- " + error.getStackTrace() +
" -->\n";
491 report +=
" </tbody>\n </table>\n";
504 String report =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
506 report +=
"<html>\n <head>\n";
508 report +=
"<title>Corpus Check Report</title>\n";
509 report +=
"<meta charset=\"utf-8\"></meta>\n";
524 "body{padding:15px;}"+
525 "#timestamp{margin-bottom:30px;}"+
526 ".critical{ background:#ffdddd; } "+
527 ".other{ background:#ffd39e; } "+
528 ".warning{ background:#fafcc2; } "+
529 ".char_Cyrillic{ color:#b51d0d; } "+
530 ".char_Greek{ background:#022299; } "+
531 ".char_Armenian{ background:#ad7600; } "+
532 ".char_Georgian{ background:#9c026d; } "+
534 report +=
" </head>\n <body>\n";
537 report +=
" <div id='timestamp'>Generated: ";
538 Timestamp timestamp =
new Timestamp(System.currentTimeMillis());
539 report += timestamp +
"</div>\n";
541 report +=
"<table>\n <thead><tr>" +
544 "<th>Filename:line.column</th>"+
547 "<th>Original</th>" +
549 report +=
" <tbody>\n";
551 switch (error.getSeverity()) {
553 report +=
"<tr class='critical'><td style='border-left: red solid 3px'>Critical</td><td>";
556 report +=
"<tr class='warning'><td style='border-left: yellow solid 3px'>Warning</td><td>";
559 report +=
"<tr class='note'><td style='border-left: green solid 3px'>Note</td><td>";
562 report +=
"<tr class='unknown'><td style='border-left: orange solid 3px'>Unknown</td><td>";
565 report +=
"<tr class='other'><td style='border-left: black solid 3px'>Other</td><td>";
568 report += error.getFunction() +
"</td><td>";
569 report += error.getLocation() +
"</td>";
570 report +=
"<td style='white-space: pre'>" +
573 report +=
"<td style='white-space: pre'>" +
576 report +=
"<td style='font-face: monospace; color: gray; border: gray solid 1px; white-space: pre;'>(" +
577 error.getLocalisedMessage() +
579 report +=
"<!-- " + error.getStackTrace() +
" -->\n";
582 report +=
" </tbody>\n </table>\n";
585 report +=
"<script>$(document).ready( function () {\n" +
586 " $('table').DataTable({ 'iDisplayLength': 50 });\n" +
589 report +=
" <footer style='white-space: pre'>" + summarylines +
"</footer>";
590 report +=
" </body>\n</html>";
static String generateDataTableHTML(Collection< ReportItem > errors, String summarylines)
ReportItem(Severity s, Throwable e, String filename, String what)
ReportItem(Severity s, String what)
static String generatePlainText(Collection< ReportItem > errors, boolean verbose)
static String InputStream2String(InputStream is)
static String generateSummary(Collection< ReportItem > errors)
ReportItem(Severity s, SAXParseException saxpe, String what)
static String generateHTML(Collection< ReportItem > errors)
ReportItem(Severity s, String filename, String what, String function)
ReportItem(Severity s, String filename, String what, String function, String howto)
ReportItem(Severity s, Throwable e, String what)
String getLocalisedMessage()