// Ok, start bouncing through our list (only the visible part)
RowIterator rowIterator = model.getRowIterator(false);
// iterator on rows
TableDecorator tableDecorator = model.getTableDecorator();
Row previousRow = null;
Row currentRow = null;
Row nextRow = null;
Map previousRowValues = new HashMap(10);
Map currentRowValues = new HashMap(10);
Map nextRowValues = new HashMap(10);
while (nextRow != null || rowIterator.hasNext())
{
// The first pass
if (currentRow == null)
{
currentRow = rowIterator.next();
}
else
{
previousRow = currentRow;
currentRow = nextRow;
}
if (previousRow != null)
{
previousRowValues.putAll(currentRowValues);
}
if (!nextRowValues.isEmpty())
{
currentRowValues.putAll(nextRowValues);
}
// handle the first pass
else
{
ColumnIterator columnIterator = currentRow.getColumnIterator(model.getHeaderCellList());
// iterator on columns
if (log.isDebugEnabled())
{
log.debug(" creating ColumnIterator on " + model.getHeaderCellList());
}
while (columnIterator.hasNext())
{
Column column = columnIterator.nextColumn();
// Get the value to be displayed for the column
column.initialize();
CellStruct struct = new CellStruct(column, column.getChoppedAndLinkedValue());
currentRowValues.put(new Integer(column.getHeaderCell().getColumnNumber()), struct);
}
}
nextRowValues.clear();
// Populate the next row values
nextRow = rowIterator.hasNext() ? rowIterator.next() : null;
if (nextRow != null)
{
ColumnIterator columnIterator = nextRow.getColumnIterator(model.getHeaderCellList());
// iterator on columns
if (log.isDebugEnabled())
{
log.debug(" creating ColumnIterator on " + model.getHeaderCellList());
}