]> source.dussan.org Git - poi.git/commitdiff
Made public instance fields for ITestDataProvider singletons.
authorJosh Micich <josh@apache.org>
Fri, 25 Dec 2009 23:51:32 +0000 (23:51 +0000)
committerJosh Micich <josh@apache.org>
Fri, 25 Dec 2009 23:51:32 +0000 (23:51 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@893900 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java
src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java
src/testcases/org/apache/poi/ss/ITestDataProvider.java

index 58dde48bfa1d32770a44e7b3756662ed73d8f838..4982081ca1fe8872b5624de57011ee6bbd0404bc 100644 (file)
 
 package org.apache.poi.xssf;
 
+import org.apache.poi.POIDataSamples;
 import org.apache.poi.ss.ITestDataProvider;
 import org.apache.poi.ss.SpreadsheetVersion;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.POIDataSamples;
 
 /**
  * @author Yegor Kozlov
  */
 public final class XSSFITestDataProvider implements ITestDataProvider {
+    public static final XSSFITestDataProvider instance = new XSSFITestDataProvider();
 
+    private XSSFITestDataProvider() {
+        // enforce singleton
+    }
+    public static XSSFITestDataProvider getInstance(){
+        return instance;
+    }
     public XSSFWorkbook openSampleWorkbook(String sampleFileName) {
         return XSSFTestDataSamples.openSampleWorkbook(sampleFileName);
     }
-
     public XSSFWorkbook writeOutAndReadBack(Workbook original) {
         if(!(original instanceof XSSFWorkbook)) {
             throw new IllegalArgumentException("Expected an instance of XSSFWorkbook");
         }
-
         return XSSFTestDataSamples.writeOutAndReadBack((XSSFWorkbook)original);
     }
-
     public XSSFWorkbook createWorkbook(){
         return new XSSFWorkbook();
     }
-
     public byte[] getTestDataFileContent(String fileName) {
         return POIDataSamples.getSpreadSheetInstance().readFile(fileName);
     }
-
     public SpreadsheetVersion getSpreadsheetVersion(){
         return SpreadsheetVersion.EXCEL2007;
     }
-
-    private XSSFITestDataProvider() {
-        // enforce singleton
-    }
-    private static XSSFITestDataProvider inst = new XSSFITestDataProvider();
-    public static XSSFITestDataProvider getInstance(){
-        return inst;
+    public String getStandardFileNameExtension() {
+        return "xlsx";
     }
 }
index 6be47dea0507bc12720e0e914f35e7c6fe92d9ba..b4d1b9d86e0de8545c93a4a16530bddaa76ff924 100644 (file)
 
 package org.apache.poi.hssf;
 
+import org.apache.poi.POIDataSamples;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.ITestDataProvider;
 import org.apache.poi.ss.SpreadsheetVersion;
 import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.POIDataSamples;
 
 /**
  * @author Yegor Kozlov
  */
 public final class HSSFITestDataProvider implements ITestDataProvider {
+    public static final HSSFITestDataProvider instance = new HSSFITestDataProvider();
 
+    private HSSFITestDataProvider(){
+        // enforce singleton
+    }
+    public static HSSFITestDataProvider getInstance(){
+        return instance;
+    }
     public HSSFWorkbook openSampleWorkbook(String sampleFileName) {
-               return HSSFTestDataSamples.openSampleWorkbook(sampleFileName);
-       }
-
-       public HSSFWorkbook writeOutAndReadBack(Workbook original) {
+        return HSSFTestDataSamples.openSampleWorkbook(sampleFileName);
+    }
+    public HSSFWorkbook writeOutAndReadBack(Workbook original) {
         if(!(original instanceof HSSFWorkbook)) {
             throw new IllegalArgumentException("Expected an instance of HSSFWorkbook");
         }
-
         return HSSFTestDataSamples.writeOutAndReadBack((HSSFWorkbook)original);
-       }
-
+    }
     public HSSFWorkbook createWorkbook(){
         return new HSSFWorkbook();
     }
-
     public byte[] getTestDataFileContent(String fileName) {
         return POIDataSamples.getSpreadSheetInstance().readFile(fileName);
     }
-
     public SpreadsheetVersion getSpreadsheetVersion(){
         return SpreadsheetVersion.EXCEL97;
     }
-
-    private HSSFITestDataProvider(){}
-    private static HSSFITestDataProvider inst = new HSSFITestDataProvider();
-    public static HSSFITestDataProvider getInstance(){
-        return inst;
+    public String getStandardFileNameExtension() {
+        return "xls";
     }
 }
index e10bfcf7c0666c629caf04110250b19dd945491d..5fdcd491de2d10020488517b9c8bf145c4df134e 100644 (file)
@@ -24,7 +24,7 @@ import org.apache.poi.ss.usermodel.Workbook;
  */
 public interface ITestDataProvider {
     /**
-     * Override to provide HSSF / XSSF specific way for re-serialising a workbook
+     * Provides HSSF / XSSF specific way for re-serialising a workbook
      *
      * @param wb the workbook to re-serialize
      * @return the re-serialized workbook
@@ -32,7 +32,7 @@ public interface ITestDataProvider {
     Workbook writeOutAndReadBack(Workbook wb);
 
     /**
-     * Override to provide way of loading HSSF / XSSF sample workbooks
+     * Provides way of loading HSSF / XSSF sample workbooks
      *
      * @param sampleFileName the file name to load
      * @return an instance of Workbook loaded from the supplied file name
@@ -40,7 +40,7 @@ public interface ITestDataProvider {
     Workbook openSampleWorkbook(String sampleFileName);
 
     /**
-     * Override to provide way of creating HSSF / XSSF workbooks
+     * Provides way of creating HSSF / XSSF workbooks
      * @return an instance of Workbook
      */
     Workbook createWorkbook();
@@ -53,4 +53,9 @@ public interface ITestDataProvider {
     byte[] getTestDataFileContent(String fileName);
 
     SpreadsheetVersion getSpreadsheetVersion();
+
+    /**
+     * @return "xls" or "xlsx"
+     */
+    String getStandardFileNameExtension();
 }