final String[] tables = tableDataFactory.getQueryNames();
for (int i = 0; i < tables.length; i++)
{
final String tableName = tables[i];
final TableModel tableModel = tableDataFactory.queryData(tableName, null);
xmlWriter.writeTag(InlineDataFactoryModule.NAMESPACE, "inline-table", "name", tableName, XmlWriterSupport.OPEN);
xmlWriter.writeTag(InlineDataFactoryModule.NAMESPACE, "definition", XmlWriterSupport.OPEN);
final Class[] colTypes = new Class[tableModel.getColumnCount()];
for (int col = 0; col < tableModel.getColumnCount(); col += 1)
{
final AttributeList colAttrs = new AttributeList();
colAttrs.setAttribute(InlineDataFactoryModule.NAMESPACE, "name", tableModel.getColumnName(col));
final Class columnClass = tableModel.getColumnClass(col);
if (columnClass == null)
{
colAttrs.setAttribute(InlineDataFactoryModule.NAMESPACE, "type", Object.class.getName());
colTypes[col] = Object.class;
}
else
{
colAttrs.setAttribute(InlineDataFactoryModule.NAMESPACE, "type", columnClass.getName());
colTypes[col] = columnClass;
}
xmlWriter.writeTag(InlineDataFactoryModule.NAMESPACE, "column", colAttrs, XmlWriterSupport.CLOSE);
}
xmlWriter.writeCloseTag(); // definition
for (int row = 0; row < tableModel.getRowCount(); row += 1)
{
xmlWriter.writeTag(InlineDataFactoryModule.NAMESPACE, "row", XmlWriterSupport.OPEN);
for (int col = 0; col < tableModel.getColumnCount(); col += 1)
{
final AttributeList colAttrs = new AttributeList();
final Object value = tableModel.getValueAt(row, col);
if (value == null)
{
colAttrs.setAttribute(InlineDataFactoryModule.NAMESPACE, "null", "true");
xmlWriter.writeTag(InlineDataFactoryModule.NAMESPACE, "data", colAttrs, XmlWriterSupport.CLOSE);
}