Have iterating over rows and cells work with JDK 1.5 foreach loops through java.lang.Iterable
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@618676 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
11b26749b4
commit
321375583d
@ -476,6 +476,13 @@ public class HSSFRow
|
|||||||
{
|
{
|
||||||
return new CellIterator();
|
return new CellIterator();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Alias for {@link CellIterator} to allow
|
||||||
|
* foreach loops
|
||||||
|
*/
|
||||||
|
public Iterator iterator() {
|
||||||
|
return cellIterator();
|
||||||
|
}
|
||||||
|
|
||||||
private class CellIterator implements Iterator
|
private class CellIterator implements Iterator
|
||||||
{
|
{
|
||||||
|
@ -715,11 +715,17 @@ public class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet
|
|||||||
* @return an iterator of the PHYSICAL rows. Meaning the 3rd element may not
|
* @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.
|
* be the third row if say for instance the second row is undefined.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Iterator rowIterator()
|
public Iterator rowIterator()
|
||||||
{
|
{
|
||||||
return rows.values().iterator();
|
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
|
* used internally in the API to get the low level Sheet record represented by this
|
||||||
|
@ -17,9 +17,10 @@
|
|||||||
|
|
||||||
package org.apache.poi.ss.usermodel;
|
package org.apache.poi.ss.usermodel;
|
||||||
|
|
||||||
|
import java.lang.Iterable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
public interface Row {
|
public interface Row extends Iterable {
|
||||||
|
|
||||||
// used for collections
|
// used for collections
|
||||||
public final static int INITIAL_CAPACITY = 5;
|
public final static int INITIAL_CAPACITY = 5;
|
||||||
@ -145,11 +146,16 @@ public interface Row {
|
|||||||
float getHeightInPoints();
|
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!
|
* 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);
|
int compareTo(Object obj);
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import java.util.Iterator;
|
|||||||
import org.apache.poi.hssf.util.PaneInformation;
|
import org.apache.poi.hssf.util.PaneInformation;
|
||||||
import org.apache.poi.hssf.util.Region;
|
import org.apache.poi.hssf.util.Region;
|
||||||
|
|
||||||
public interface Sheet {
|
public interface Sheet extends Iterable {
|
||||||
|
|
||||||
/* Constants for margins */
|
/* Constants for margins */
|
||||||
public static final short LeftMargin = Sheet.LeftMargin;
|
public static final short LeftMargin = Sheet.LeftMargin;
|
||||||
@ -250,9 +250,14 @@ public interface Sheet {
|
|||||||
* @return an iterator of the PHYSICAL rows. Meaning the 3rd element may not
|
* @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.
|
* be the third row if say for instance the second row is undefined.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Iterator rowIterator();
|
Iterator rowIterator();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for {@link #rowIterator()} to allow
|
||||||
|
* foreach loops
|
||||||
|
*/
|
||||||
|
Iterator iterator();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* whether alternate expression evaluation is on
|
* whether alternate expression evaluation is on
|
||||||
* @param b alternative expression evaluation or not
|
* @param b alternative expression evaluation or not
|
||||||
|
@ -53,6 +53,13 @@ public class XSSFRow implements Row {
|
|||||||
public Iterator<Cell> cellIterator() {
|
public Iterator<Cell> cellIterator() {
|
||||||
return cells.iterator();
|
return cells.iterator();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Alias for {@link #cellIterator()} to allow
|
||||||
|
* foreach loops
|
||||||
|
*/
|
||||||
|
public Iterator<Cell> iterator() {
|
||||||
|
return cellIterator();
|
||||||
|
}
|
||||||
|
|
||||||
public int compareTo(Object obj) {
|
public int compareTo(Object obj) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
@ -502,6 +502,13 @@ public class XSSFSheet implements Sheet {
|
|||||||
public Iterator<Row> rowIterator() {
|
public Iterator<Row> rowIterator() {
|
||||||
return rows.iterator();
|
return rows.iterator();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Alias for {@link #rowIterator()} to
|
||||||
|
* allow foreach loops
|
||||||
|
*/
|
||||||
|
public Iterator<Row> iterator() {
|
||||||
|
return rowIterator();
|
||||||
|
}
|
||||||
|
|
||||||
public void setAlternativeExpression(boolean b) {
|
public void setAlternativeExpression(boolean b) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
Loading…
Reference in New Issue
Block a user