From 23a86e709a63a58986c9f8e8392080792af41b31 Mon Sep 17 00:00:00 2001 From: Avik Sengupta Date: Tue, 21 May 2002 18:28:35 +0000 Subject: [PATCH] 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 --- .../aggregates/RowRecordsAggregate.java | 10 +++++-- .../aggregates/TestRowRecordsAggregate.java | 30 +++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 src/testcases/org/apache/poi/hssf/record/aggregates/TestRowRecordsAggregate.java diff --git a/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java b/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java index d8b261ef2d..1176943c7c 100644 --- a/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java +++ b/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java @@ -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(); } + } + diff --git a/src/testcases/org/apache/poi/hssf/record/aggregates/TestRowRecordsAggregate.java b/src/testcases/org/apache/poi/hssf/record/aggregates/TestRowRecordsAggregate.java new file mode 100644 index 0000000000..671cbdcbf0 --- /dev/null +++ b/src/testcases/org/apache/poi/hssf/record/aggregates/TestRowRecordsAggregate.java @@ -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); + } +} \ No newline at end of file