fix for bug 9114, reported and fix pointed by Tal Moshaiov

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352646 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Avik Sengupta 2002-05-21 18:28:35 +00:00
parent f75fb848ba
commit 5fef5940be
2 changed files with 37 additions and 3 deletions

View File

@ -59,7 +59,8 @@ import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.RowRecord;
import org.apache.poi.hssf.record.UnknownRecord;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
import java.util.Iterator;
import java.util.List;
@ -73,14 +74,15 @@ public class RowRecordsAggregate
{
int firstrow = -1;
int lastrow = -1;
HashMap records = null;
Map records = null;
int size = 0;
/** Creates a new instance of ValueRecordsAggregate */
public RowRecordsAggregate()
{
records = new HashMap();
records = new TreeMap();
}
public void insertRow(RowRecord row)
@ -216,4 +218,6 @@ public class RowRecordsAggregate
{
return records.values().iterator();
}
}

View File

@ -0,0 +1,30 @@
package org.apache.poi.hssf.record.aggregates;
import org.apache.poi.hssf.record.*;
public class TestRowRecordsAggregate extends junit.framework.TestCase {
public TestRowRecordsAggregate(String name) {
super (name);
}
public void testRowGet() {
RowRecordsAggregate rra = new RowRecordsAggregate();
RowRecord rr = new RowRecord();
rr.setRowNumber(( short ) 4);
rra.insertRow(rr);
RowRecord rr2 = new RowRecord(); rr2.setRowNumber((short) 1);
rra.insertRow(rr2);
RowRecord rr1 = rra.getRow(4);
assertTrue("Row Record should not be null", rr1!=null);
assertTrue("Row number is 1",rr1.getRowNumber() == 4);
assertTrue("Row record retrieved is identical ", rr1 == rr);
}
public static void main(String [] args) {
System.out
.println("Testing org.apache.poi.hssf.record.aggregates.RowRecordAggregate");
junit.textui.TestRunner.run(TestRowRecordsAggregate.class);
}
}