]> source.dussan.org Git - poi.git/commitdiff
make SXSSFWorkbook member variables private
authorJaven O'Neal <onealj@apache.org>
Sat, 16 Jan 2016 22:58:25 +0000 (22:58 +0000)
committerJaven O'Neal <onealj@apache.org>
Sat, 16 Jan 2016 22:58:25 +0000 (22:58 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1725047 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java
src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java

index 57bee980a29225908ada8552b6bdef295e5272e0..8e15739b459bc1cb371fda335d7aa434b048afd0 100644 (file)
@@ -28,6 +28,7 @@ import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
@@ -71,29 +72,29 @@ public class SXSSFWorkbook implements Workbook {
     /**
      * Specifies how many rows can be accessed at most via getRow().
      * When a new node is created via createRow() and the total number
-     * of unflushed records would exeed the specified value, then the
+     * of unflushed records would exceed the specified value, then the
      * row with the lowest index value is flushed and cannot be accessed
      * via getRow() anymore.
      */
     public static final int DEFAULT_WINDOW_SIZE = 100;
-    private static POILogger logger = POILogFactory.getLogger(SXSSFWorkbook.class);
+    private static final POILogger logger = POILogFactory.getLogger(SXSSFWorkbook.class);
 
-    XSSFWorkbook _wb;
+    private final XSSFWorkbook _wb;
 
-    HashMap<SXSSFSheet,XSSFSheet> _sxFromXHash=new HashMap<SXSSFSheet,XSSFSheet>();
-    HashMap<XSSFSheet,SXSSFSheet> _xFromSxHash=new HashMap<XSSFSheet,SXSSFSheet>();
+    private final Map<SXSSFSheet,XSSFSheet> _sxFromXHash = new HashMap<SXSSFSheet,XSSFSheet>();
+    private final Map<XSSFSheet,SXSSFSheet> _xFromSxHash = new HashMap<XSSFSheet,SXSSFSheet>();
 
     private int _randomAccessWindowSize = DEFAULT_WINDOW_SIZE;
 
     /**
-     * whetehr temp files should be compressed.
+     * whether temp files should be compressed.
      */
     private boolean _compressTmpFiles = false;
 
     /**
      * shared string table - a cache of strings in this workbook
      */
-    private SharedStringsTable _sharedStringSource = null;
+    private final SharedStringsTable _sharedStringSource;
 
     /**
      * Construct a new workbook
@@ -220,16 +221,12 @@ public class SXSSFWorkbook implements Workbook {
         if (workbook == null)
         {
             _wb=new XSSFWorkbook();
-            if(useSharedStringsTable){
-                _sharedStringSource = _wb.getSharedStringSource();
-            }
+            _sharedStringSource = useSharedStringsTable ? _wb.getSharedStringSource() : null;
         }
         else
         {
             _wb=workbook;
-            if(useSharedStringsTable){
-                _sharedStringSource = _wb.getSharedStringSource();
-            }
+            _sharedStringSource = useSharedStringsTable ? _wb.getSharedStringSource() : null;
             for ( int i = 0; i < _wb.getNumberOfSheets(); i++ )
             {
                 XSSFSheet sheet = _wb.getSheetAt( i );
@@ -1333,7 +1330,7 @@ public class SXSSFWorkbook implements Workbook {
      * @since 3.14 beta 2
      */
     @Override
-    public SpreadsheetVersion getSpreadsheetVersion() { 
+    public SpreadsheetVersion getSpreadsheetVersion() {
         return SpreadsheetVersion.EXCEL2007;
     }
 
index 4c46cd1f4111841b362222048f52e43dc8fca1c0..6d89aa500eecd09ea48f939174570d33d5e966e1 100644 (file)
@@ -310,14 +310,16 @@ public final class TestSXSSFWorkbook extends BaseTestWorkbook {
             }
         }
 
-        for (SXSSFSheet sheet : wb._sxFromXHash.keySet()) {
-            assertTrue(sheet.getSheetDataWriter().getTempFile().exists());
+        for (Sheet sheet : wb) {
+            SXSSFSheet sxSheet = (SXSSFSheet) sheet;
+            assertTrue(sxSheet.getSheetDataWriter().getTempFile().exists());
         }
 
         assertTrue(wb.dispose());
 
-        for (SXSSFSheet sheet : wb._sxFromXHash.keySet()) {
-            assertFalse(sheet.getSheetDataWriter().getTempFile().exists());
+        for (Sheet sheet : wb) {
+            SXSSFSheet sxSheet = (SXSSFSheet) sheet;
+            assertFalse(sxSheet.getSheetDataWriter().getTempFile().exists());
         }
     }