You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2008/02/05 16:41:43 UTC

svn commit: r618676 - in /poi/branches/ooxml/src: java/org/apache/poi/hssf/usermodel/ ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/ ooxml/java/org/apache/poi/xssf/usermodel/

Author: nick
Date: Tue Feb  5 07:41:37 2008
New Revision: 618676

URL: http://svn.apache.org/viewvc?rev=618676&view=rev
Log:
Have iterating over rows and cells work with JDK 1.5 foreach loops through java.lang.Iterable

Modified:
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
    poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Row.java
    poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java?rev=618676&r1=618675&r2=618676&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java Tue Feb  5 07:41:37 2008
@@ -476,6 +476,13 @@
     {
       return new CellIterator();
     }
+    /**
+     * Alias for {@link CellIterator} to allow
+     *  foreach loops
+     */
+    public Iterator iterator() { 
+    	return cellIterator();
+    }
     
     private class CellIterator implements Iterator
     {

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java?rev=618676&r1=618675&r2=618676&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java Tue Feb  5 07:41:37 2008
@@ -715,10 +715,16 @@
      * @return an iterator of the PHYSICAL rows.  Meaning the 3rd element may not
      * be the third row if say for instance the second row is undefined.
      */
-
     public Iterator rowIterator()
     {
         return rows.values().iterator();
+    }
+    /**
+     * Alias for {@link #rowIterator()} to allow 
+     *  foreach loops
+     */
+    public Iterator iterator() {
+    	return rowIterator();
     }
 
     /**

Modified: poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Row.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Row.java?rev=618676&r1=618675&r2=618676&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Row.java (original)
+++ poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Row.java Tue Feb  5 07:41:37 2008
@@ -17,9 +17,10 @@
 
 package org.apache.poi.ss.usermodel;
 
+import java.lang.Iterable;
 import java.util.Iterator;
 
-public interface Row {
+public interface Row extends Iterable {
 
     // used for collections
     public final static int INITIAL_CAPACITY = 5;
@@ -145,14 +146,19 @@
     float getHeightInPoints();
 
     /**
-     * @return cell iterator of the physically defined cells.  Note element 4 may
+     * @return Cell iterator of the physically defined cells.  Note element 4 may
      * actually be row cell depending on how many are defined!
      */
+    Iterator<Cell> cellIterator();
 
-    Iterator cellIterator();
+	/**
+	 * Alias for {@link #cellIterator()} to allow
+	 * foreach loops
+	 */
+	Iterator<Cell> iterator();
 
     int compareTo(Object obj);
 
     boolean equals(Object obj);
 
-}
\ No newline at end of file
+}

Modified: poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java?rev=618676&r1=618675&r2=618676&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java (original)
+++ poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java Tue Feb  5 07:41:37 2008
@@ -22,7 +22,7 @@
 import org.apache.poi.hssf.util.PaneInformation;
 import org.apache.poi.hssf.util.Region;
 
-public interface Sheet {
+public interface Sheet extends Iterable {
 
     /* Constants for margins */
     public static final short LeftMargin = Sheet.LeftMargin;
@@ -250,8 +250,13 @@
      * @return an iterator of the PHYSICAL rows.  Meaning the 3rd element may not
      * be the third row if say for instance the second row is undefined.
      */
-
     Iterator rowIterator();
+    
+    /**
+     * Alias for {@link #rowIterator()} to allow 
+     *  foreach loops
+     */
+    Iterator iterator();
 
     /**
      * whether alternate expression evaluation is on

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java?rev=618676&r1=618675&r2=618676&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java Tue Feb  5 07:41:37 2008
@@ -53,6 +53,13 @@
     public Iterator<Cell> cellIterator() {
         return cells.iterator();
     }
+    /**
+     * Alias for {@link #cellIterator()} to allow
+     *  foreach loops
+     */
+    public Iterator<Cell> iterator() {
+    	return cellIterator();
+    }
 
     public int compareTo(Object obj) {
         // TODO Auto-generated method stub

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=618676&r1=618675&r2=618676&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Tue Feb  5 07:41:37 2008
@@ -502,6 +502,13 @@
     public Iterator<Row> rowIterator() {
         return rows.iterator();
     }
+    /**
+     * Alias for {@link #rowIterator()} to
+     *  allow foreach loops
+     */
+    public Iterator<Row> iterator() {
+    	return rowIterator();
+    }
 
     public void setAlternativeExpression(boolean b) {
         // TODO Auto-generated method stub



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org