01: package com.xoetrope.export.html;
02:
03: import com.xoetrope.export.ArrayArrayBlock;
04: import com.xoetrope.export.RowBlock;
05: import com.xoetrope.export.TableBlock;
06: import com.xoetrope.export.TagExporter;
07: import java.util.ArrayList;
08: import net.xoetrope.xui.helper.XTranslator;
09:
10: /**
11: *
12: * <p> Copyright (c) Xoetrope Ltd., 2002-2006, This software is licensed under
13: * the GNU Public License (GPL), please see license.txt for more details</p>
14: * <p>$Revision: 1.5 $</p>
15: */
16: public class HTMLArrayArrayBlock extends ArrayArrayBlock implements
17: TagExporter {
18: protected HTMLExporter htmlExporter;
19: protected XTranslator translator;
20:
21: public HTMLArrayArrayBlock(HTMLExporter exporter) {
22: htmlExporter = exporter;
23: translator = exporter.getCurrentProject().getTranslator();
24: }
25:
26: protected String exportModel(ArrayList table, boolean includeHeader) {
27: int startRow = 0;
28: int numRows = table.size();
29:
30: ArrayList row0 = (ArrayList) table.get(0);
31: int numCols = row0.size();
32:
33: TableBlock tableExport = htmlExporter.getTableBlock();
34:
35: String widthStr = getWidth();
36: content.append("<TABLE");
37: if ((widthStr != null) && (widthStr.length() > 0))
38: content.append(" width=\"" + widthStr + "\"");
39: content.append(">\n");
40:
41: // if ( includeHeader ) {
42: // content.append( "<TR>\n" );
43: // for ( int col = 0; col < tableModel.getColumnCount(); col++ ) {
44: // content.append( "<TD class='" + getHeaderStyle() + "'>\n" );
45: // TableCellRenderer renderer = table.getColumnModel().getColumn( col ).getHeaderRenderer();
46: // String value = table.getTableHeader().getColumnModel().getColumn( col ).getHeaderValue().toString();
47: //
48: // content.append( value );
49: // content.append( "</TD>\n" );
50: // }
51: // }
52:
53: for (int i = startRow; i < numRows; i++) {
54: content.append("<TR>\n");
55: RowBlock rowBlock = tableExport.addRow();
56: ArrayList row = (ArrayList) table.get(i);
57: for (int j = 0; j < numCols; j++) {
58: content
59: .append("<TD class='" + getTableStyle()
60: + "'>\n");
61: String value = (String) row.get(j);
62: if (translator != null)
63: value = translator.translate(value);
64: if ((value != null) && (value.compareTo("null") != 0))
65: content.append(value);
66: content.append("</TD>\n");
67: }
68: content.append("</TR>\n");
69: }
70:
71: content.append("</TABLE>\n");
72:
73: return content.toString();
74: }
75:
76: public String getStartTag() {
77: return content.toString();
78: }
79:
80: public String getEndTag() {
81: return "";
82: }
83: }
|