SVN: toys/cvsstats/web/src/pl/org/pld/cvsstats/ResultsTable.java
pawelz
pawelz at pld-linux.org
Mon Apr 5 13:23:21 CEST 2010
Author: pawelz
Date: Mon Apr 5 13:23:20 2010
New Revision: 11306
Modified:
toys/cvsstats/web/src/pl/org/pld/cvsstats/ResultsTable.java
Log:
- added ResultTable.getHtml() method
Modified: toys/cvsstats/web/src/pl/org/pld/cvsstats/ResultsTable.java
==============================================================================
--- toys/cvsstats/web/src/pl/org/pld/cvsstats/ResultsTable.java (original)
+++ toys/cvsstats/web/src/pl/org/pld/cvsstats/ResultsTable.java Mon Apr 5 13:23:20 2010
@@ -6,15 +6,18 @@
import java.util.ArrayList;
public class ResultsTable {
+ String[] header;
ArrayList<String[]> rows;
int columnCount;
public ResultsTable(ResultSet rs, ResultSetMetaData md) throws SQLException {
columnCount = md.getColumnCount();
+ header = new String[columnCount];
rows = new ArrayList<String[]>();
+ int i;
+ for (i = 0; i < columnCount; i++) header[i] = md.getColumnLabel(i+1);
while (rs.next()) {
String[] row = new String[columnCount];
- int i;
for (i = 0; i < columnCount; i++) row[i] = rs.getString(i+1);
rows.add(row);
}
@@ -35,4 +38,32 @@
public String getCell(int r, int c) {
return rows.get(r)[c];
}
+
+ /**
+ * runs getHtml(String css) with css="resulttable"
+ * @return
+ */
+ public String getHtml() {
+ return getHtml("resultstable");
+ }
+
+ public String getHtml(String css) {
+ String rv = "<table class="+css+">";
+ rv += "<tr class="+css+">";
+ for (int c = 0; c < getColumnCount(); c++) {
+ rv += "<th class="+css+">" + header[c] + "</th>";
+ }
+ rv += "</tr>";
+ for (int r = 0; r < getRowCount(); r++) {
+ rv+="<tr class="+css+">";
+ for (int c = 0; c < getColumnCount(); c++) {
+ rv+="<td class="+css+">";
+ rv+=getCell(r, c);
+ rv+="</td>";
+ }
+ rv+="</tr>";
+ }
+ rv += "</table>";
+ return rv;
+ }
}
\ No newline at end of file
More information about the pld-cvs-commit
mailing list