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);
}
int rows = table.rows();
if (table != null && rows > 0) {
space(8, buffer).append("<customTable name=\"").
append(entry.getKey()).append("\">\n");
space(12, buffer).append("<head>\n");
for (int i = 0; i < table.columns(); i++) {
space(16, buffer).append("<th>").append(table.getHeader(i)).
append("</th>\n");
}
space(12, buffer).append("</head>\n");
for(int i = 0; i < rows; i++) {
Comparable[] row = table.getRow(i);
space(12, buffer).append("<tr>\n");
for (int j = 0; j < row.length; j++) {
space(16, buffer).append("<td>").append(row[j]).
append("</td>\n");
}