poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1751837 - in /poi/trunk/src: java/org/apache/poi/hssf/usermodel/ java/org/apache/poi/ss/formula/eval/forked/ ooxml/java/org/apache/poi/xssf/streaming/ ooxml/java/org/apache/poi/xssf/usermodel/
Date Thu, 07 Jul 2016 22:27:32 GMT
Author: onealj
Date: Thu Jul  7 22:27:32 2016
New Revision: 1751837

URL: http://svn.apache.org/viewvc?rev=1751837&view=rev
Log:
add @Override annotations to spreadsheet formula Evaluation classes

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationSheet.java
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationWorkbook.java
    poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationSheet.java
    poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationWorkbook.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFEvaluationSheet.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFEvaluationWorkbook.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationSheet.java?rev=1751837&r1=1751836&r2=1751837&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationSheet.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationSheet.java Thu Jul  7 22:27:32
2016
@@ -34,6 +34,7 @@ final class HSSFEvaluationSheet implemen
 	public HSSFSheet getHSSFSheet() {
 		return _hs;
 	}
+	@Override
 	public EvaluationCell getCell(int rowIndex, int columnIndex) {
 		HSSFRow row = _hs.getRow(rowIndex);
 		if (row == null) {
@@ -46,6 +47,7 @@ final class HSSFEvaluationSheet implemen
 		return new HSSFEvaluationCell(cell, this);
 	}
 	
+	@Override
 	public void clearAllCachedResultValues() {
 	    // nothing to do
 	}

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationWorkbook.java?rev=1751837&r1=1751836&r2=1751837&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationWorkbook.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationWorkbook.java Thu Jul 
7 22:27:32 2016
@@ -63,7 +63,8 @@ public final class HSSFEvaluationWorkboo
         _uBook = book;
         _iBook = book.getWorkbook();
     }
-    
+
+    @Override
     public void clearAllCachedResultValues() {
         // nothing to do
     }
@@ -73,18 +74,22 @@ public final class HSSFEvaluationWorkboo
         return _uBook.createName();
     }
 
+    @Override
     public int getExternalSheetIndex(String sheetName) {
         int sheetIndex = _uBook.getSheetIndex(sheetName);
         return _iBook.checkExternSheet(sheetIndex);
     }
+    @Override
     public int getExternalSheetIndex(String workbookName, String sheetName) {
         return _iBook.getExternalSheetIndex(workbookName, sheetName);
     }
     
+    @Override
     public Ptg get3DReferencePtg(CellReference cr, SheetIdentifier sheet) {
         int extIx = getSheetExtIx(sheet);
         return new Ref3DPtg(cr, extIx);
     }
+    @Override
     public Ptg get3DReferencePtg(AreaReference areaRef, SheetIdentifier sheet) {
         int extIx = getSheetExtIx(sheet);
         return new Area3DPtg(areaRef, extIx);
@@ -115,26 +120,33 @@ public final class HSSFEvaluationWorkboo
         return sheetIndex == -1 ? null : getName(name, -1);
     }
 
+    @Override
     public int getSheetIndex(EvaluationSheet evalSheet) {
         HSSFSheet sheet = ((HSSFEvaluationSheet)evalSheet).getHSSFSheet();
         return _uBook.getSheetIndex(sheet);
     }
+    @Override
     public int getSheetIndex(String sheetName) {
         return _uBook.getSheetIndex(sheetName);
     }
 
+    @Override
     public String getSheetName(int sheetIndex) {
         return _uBook.getSheetName(sheetIndex);
     }
 
+    @Override
     public EvaluationSheet getSheet(int sheetIndex) {
+        // TODO Cache these evaluation sheets so they aren't re-generated on every getSheet
call
         return new HSSFEvaluationSheet(_uBook.getSheetAt(sheetIndex));
     }
+    @Override
     public int convertFromExternSheetIndex(int externSheetIndex) {
         // TODO Update this to expose first and last sheet indexes
         return _iBook.getFirstSheetIndexFromExternSheetIndex(externSheetIndex);
     }
 
+    @Override
     public ExternalSheet getExternalSheet(int externSheetIndex) {
         ExternalSheet sheet = _iBook.getExternalSheet(externSheetIndex);
         if (sheet == null) {
@@ -163,36 +175,52 @@ public final class HSSFEvaluationWorkboo
         }
         return sheet;
     }
+
+    /**
+     * @throws IllegalStateException: XSSF-style external references are not supported for
HSSF
+     */
+    @Override
     public ExternalSheet getExternalSheet(String firstSheetName, String lastSheetName, int
externalWorkbookNumber) {
         throw new IllegalStateException("XSSF-style external references are not supported
for HSSF");
     }
 
+    @Override
     public ExternalName getExternalName(int externSheetIndex, int externNameIndex) {
         return _iBook.getExternalName(externSheetIndex, externNameIndex);
     }
 
+    /**
+     * @throws IllegalStateException: XSSF-style external names are not supported for HSSF
+     */
+    @Override
     public ExternalName getExternalName(String nameName, String sheetName, int externalWorkbookNumber)
{
         throw new IllegalStateException("XSSF-style external names are not supported for
HSSF");
     }
 
+    @Override
     public String resolveNameXText(NameXPtg n) {
         return _iBook.resolveNameXText(n.getSheetRefIndex(), n.getNameIndex());
     }
 
+    @Override
     public String getSheetFirstNameByExternSheet(int externSheetIndex) {
         return _iBook.findSheetFirstNameFromExternSheet(externSheetIndex);
     }
+    @Override
     public String getSheetLastNameByExternSheet(int externSheetIndex) {
         return _iBook.findSheetLastNameFromExternSheet(externSheetIndex);
     }
+    @Override
     public String getNameText(NamePtg namePtg) {
         return _iBook.getNameRecord(namePtg.getIndex()).getNameText();
     }
+    @Override
     public EvaluationName getName(NamePtg namePtg) {
         int ix = namePtg.getIndex();
         return new Name(_iBook.getNameRecord(ix), ix);
     }
 
+    @Override
     @SuppressWarnings("unused")
     public Ptg[] getFormulaTokens(EvaluationCell evalCell) {
         HSSFCell cell = ((HSSFEvaluationCell)evalCell).getHSSFCell();
@@ -213,6 +241,7 @@ public final class HSSFEvaluationWorkboo
         return fra.getFormulaTokens();
     }
 
+    @Override
     public UDFFinder getUDFFinder(){
         return _uBook.getUDFFinder();
     }

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationSheet.java?rev=1751837&r1=1751836&r2=1751837&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationSheet.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationSheet.java Thu
Jul  7 22:27:32 2016
@@ -50,6 +50,7 @@ final class ForkedEvaluationSheet implem
 		_sharedCellsByRowCol = new HashMap<RowColKey, ForkedEvaluationCell>();
 	}
 
+	@Override
 	public EvaluationCell getCell(int rowIndex, int columnIndex) {
 		RowColKey key = new RowColKey(rowIndex, columnIndex);
 
@@ -105,10 +106,12 @@ final class ForkedEvaluationSheet implem
 	 * leave the map alone, if it needs resetting, reusing this class is probably a bad idea.
 	 * @see org.apache.poi.ss.formula.EvaluationSheet#clearAllCachedResultValues()
 	 */
+	@Override
 	public void clearAllCachedResultValues() {
 	    _masterSheet.clearAllCachedResultValues();
 	}
 	
+    // FIXME: serves same purpose as org.apache.poi.xssf.usermodel.XSSFEvaluationSheet$CellKey
 	private static final class RowColKey implements Comparable<RowColKey>{
 		private final int _rowIndex;
 		private final int _columnIndex;

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationWorkbook.java?rev=1751837&r1=1751836&r2=1751837&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationWorkbook.java
(original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationWorkbook.java
Thu Jul  7 22:27:32 2016
@@ -75,17 +75,21 @@ final class ForkedEvaluationWorkbook imp
 		}
 	}
 
+    @Override
 	public int convertFromExternSheetIndex(int externSheetIndex) {
 		return _masterBook.convertFromExternSheetIndex(externSheetIndex);
 	}
 
+    @Override
 	public ExternalSheet getExternalSheet(int externSheetIndex) {
 		return _masterBook.getExternalSheet(externSheetIndex);
 	}
+    @Override
 	public ExternalSheet getExternalSheet(String firstSheetName, String lastSheetName, int externalWorkbookNumber)
{
         return _masterBook.getExternalSheet(firstSheetName, lastSheetName, externalWorkbookNumber);
     }
 
+    @Override
     public Ptg[] getFormulaTokens(EvaluationCell cell) {
 		if (cell instanceof ForkedEvaluationCell) {
 			// doesn't happen yet because formulas cannot be modified from the master workbook
@@ -94,25 +98,31 @@ final class ForkedEvaluationWorkbook imp
 		return _masterBook.getFormulaTokens(cell);
 	}
 
+    @Override
 	public EvaluationName getName(NamePtg namePtg) {
 		return _masterBook.getName(namePtg);
 	}
 
+    @Override
     public EvaluationName getName(String name, int sheetIndex){
         return _masterBook.getName(name, sheetIndex);
     }
 
+    @Override
 	public EvaluationSheet getSheet(int sheetIndex) {
 		return getSharedSheet(getSheetName(sheetIndex));
 	}
 	
+    @Override
 	public ExternalName getExternalName(int externSheetIndex, int externNameIndex) {
 	   return _masterBook.getExternalName(externSheetIndex, externNameIndex);
 	}
+    @Override
 	public ExternalName getExternalName(String nameName, String sheetName, int externalWorkbookNumber)
{
 	       return _masterBook.getExternalName(nameName, sheetName, externalWorkbookNumber);
     }
 
+    @Override
     public int getSheetIndex(EvaluationSheet sheet) {
 		if (sheet instanceof ForkedEvaluationSheet) {
 			ForkedEvaluationSheet mes = (ForkedEvaluationSheet) sheet;
@@ -121,19 +131,23 @@ final class ForkedEvaluationWorkbook imp
 		return _masterBook.getSheetIndex(sheet);
 	}
 
+    @Override
 	public int getSheetIndex(String sheetName) {
 		return _masterBook.getSheetIndex(sheetName);
 	}
 
+    @Override
 	public String getSheetName(int sheetIndex) {
 		return _masterBook.getSheetName(sheetIndex);
 	}
 
+    @Override
 	public String resolveNameXText(NameXPtg ptg) {
 		return _masterBook.resolveNameXText(ptg);
 	}
 
-    public UDFFinder getUDFFinder(){
+    @Override
+    public UDFFinder getUDFFinder() {
         return _masterBook.getUDFFinder();
     }
     
@@ -141,6 +155,7 @@ final class ForkedEvaluationWorkbook imp
      * leave the map alone, if it needs resetting, reusing this class is probably a bad idea.
      * @see org.apache.poi.ss.formula.EvaluationSheet#clearAllCachedResultValues()
      */
+    @Override
     public void clearAllCachedResultValues() {
         _masterBook.clearAllCachedResultValues();
     }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFEvaluationSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFEvaluationSheet.java?rev=1751837&r1=1751836&r2=1751837&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFEvaluationSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFEvaluationSheet.java Thu Jul
 7 22:27:32 2016
@@ -33,6 +33,7 @@ final class SXSSFEvaluationSheet impleme
     public SXSSFSheet getSXSSFSheet() {
         return _xs;
     }
+    @Override
     public EvaluationCell getCell(int rowIndex, int columnIndex) {
         SXSSFRow row = _xs.getRow(rowIndex);
         if (row == null) {
@@ -48,6 +49,7 @@ final class SXSSFEvaluationSheet impleme
         return new SXSSFEvaluationCell(cell, this);
     }
     
+    @Override
     public void clearAllCachedResultValues() {
         // nothing to do
     }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFEvaluationWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFEvaluationWorkbook.java?rev=1751837&r1=1751836&r2=1751837&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFEvaluationWorkbook.java
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFEvaluationWorkbook.java
Thu Jul  7 22:27:32 2016
@@ -52,10 +52,16 @@ import org.openxmlformats.schemas.spread
 public abstract class BaseXSSFEvaluationWorkbook implements FormulaRenderingWorkbook, EvaluationWorkbook,
FormulaParsingWorkbook {
     protected final XSSFWorkbook _uBook;
 
+    // lazily populated. This should only be accessed through getTableCache
+    // keys are lower-case to make this a quasi-case-insensitive map
+    private Map<String, XSSFTable> _tableCache = null;
+
+
     protected BaseXSSFEvaluationWorkbook(XSSFWorkbook book) {
         _uBook = book;
     }
 
+    @Override
     public void clearAllCachedResultValues() {
         _tableCache = null;
     }
@@ -67,6 +73,7 @@ public abstract class BaseXSSFEvaluation
      * XSSF doesn't use external sheet indexes, so when asked treat
      * it just as a local index
      */
+    @Override
     public int convertFromExternSheetIndex(int externSheetIndex) {
         return externSheetIndex;
     }
@@ -80,6 +87,7 @@ public abstract class BaseXSSFEvaluation
         return sheetIndex;
     }
 
+    @Override
     public int getExternalSheetIndex(String sheetName) {
         int sheetIndex = _uBook.getSheetIndex(sheetName);
         return convertToExternalSheetIndex(sheetIndex);
@@ -121,7 +129,7 @@ public abstract class BaseXSSFEvaluation
         // Not properly referenced
         throw new RuntimeException("Book not linked for filename " + bookName);
     }
-    /* case-sensitive */
+    /* This is case-sensitive. Is that correct? */
     private int findExternalLinkIndex(String bookName, List<ExternalLinksTable> tables)
{
         int i = 0;
         for (ExternalLinksTable table : tables) {
@@ -152,6 +160,7 @@ public abstract class BaseXSSFEvaluation
      *  EvaluationName corresponding to that named range 
      *  Returns null if there is no named range with the same name and scope in the workbook
      */
+    @Override
     public EvaluationName getName(String name, int sheetIndex) {
         for (int i = 0; i < _uBook.getNumberOfNames(); i++) {
             XSSFName nm = _uBook.getNameAt(i);
@@ -165,14 +174,17 @@ public abstract class BaseXSSFEvaluation
         return sheetIndex == -1 ? null : getName(name, -1);
     }
 
+    @Override
     public String getSheetName(int sheetIndex) {
         return _uBook.getSheetName(sheetIndex);
     }
     
+    @Override
     public ExternalName getExternalName(int externSheetIndex, int externNameIndex) {
         throw new IllegalStateException("HSSF-style external references are not supported
for XSSF");
     }
 
+    @Override
     public ExternalName getExternalName(String nameName, String sheetName, int externalWorkbookNumber)
{
         if (externalWorkbookNumber > 0) {
             // External reference - reference is 1 based, link table is 0 based
@@ -236,6 +248,7 @@ public abstract class BaseXSSFEvaluation
             return new NameXPxg(sheetName, name);
         }
     }
+    @Override
     public Ptg get3DReferencePtg(CellReference cell, SheetIdentifier sheet) {
         if (sheet._bookName != null) {
             int bookIndex = resolveBookIndex(sheet._bookName);
@@ -244,6 +257,7 @@ public abstract class BaseXSSFEvaluation
             return new Ref3DPxg(sheet, cell);
         }
     }
+    @Override
     public Ptg get3DReferencePtg(AreaReference area, SheetIdentifier sheet) {
         if (sheet._bookName != null) {
             int bookIndex = resolveBookIndex(sheet._bookName);
@@ -253,6 +267,7 @@ public abstract class BaseXSSFEvaluation
         }
     }
 
+    @Override
     public String resolveNameXText(NameXPtg n) {
         int idx = n.getNameIndex();
         String name = null;
@@ -271,9 +286,11 @@ public abstract class BaseXSSFEvaluation
         return name;
     }
 
+    @Override
     public ExternalSheet getExternalSheet(int externSheetIndex) {
         throw new IllegalStateException("HSSF-style external references are not supported
for XSSF");
     }
+    @Override
     public ExternalSheet getExternalSheet(String firstSheetName, String lastSheetName, int
externalWorkbookNumber) {
         String workbookName;
         if (externalWorkbookNumber > 0) {
@@ -297,22 +314,27 @@ public abstract class BaseXSSFEvaluation
     public int getExternalSheetIndex(String workbookName, String sheetName) {
         throw new RuntimeException("not implemented yet");
     }
+    @Override
     public int getSheetIndex(String sheetName) {
         return _uBook.getSheetIndex(sheetName);
     }
 
+    @Override
     public String getSheetFirstNameByExternSheet(int externSheetIndex) {
         int sheetIndex = convertFromExternalSheetIndex(externSheetIndex);
         return _uBook.getSheetName(sheetIndex);
     }
+    @Override
     public String getSheetLastNameByExternSheet(int externSheetIndex) {
         // XSSF does multi-sheet references differently, so this is the same as the first
         return getSheetFirstNameByExternSheet(externSheetIndex);
     }
 
+    @Override
     public String getNameText(NamePtg namePtg) {
         return _uBook.getNameAt(namePtg.getIndex()).getNameName();
     }
+    @Override
     public EvaluationName getName(NamePtg namePtg) {
         int ix = namePtg.getIndex();
         return new Name(_uBook.getNameAt(ix), ix, this);
@@ -337,7 +359,6 @@ public abstract class BaseXSSFEvaluation
      *
      *       Perhaps tables can be managed similar to PivotTable references above?
      */
-    private Map<String, XSSFTable> _tableCache = null;
     private Map<String, XSSFTable> getTableCache() {
         if ( _tableCache != null ) {
             return _tableCache;
@@ -371,10 +392,16 @@ public abstract class BaseXSSFEvaluation
         return getTableCache().get(lname);
     }
     
+    @Override
     public UDFFinder getUDFFinder(){
         return _uBook.getUDFFinder();
     }
 
+    @Override
+    public SpreadsheetVersion getSpreadsheetVersion(){
+        return SpreadsheetVersion.EXCEL2007;
+    }
+
     private static final class Name implements EvaluationName {
 
         private final XSSFName _nameRecord;
@@ -414,8 +441,4 @@ public abstract class BaseXSSFEvaluation
             return new NamePtg(_index);
         }
     }
-
-    public SpreadsheetVersion getSpreadsheetVersion(){
-        return SpreadsheetVersion.EXCEL2007;
-    }
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java?rev=1751837&r1=1751836&r2=1751837&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java Thu Jul
 7 22:27:32 2016
@@ -41,10 +41,12 @@ final class XSSFEvaluationSheet implemen
         return _xs;
     }
 
+    @Override
     public void clearAllCachedResultValues() {
         _cellCache = null;
     }
     
+    @Override
     public EvaluationCell getCell(int rowIndex, int columnIndex) {
         // cache for performance: ~30% speedup due to caching
         if (_cellCache == null) {

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java?rev=1751837&r1=1751836&r2=1751837&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java Thu
Jul  7 22:27:32 2016
@@ -40,6 +40,7 @@ public final class XSSFEvaluationWorkboo
         super(book);
     }
 
+    @Override
     public void clearAllCachedResultValues() {
         super.clearAllCachedResultValues();
         _sheetCache = null;



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message