]> source.dussan.org Git - poi.git/commitdiff
bug 40285: Corrected index of CellIterator. In addition made CelIterator obey the...
authorJason Height <jheight@apache.org>
Fri, 25 Aug 2006 22:24:47 +0000 (22:24 +0000)
committerJason Height <jheight@apache.org>
Fri, 25 Aug 2006 22:24:47 +0000 (22:24 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@436986 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/usermodel/HSSFRow.java

index 8a484e45496ad68ba19b78df551ba03a931806a4..ae994a2845c78d4be91b1a8e3c86764535601f15 100644 (file)
@@ -28,6 +28,7 @@ import org.apache.poi.hssf.record.RowRecord;
 
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.NoSuchElementException;
 
 /**
  * High level representation of a row of a spreadsheet.
@@ -436,7 +437,8 @@ public class HSSFRow
     
     private class CellIterator implements Iterator
     {
-      int thisId,nextId=0;
+      int thisId=-1;
+      int nextId=-1;
       
       public CellIterator()
       {
@@ -448,6 +450,8 @@ public class HSSFRow
       }
 
       public Object next() {
+         if (!hasNext())
+                 throw new NoSuchElementException("At last element");
         HSSFCell cell=cells[nextId];
         thisId=nextId;
         findNext();
@@ -455,6 +459,8 @@ public class HSSFRow
       }
 
       public void remove() {
+         if (thisId == -1)
+                 throw new IllegalStateException("remove() called before next()");
         cells[thisId]=null;
       }