Pārlūkot izejas kodu

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
tags/REL_3_5_BETA2
Nick Burch pirms 16 gadiem
vecāks
revīzija
ccc4069b86

+ 7
- 0
src/java/org/apache/poi/hssf/usermodel/HSSFRow.java Parādīt failu

@@ -476,6 +476,13 @@ public class HSSFRow
{
return new CellIterator();
}
/**
* Alias for {@link CellIterator} to allow
* foreach loops
*/
public Iterator iterator() {
return cellIterator();
}
private class CellIterator implements Iterator
{

+ 7
- 1
src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java Parādīt failu

@@ -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
* 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

+ 10
- 4
src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Row.java Parādīt failu

@@ -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 @@ public interface Row {
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);

}
}

+ 7
- 2
src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java Parādīt failu

@@ -22,7 +22,7 @@ import java.util.Iterator;
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 @@ public interface Sheet {
* @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

+ 7
- 0
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java Parādīt failu

@@ -53,6 +53,13 @@ public class XSSFRow implements Row {
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

+ 7
- 0
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Parādīt failu

@@ -502,6 +502,13 @@ public class XSSFSheet implements Sheet {
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

Notiek ielāde…
Atcelt
Saglabāt