From 0173f227872bb28d1a7903f27a9308fd99555782 Mon Sep 17 00:00:00 2001 From: Javen O'Neal Date: Sat, 16 Jan 2016 22:58:25 +0000 Subject: [PATCH] make SXSSFWorkbook member variables private git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1725047 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/xssf/streaming/SXSSFWorkbook.java | 25 ++++++++----------- .../poi/xssf/streaming/TestSXSSFWorkbook.java | 10 +++++--- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java index 57bee980a..8e15739b4 100644 --- a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java @@ -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 _sxFromXHash=new HashMap(); - HashMap _xFromSxHash=new HashMap(); + private final Map _sxFromXHash = new HashMap(); + private final Map _xFromSxHash = new HashMap(); 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; } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java index 4c46cd1f4..6d89aa500 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java @@ -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()); } }