1 package org.cacert.gigi.output;
3 import java.io.PrintWriter;
4 import java.util.LinkedList;
7 import org.cacert.gigi.Language;
9 public abstract class DataTable implements Outputable {
10 protected abstract Cell[] getColumns();
12 protected abstract LinkedList<Cell> getTableContent();
15 public void output(PrintWriter out, Language l, Map<String, Object> vars) {
16 out.println("<table align=\"center\" valign=\"middle\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"wrapper\">");
18 for (Cell column : getColumns()) {
19 out.print("<td " + column.getHtmlAttribs() + " class=\"DataTD\">");
20 out.print(column.shouldTranslate() ? l.getTranslation(column
21 .getText()) : column.getText());
25 LinkedList<Cell> tableContnet = getTableContent();
26 for (int i = 0; i < tableContnet.size() / getColumns().length; i++) {
28 for (int j = 0; j < getColumns().length; j++) {
29 Cell current = tableContnet.get((i * getColumns().length) + j);
30 out.println("<td " + current.getHtmlAttribs()
31 + " class=\"DataTD\">");
32 out.print(current.shouldTranslate() ? l.getTranslation(current
33 .getText()) : current.getText());
38 out.println("</table>");
42 * <b>Note:</b> All cells have the html attribute class="DataTD"!
47 public static class Cell {
48 private String text, htmlAttribs;
49 private boolean translate;
52 this(" ", false);
55 public Cell(String text, boolean translate, String htmlAttribs) {
57 this.translate = translate;
58 this.htmlAttribs = htmlAttribs;
61 public Cell(String text, boolean translate) {
62 this(text, translate, "");
65 public boolean shouldTranslate() {
69 public String getText() {
73 public String getHtmlAttribs() {