* */ - - public void testWriteSheetSimple() - throws IOException - { + public void testWriteSheetSimple() throws IOException { File file = TempFile.createTempFile("testWriteSheetSimple", ".xls"); FileOutputStream out = new FileOutputStream(file); @@ -84,13 +77,10 @@ public final class TestWorkbook extends TestCase { HSSFRow r = null; HSSFCell c = null; - for (short rownum = ( short ) 0; rownum < 100; rownum++) - { + for (int rownum = 0; rownum < 100; rownum++) { r = s.createRow(rownum); - // r.setRowNum(( short ) rownum); - for (short cellnum = ( short ) 0; cellnum < 50; cellnum += 2) - { + for (int cellnum = 0; cellnum < 50; cellnum += 2) { c = r.createCell(cellnum); c.setCellValue(rownum * 10000 + cellnum + ((( double ) rownum / 1000) @@ -104,8 +94,6 @@ public final class TestWorkbook extends TestCase { sanityChecker.checkHSSFWorkbook(wb); assertEquals("LAST ROW == 99", 99, s.getLastRowNum()); assertEquals("FIRST ROW == 0", 0, s.getFirstRowNum()); - - // assert((s.getLastRowNum() == 99)); } /** @@ -130,13 +118,10 @@ public final class TestWorkbook extends TestCase { HSSFRow r = null; HSSFCell c = null; - for (short rownum = ( short ) 0; rownum < 100; rownum++) - { + for (int rownum = 0; rownum < 100; rownum++) { r = s.createRow(rownum); - // r.setRowNum(( short ) rownum); - for (short cellnum = ( short ) 0; cellnum < 50; cellnum += 2) - { + for (int cellnum = 0; cellnum < 50; cellnum += 2) { c = r.createCell(cellnum); c.setCellValue(rownum * 10000 + cellnum + ((( double ) rownum / 1000) @@ -145,13 +130,11 @@ public final class TestWorkbook extends TestCase { c.setCellValue(new HSSFRichTextString("TEST")); } } - for (short rownum = ( short ) 0; rownum < 25; rownum++) - { + for (int rownum = 0; rownum < 25; rownum++) { r = s.getRow(rownum); s.removeRow(r); } - for (short rownum = ( short ) 75; rownum < 100; rownum++) - { + for (int rownum = 75; rownum < 100; rownum++) { r = s.getRow(rownum); s.removeRow(r); } @@ -428,12 +411,10 @@ public final class TestWorkbook extends TestCase { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet s = wb.createSheet(); - for (short rownum = ( short ) 0; rownum < 100; rownum++) - { + for (int rownum = 0; rownum < 100; rownum++) { HSSFRow r = s.createRow(rownum); - for (short cellnum = ( short ) 0; cellnum < 50; cellnum += 2) - { + for (int cellnum = 0; cellnum < 50; cellnum += 2) { HSSFCell c = r.createCell(cellnum); c.setCellValue(rownum * 10000 + cellnum + ((( double ) rownum / 1000) @@ -465,13 +446,10 @@ public final class TestWorkbook extends TestCase { /** * Test the backup field gets set as expected. */ - - public void testBackupRecord() - throws Exception - { - HSSFWorkbook wb = new HSSFWorkbook(); - wb.createSheet(); - Workbook workbook = wb.getWorkbook(); + public void testBackupRecord() { + HSSFWorkbook wb = new HSSFWorkbook(); + wb.createSheet(); + Workbook workbook = wb.getWorkbook(); BackupRecord record = workbook.getBackupRecord(); assertEquals(0, record.getBackup()); @@ -479,7 +457,7 @@ public final class TestWorkbook extends TestCase { assertEquals(1, record.getBackup()); } - private static final class RecordCounter implements ERFListener { + private static final class RecordCounter implements RecordVisitor { private int _count; public RecordCounter() { @@ -488,9 +466,10 @@ public final class TestWorkbook extends TestCase { public int getCount() { return _count; } - public boolean processRecord(Record rec) { - _count++; - return true; + public void visitRecord(Record r) { + if (r instanceof LabelSSTRecord) { + _count++; + } } } @@ -499,9 +478,7 @@ public final class TestWorkbook extends TestCase { * * We need to make sure only one LabelSSTRecord is produced. */ - public void testRepeatingBug() - throws Exception - { + public void testRepeatingBug() { HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("Design Variants"); HSSFRow row = sheet.createRow(2); @@ -510,12 +487,8 @@ public final class TestWorkbook extends TestCase { cell.setCellValue(new HSSFRichTextString("Class")); cell = row.createCell(2); - byte[] data = new byte[sheet.getSheet().getSize()]; - sheet.getSheet().serialize(0, data); RecordCounter rc = new RecordCounter(); - EventRecordFactory erf = new EventRecordFactory(rc, new short[] { LabelSSTRecord.sid, }); - erf.processRecords(new ByteArrayInputStream(data)); - + sheet.getSheet().visitContainedRecords(rc, 0); assertEquals(1, rc.getCount()); }