poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1747616 - /poi/branches/xssf_structured_references/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
Date Fri, 10 Jun 2016 01:08:05 GMT
Author: onealj
Date: Fri Jun 10 01:08:05 2016
New Revision: 1747616

URL: http://svn.apache.org/viewvc?rev=1747616&view=rev
Log:
bug 57840: move XSSFTable cache from XSSFWorkbook to XSSFEvaluationWorkbook where staleness
is less likely to cause problems for users

Modified:
    poi/branches/xssf_structured_references/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java

Modified: poi/branches/xssf_structured_references/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/branches/xssf_structured_references/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java?rev=1747616&r1=1747615&r2=1747616&view=diff
==============================================================================
--- poi/branches/xssf_structured_references/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
(original)
+++ poi/branches/xssf_structured_references/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
Fri Jun 10 01:08:05 2016
@@ -2263,48 +2263,23 @@ public class XSSFWorkbook extends POIXML
         return SpreadsheetVersion.EXCEL2007;
     }
     
-    /*
-     * TODO: data tables are stored at the workbook level in XSSF, but are bound to a single
sheet.
-     *       The current code structure has them hanging off XSSFSheet, but formulas reference
them
-     *       only by name (names are global, and case insensitive).
-     *       This map stores names as lower case for case-insensitive lookups.
-     *
-     * FIXME: Caching tables by name here for fast formula lookup means the map is out of
date if
-     *       a table is renamed or added/removed to a sheet after the map is created.
-     *
-     *       Perhaps tables can be managed similar to PivotTable references above?
-     */
-    Map<String, XSSFTable> _tableCache = null;
-    private Map<String, XSSFTable> getTableCache() {
-        if ( _tableCache != null ) {
-            return _tableCache;
-        }
-        // FIXME: use org.apache.commons.collections.map.CaseInsensitiveMap
-        _tableCache = new HashMap<String, XSSFTable>();
-
-        if (sheets != null) {
-            for (XSSFSheet sheet : sheets) {
-                for (XSSFTable tbl : sheet.getTables()) {
-                    String lname = tbl.getName().toLowerCase(Locale.ROOT);
-                    _tableCache.put(lname, tbl);
-                }
-            }
-        }
-        return _tableCache;
-    }
-
     /**
      * Returns the data table with the given name (case insensitive).
-     * Tables are cached for performance (formula evaluation looks them up by name repeatedly).
-     * After the first table lookup, adding or removing a table from the document structure
will cause trouble.
-     * This is meant to be used on documents whose structure is essentially static at the
point formulas are evaluated.
      * 
      * @param name the data table name (case-insensitive)
      * @return The Data table in the workbook named <tt>name</tt>, or <tt>null</tt>
if no table is named <tt>name</tt>.
      * @since 3.15 beta 2
      */
     public XSSFTable getTable(String name) {
-        String lname = name.toLowerCase(Locale.ROOT);
-        return getTableCache().get(lname);
+        if (sheets != null) {
+            for (XSSFSheet sheet : sheets) {
+                for (XSSFTable tbl : sheet.getTables()) {
+                    if (name.equalsIgnoreCase(tbl.getName())) {
+                        return tbl;
+                    }
+                }
+            }
+        }
+        return null;
     }
 }



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


Mime
View raw message