1 /*
2 Bloof - visualize the evolution of your software project
3 Copyright ( C ) 2003 Lukasz Pekacki <lukasz@pekacki.de>
4 http://bloof.sf.net/
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along with
15 this program; if not, write to the Free Software Foundation, Inc.,
16 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18 $RCSfile: ResultTable.java,v $
19 Created on $Date: 2003/06/30 07:39:41 $
20 */
21 package net.sf.bloof.metrics;
22
23 import java.util.Iterator;
24 import java.util.Vector;
25
26 import javax.swing.table.DefaultTableModel;
27 import javax.swing.table.TableModel;
28
29 import net.n3.nanoxml.XMLElement;
30
31 /***
32 *
33 * @author Lukasz Pekacki <pekacki@users.sourceforge.net>
34 * @version $Id: ResultTable.java,v 1.1 2003/06/30 07:39:41 pekacki Exp $
35 */
36 public class ResultTable {
37
38 /***
39 * Default constructor
40 * @param aColumnNames columns of the table
41 */
42 public ResultTable(Object[] aColumnNames) {
43 mTableModel = new DefaultTableModel(aColumnNames,0);
44 }
45
46 /***
47 * Adds a row to the tabe
48 * @param aRowData data of the row
49 */
50 public void addRow(Vector aRowData) {
51 mTableModel.addRow(aRowData);
52 }
53
54 /***
55 * Returns the XML Element for this table
56 * @return XML Element for this table
57 */
58 public XMLElement getXML() {
59 XMLElement table = new XMLElement("table");
60 XMLElement tr = new XMLElement("tr");
61 for (int i = 0; i < mTableModel.getColumnCount(); i++) {
62 XMLElement th = new XMLElement("th");
63 th.setContent(mTableModel.getColumnName(i));
64 tr.addChild(th);
65 }
66 table.addChild(tr);
67 for (Iterator rowIter = mTableModel.getDataVector().iterator(); rowIter.hasNext();) {
68 Vector rowData = (Vector) rowIter.next();
69 tr = new XMLElement("tr");
70 for (Iterator iter = rowData.iterator(); iter.hasNext();) {
71 Object element = (Object) iter.next();
72 XMLElement td = new XMLElement("td");
73 if (element != null) {
74 td.setContent(element.toString());
75 }
76
77 tr.addChild(td);
78 }
79 table.addChild(tr);
80 }
81 return table;
82 }
83
84 /***
85 * Returns the table model
86 * @return the table model
87 */
88 public TableModel getTabelModel() {
89 return mTableModel;
90 }
91
92 private DefaultTableModel mTableModel;
93 }
This page was automatically generated by Maven