From: Nick Burch Date: Tue, 5 Feb 2008 15:51:29 +0000 (+0000) Subject: Add java.lang.Iterable style methods for iterating over rows and cells, but don't... X-Git-Tag: REL_3_0_3_BETA1~153 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=407a62f2bc90b7e635b689ee116845ab22f0dc9e;p=poi.git Add java.lang.Iterable style methods for iterating over rows and cells, but don't actually implement that, as it wasn't in jdk 1.3 or jdk 1.4, with is rather tedious git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@618680 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java b/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java index ae5727bc68..c759bcb46b 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java @@ -466,11 +466,17 @@ public class HSSFRow * @return cell iterator of the physically defined cells. Note element 4 may * actually be row cell depending on how many are defined! */ - public Iterator cellIterator() { return new CellIterator(); } + /** + * Alias for {@link CellIterator} to allow + * foreach loops + */ + public Iterator iterator() { + return cellIterator(); + } private class CellIterator implements Iterator { diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java index 0250a4cbaa..ee8aeac590 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java @@ -701,11 +701,18 @@ public class HSSFSheet * @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(); + } + /** * used internally in the API to get the low level Sheet record represented by this