int numCols = 0;
DataTable table = DataTable.create();
if (hrows.getLength() == 1) {
TableRowElement tr = hrows.getItem(0);
NodeList<TableCellElement> hcols = tr.getCells();
assertTrue(hcols.getLength() > 1,
"THEAD TR contains less than 2 columns");
for (int i = 0; i < hcols.getLength(); i++) {
TableCellElement th = hcols.getItem(i);
assertTrue("th".equalsIgnoreCase(th.getNodeName()),
"Only TH elements should occur in THEAD TR");
String title = th.getInnerText().trim();
numCols++;
if (i == 0) {
table.addColumn("date", title);
} else {
if ("markers".equalsIgnoreCase(title)) {
table.addColumn("string", title);
} else {
table.addColumn("number", title);
}
}
}
} else {
throw new JavaScriptException("Table Element must ");
}
String dateFormat = "MM-dd-yy";
NumberFormat numberFormats[] = new NumberFormat[numCols];
NodeList<Element> colGroup = te.getElementsByTagName("colgroup");
assertTrue(colGroup != null && colGroup.getLength() == 1,
"Table must have exactly one COLGROUP element");
NodeList<Element> cols = colGroup.getItem(0).getElementsByTagName("col");
assertTrue(cols != null && cols.getLength() == numCols,
"COLGROUP must have one COL element for each TH in THEAD");
for (int i = 0; i < cols.getLength(); i++) {
Element col = cols.getItem(i);
String fmt = col.getAttribute("title");
String className = col.getClassName();
if (i == 0) {
assertTrue(fmt != null && !"".equals(fmt),
"COL for column 0 must have TITLE attribute containing date");
assertTrue("cmf-dateformat".equals(className),
"COL for column 0 must have CLASS of cmf-dateformat");
}
if (i == 0) {
dateFormat = fmt;
} else {
if (fmt != null && !"".equals(fmt)) {
assertTrue("cmf-numberformat".equals(className),
"Number format COL elements must have class of cmf-numberformat with title containing format according to GWT NumberFormat syntax at http://google-web-toolkit.googlecode.com/svn/javadoc/1.4/com/google/gwt/i18n/client/NumberFormat.html");
numberFormats[i] = NumberFormat.getFormat(fmt);
} else if ("cmf-numberformat".equals(className)) {
assertTrue(fmt != null && !"".equals(fmt),
"COL has class cmf-numberformat but missing title attribute with format string with syntax http://google-web-toolkit.googlecode.com/svn/javadoc/1.4/com/google/gwt/i18n/client/NumberFormat.html");
numberFormats[i] = NumberFormat.getFormat(fmt);
}
}
}
NodeList<TableSectionElement> tbodies = te.getTBodies();
assertNotNull(tbodies, "Table must contain TBODY elements");
assertTrue(tbodies.getLength() > 0, "Table must contain TBODY elements");
int totalAdded = 0;
for (int i = 0; i < tbodies.getLength(); i++) {
TableSectionElement tbody = tbodies.getItem(i);
NodeList<TableRowElement> drows = tbody.getRows();
table.addRows(drows.getLength());
for (int j = 0; j < drows.getLength(); j++) {
TableRowElement row = drows.getItem(j);
NodeList<TableCellElement> cells = row.getCells();
assertTrue(cells.getLength() == numCols,
"Number of TH header columns in THEAD must match number of TD columns in TBODY");
for (int k = 0; k < cells.getLength(); k++) {
TableCellElement cell = cells.getItem(k);