int sstPos = 0;
boolean wroteBoundSheets = false;
for ( int k = 0; k < records.size(); k++ )
{
Record record = records.get( k );
int len = 0;
if (record instanceof SSTRecord)
{
sst = (SSTRecord)record;
sstPos = pos;
}
if (record.getSid() == ExtSSTRecord.sid && sst != null)
{
record = sst.createExtSSTRecord(sstPos + offset);
}
if (record instanceof BoundSheetRecord) {
if(!wroteBoundSheets) {
for (int i = 0; i < boundsheets.size(); i++) {
len+= getBoundSheetRec(i)
.serialize(pos+offset+len, data);
}
wroteBoundSheets = true;
}
} else {
len = record.serialize( pos + offset, data );
}
///// DEBUG BEGIN /////
// if (len != record.getRecordSize())
// throw new IllegalStateException("Record size does not match serialized bytes. Serialized size = " + len + " but getRecordSize() returns " + record.getRecordSize());
///// DEBUG END /////