if (metricAttachments != null) {
Set<Map.Entry<String, CustomMetrics>> entries =
metricAttachments.entrySet();
for (Map.Entry<String, CustomMetrics> entry : entries) {
CustomMetrics attachment = entry.getValue();
CustomMetrics.Element[] elements;
try {
elements = attachment.getResults();
} catch (Exception e) { // Ensure the getResults
// doesn't break report generation.
logger.log(Level.WARNING,
"Exceptions reporting CustomMetrics", e);
elements = null;
}
if (elements != null && elements.length > 0) {
space(8, buffer).append("<customStats name=\"").
append(entry.getKey()).append("\">\n");
for (CustomMetrics.Element element : elements) {
if (element == null) {
logger.warning("Null element returned from " +
attachment.getClass().getName() +
".getResults, ignored!");
continue;
}
space(12, buffer).append("<stat>\n");
if (element.description != null) {
space(16, buffer).append("<description>");
Utilities.escapeXML(element.description, buffer);
buffer.append("</description>\n");
} else {
space(16, buffer).append("<description/>\n");
}
if (element.result != null) {
space(16, buffer).append("<result>");
Utilities.escapeXML(element.result, buffer);
buffer.append("</result>\n");
} else {
space(16, buffer).append("<result/>\n");
}
if (element.target != null) {
space(16, buffer).append("<target>");
Utilities.escapeXML(element.target, buffer);
buffer.append("</target>\n");
}
if (element.allowedDeviation != null) {
space(16, buffer).append("<allowedDeviation>");
Utilities.escapeXML(element.allowedDeviation,
buffer);
buffer.append("</allowedDeviation>\n");
}
if (element.passed != null) {
space(16, buffer).append("<passed>").append(
element.passed.booleanValue()).
append("</passed>\n");
if (!element.passed) {
success = false;
}
}
space(12, buffer).append("</stat>\n");
}
space(8, buffer).append("</customStats>\n");
}
}
}
if (tableAttachments != null) {
Set<Map.Entry<String, CustomTableMetrics>> entries =
tableAttachments.entrySet();
for (Map.Entry<String, CustomTableMetrics> entry : entries) {
CustomTableMetrics attachment = entry.getValue();
TableModel table = null;
try {
table = attachment.getResults();
} catch (Exception e) { // Ensure the getResults
// doesn't break report generation.
logger.log(Level.WARNING,
"Exceptions reporting CustomTableMetrics", e);
}