System.arraycopy(counters, 0, countersCopy, 0, counters.length);
}
double totalDouble = (double) totalCopy;
double uptimeMillis = (double) (System.currentTimeMillis() - startTime);
response.setContentType("text/html; charset=utf-8");
ContentHandler ch = new HtmlSerializer(response.getOutputStream());
try {
ch.startDocument();
startElement(ch, "html");
startElement(ch, "head");
startElement(ch, "title");
characters(ch, VALIDATOR_STATISTICS);
endElement(ch, "title");
endElement(ch, "head");
startElement(ch, "body");
startElement(ch, "h1");
characters(ch, VALIDATOR_STATISTICS);
endElement(ch, "h1");
startElement(ch, "dl");
startElement(ch, "dt");
characters(ch, TOTAL_VALIDATIONS);
endElement(ch, "dt");
startElement(ch, "dd");
characters(ch, totalCopy);
endElement(ch, "dd");
startElement(ch, "dt");
characters(ch, UPTIME_DAYS);
endElement(ch, "dt");
startElement(ch, "dd");
characters(ch, uptimeMillis / (1000 * 60 * 60 * 24));
endElement(ch, "dd");
startElement(ch, "dt");
characters(ch, VALIDATIONS_PER_SECOND);
endElement(ch, "dt");
startElement(ch, "dd");
characters(ch, totalDouble / (uptimeMillis / 1000.0));
endElement(ch, "dd");
endElement(ch, "dl");
startElement(ch, "table");
startElement(ch, "thead");
startElement(ch, "tr");
startElement(ch, "th");
characters(ch, COUNTER_NAME);
endElement(ch, "th");
startElement(ch, "th");
characters(ch, COUNTER_VALUE);
endElement(ch, "th");
startElement(ch, "th");
characters(ch, COUNTER_PROPORTION);
endElement(ch, "th");
endElement(ch, "tr");
endElement(ch, "thead");
startElement(ch, "tbody");
for (int i = 0; i < countersCopy.length; i++) {
long count = countersCopy[i];
startElement(ch, "tr");
startElement(ch, "td");
characters(ch, Field.values()[i].toString());
endElement(ch, "td");
startElement(ch, "td");
characters(ch, count);
endElement(ch, "td");
startElement(ch, "td");
characters(ch, ((double) count) / totalDouble);
endElement(ch, "td");
endElement(ch, "tr");
}
endElement(ch, "tbody");
endElement(ch, "table");
endElement(ch, "body");
endElement(ch, "html");
} finally {
ch.endDocument();
}
} catch (SAXException e) {
throw new IOException(e);
}
}