inline numberOfRows, numberOfColumns and the name for performance.
This commit is contained in:
Marten Deinum
2015-02-03 22:01:56 +01:00
committed by Michael Minella
parent 01ae4985e4
commit 58bbaa494d
2 changed files with 15 additions and 5 deletions

View File

@@ -31,6 +31,9 @@ import org.springframework.batch.item.excel.Sheet;
public class JxlSheet implements Sheet {
private final jxl.Sheet delegate;
private final int numberOfRows;
private final int numberOfColumns;
private final String name;
/**
* Constructor which takes the delegate sheet.
@@ -40,6 +43,9 @@ public class JxlSheet implements Sheet {
JxlSheet(final jxl.Sheet delegate) {
super();
this.delegate = delegate;
this.numberOfRows = this.delegate.getRows();
this.numberOfColumns = this.delegate.getNumberOfImages();
this.name=this.delegate.getName();
}
/**
@@ -47,7 +53,7 @@ public class JxlSheet implements Sheet {
*/
@Override
public int getNumberOfRows() {
return this.delegate.getRows();
return this.numberOfRows;
}
/**
@@ -68,7 +74,7 @@ public class JxlSheet implements Sheet {
*/
@Override
public String getName() {
return this.delegate.getName();
return this.name;
}
/**
@@ -76,7 +82,7 @@ public class JxlSheet implements Sheet {
*/
@Override
public int getNumberOfColumns() {
return this.delegate.getColumns();
return this.numberOfColumns;
}
}

View File

@@ -33,6 +33,8 @@ import java.util.List;
public class PoiSheet implements Sheet {
private final org.apache.poi.ss.usermodel.Sheet delegate;
private final int numberOfRows;
private final String name;
private int numberOfColumns = -1;
@@ -44,6 +46,8 @@ public class PoiSheet implements Sheet {
PoiSheet(final org.apache.poi.ss.usermodel.Sheet delegate) {
super();
this.delegate = delegate;
this.numberOfRows = this.delegate.getLastRowNum() + 1;
this.name=this.delegate.getSheetName();
}
/**
@@ -51,7 +55,7 @@ public class PoiSheet implements Sheet {
*/
@Override
public int getNumberOfRows() {
return this.delegate.getLastRowNum() + 1;
return this.numberOfRows;
}
/**
@@ -59,7 +63,7 @@ public class PoiSheet implements Sheet {
*/
@Override
public String getName() {
return this.delegate.getSheetName();
return this.name;
}
/**