package com.github.cstroe.spendhawk.report.impl;

import com.github.cstroe.spendhawk.report.ReportResult;
import com.github.cstroe.spendhawk.report.ReportResultRenderer;

public class TableRenderer implements ReportResultRenderer {

    private final ReportResult result;

    public TableRenderer(ReportResult result) {
        this.result = result;
    }

    @Override
    public String render() {
        StringBuilder builder = new StringBuilder();
        builder.append("<table border=\"1\">\n");
        for(int i = 0; i < result.getNumRows(); i++) {
            builder.append("\t<tr>\n");
            for(int j = 0; j < result.getNumColumns(); j++) {
                builder.append("\t\t<td>\n");
                builder.append("\t\t\t").append(result.getCell(i,j));
                builder.append("\t\t</td>\n");
            }
            builder.append("\t</tr>\n");
        }
        builder.append("</table>");

        return builder.toString();
    }
}

@@ -164,16 +164,62 @@
 derer;%0A%0A
+/**%0A * Renders a result as an HTML table.%0A */%0A
 public c

Comment on TableRenderer