final class CellLocation {
public static final CellLocation[] EMPTY_ARRAY = { };
- private final EvaluationWorkbook _book;
+ private final int _bookIx;
private final int _sheetIndex;
private final int _rowIndex;
private final int _columnIndex;
private final int _hashCode;
- public CellLocation(EvaluationWorkbook book, int sheetIndex, int rowIndex, int columnIndex) {
+ public CellLocation(int bookIx, int sheetIndex, int rowIndex, int columnIndex) {
if (sheetIndex < 0) {
throw new IllegalArgumentException("sheetIndex must not be negative");
}
- _book = book;
+ _bookIx = bookIx;
_sheetIndex = sheetIndex;
_rowIndex = rowIndex;
_columnIndex = columnIndex;
- _hashCode = System.identityHashCode(book) + sheetIndex + 17 * (rowIndex + 17 * columnIndex);
+ _hashCode = _bookIx + 17 * (sheetIndex + 17 * (rowIndex + 17 * columnIndex));
}
- public Object getBook() {
- return _book;
+ public int getBookIndex() {
+ return _bookIx;
}
public int getSheetIndex() {
return _sheetIndex;
if (getSheetIndex() != other.getSheetIndex()) {
return false;
}
- if (getBook() != other.getBook()) {
+ if (getBookIndex() != other.getBookIndex()) {
return false;
}
return true;
private final EvaluationWorkbook _workbook;
private EvaluationCache _cache;
+ private int _workbookIx;
private final IEvaluationListener _evaluationListener;
private final Map _sheetIndexesBySheet;
_cache = new EvaluationCache(evaluationListener);
_sheetIndexesBySheet = new IdentityHashMap();
_collaboratingWorkbookEnvironment = CollaboratingWorkbooksEnvironment.EMPTY;
+ _workbookIx = 0;
}
/**
System.out.println(s);
}
}
- /* package */ void attachToEnvironment(CollaboratingWorkbooksEnvironment collaboratingWorkbooksEnvironment, EvaluationCache cache) {
+ /* package */ void attachToEnvironment(CollaboratingWorkbooksEnvironment collaboratingWorkbooksEnvironment, EvaluationCache cache, int workbookIx) {
_collaboratingWorkbookEnvironment = collaboratingWorkbooksEnvironment;
_cache = cache;
+ _workbookIx = workbookIx;
}
/* package */ CollaboratingWorkbooksEnvironment getEnvironment() {
return _collaboratingWorkbookEnvironment;
/* package */ void detachFromEnvironment() {
_collaboratingWorkbookEnvironment = CollaboratingWorkbooksEnvironment.EMPTY;
_cache = new EvaluationCache(_evaluationListener);
+ _workbookIx = 0;
}
/* package */ IEvaluationListener getEvaluationListener() {
return _evaluationListener;
throw new IllegalArgumentException("value must not be null");
}
int sheetIndex = getSheetIndex(sheet);
- _cache.setValue(new CellLocation(_workbook, sheetIndex, rowIndex, columnIndex), true, CellLocation.EMPTY_ARRAY, value);
+ _cache.setValue(getCellLoc(sheetIndex, rowIndex, columnIndex), true, CellLocation.EMPTY_ARRAY, value);
}
/**
*/
public void notifySetFormula(HSSFSheet sheet, int rowIndex, int columnIndex) {
int sheetIndex = getSheetIndex(sheet);
- _cache.setValue(new CellLocation(_workbook, sheetIndex, rowIndex, columnIndex), false, CellLocation.EMPTY_ARRAY, null);
+ _cache.setValue(getCellLoc(sheetIndex, rowIndex, columnIndex), false, CellLocation.EMPTY_ARRAY, null);
}
private int getSheetIndex(HSSFSheet sheet) {
public ValueEval evaluate(HSSFCell srcCell) {
int sheetIndex = getSheetIndex(srcCell.getSheet());
- CellLocation cellLoc = new CellLocation(_workbook, sheetIndex, srcCell.getRowIndex(), srcCell.getCellNum());
+ CellLocation cellLoc = getCellLoc(sheetIndex, srcCell.getRowIndex(), srcCell.getCellNum());
return internalEvaluate(srcCell, cellLoc, new EvaluationTracker(_cache));
}
} else {
cell = row.getCell(columnIndex);
}
- CellLocation cellLoc = new CellLocation(_workbook, sheetIndex, rowIndex, columnIndex);
+ CellLocation cellLoc = getCellLoc(sheetIndex, rowIndex, columnIndex);
tracker.acceptDependency(cellLoc);
return internalEvaluate(cell, cellLoc, tracker);
}
+ private CellLocation getCellLoc(int sheetIndex, int rowIndex, int columnIndex) {
+ return new CellLocation(_workbookIx, sheetIndex, rowIndex, columnIndex);
+ }
}