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 int getColoumnCount();
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\">");
17 LinkedList<Cell> tableContnet = getTableContent();
18 for (int i = 0; i < tableContnet.size() / getColoumnCount(); i++) {
20 for (int j = 0; j < getColoumnCount(); j++) {
21 Cell current = tableContnet.get((i * getColoumnCount()) + j);
22 out.println("<td " + current.getHtmlAttribs()
23 + " class=\"DataTD\">");
24 out.print(current.shouldTranslate() ? l.getTranslation(current
25 .getText()) : current.getText());
30 out.println("</table>");
34 * <b>Note:</b> All cells have the html attribute class="DataTD"!
39 public static class Cell {
40 private String text, htmlAttribs;
41 private boolean translate;
44 this(" ", false);
47 public Cell(String text, boolean translate, String htmlAttribs) {
49 this.translate = translate;
50 this.htmlAttribs = htmlAttribs;
53 public Cell(String text, boolean translate) {
54 this(text, translate, "");
57 public boolean shouldTranslate() {
61 public String getText() {
65 public String getHtmlAttribs() {