From 721ab0e8047e291ad036e1865acd693b0471deca Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Tue, 19 Mar 2019 21:55:26 +0000 Subject: [PATCH] Remove more remnants of NPOIFSFileSystem, mostly in comments and variable names This avoids confusion if people look at this code in the future without knowledge about the historical transition from java.io to java.nio git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1855873 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/poi/POIDocument.java | 6 ++--- .../poi/hssf/usermodel/HSSFWorkbook.java | 2 +- .../hssf/usermodel/HSSFWorkbookFactory.java | 2 +- .../poifs/eventfilesystem/POIFSReader.java | 4 +-- .../poi/poifs/filesystem/DirectoryNode.java | 26 +++++++++---------- .../filesystem/DocumentFactoryHelper.java | 4 +-- .../poi/poifs/macros/VBAMacroReader.java | 2 +- .../poi/sl/usermodel/SlideShowFactory.java | 8 +++--- .../poi/ss/usermodel/WorkbookFactory.java | 8 +++--- .../poi/ooxml/extractor/ExtractorFactory.java | 2 +- .../poi/xssf/usermodel/TestXSSFBugs.java | 6 ++--- .../hslf/extractor/PowerPointExtractor.java | 2 +- .../poi/hslf/usermodel/HSLFSlideShow.java | 4 +-- .../hslf/usermodel/HSLFSlideShowFactory.java | 2 +- .../extractor/TestPublisherTextExtractor.java | 6 ++--- .../poi/hslf/extractor/TestExtractor.java | 4 +-- .../apache/poi/hslf/usermodel/TestBugs.java | 10 +++---- .../poi/hwpf/extractor/TestWordExtractor.java | 4 +-- .../apache/poi/hwpf/usermodel/TestBugs.java | 6 ++--- .../poi/hwpf/usermodel/TestHWPFWrite.java | 2 +- .../org/apache/poi/hpsf/basic/TestWrite.java | 4 +-- .../TestHPSFPropertiesExtractor.java | 4 +-- .../hssf/extractor/TestOldExcelExtractor.java | 2 +- .../apache/poi/hssf/usermodel/TestBugs.java | 17 +++++------- .../poi/hssf/usermodel/TestHSSFWorkbook.java | 23 +++++++--------- .../poi/poifs/filesystem/TestDocument.java | 2 +- .../filesystem/TestDocumentInputStream.java | 20 +++++++------- .../poi/poifs/filesystem/TestEntryUtils.java | 2 +- .../poifs/filesystem/TestFileSystemBugs.java | 4 +-- .../poi/poifs/filesystem/TestPOIFSStream.java | 4 +-- .../poi/poifs/macros/TestVBAMacroReader.java | 20 +++++++------- .../usermodel/BaseTestSlideShowFactory.java | 18 ++++++------- 32 files changed, 110 insertions(+), 120 deletions(-) diff --git a/src/java/org/apache/poi/POIDocument.java b/src/java/org/apache/poi/POIDocument.java index 78015b4a95..e7d8afa8d7 100644 --- a/src/java/org/apache/poi/POIDocument.java +++ b/src/java/org/apache/poi/POIDocument.java @@ -236,7 +236,7 @@ public abstract class POIDocument implements Closeable { /** * Writes out the updated standard Document Information Properties (HPSF) - * into the currently open NPOIFSFileSystem + * into the currently open POIFSFileSystem * * @throws IOException if an error when writing to the open * {@link POIFSFileSystem} occurs @@ -258,7 +258,7 @@ public abstract class POIDocument implements Closeable { } /** * Writes out the standard Document Information Properties (HPSF) - * @param outFS the NPOIFSFileSystem to write the properties into + * @param outFS the {@link POIFSFileSystem} to write the properties into * @param writtenEntries a list of POIFS entries to add the property names too * * @throws IOException if an error when writing to the @@ -314,7 +314,7 @@ public abstract class POIDocument implements Closeable { * * @param name the (POIFS Level) name of the property to write * @param set the PropertySet to write out - * @param outFS the NPOIFSFileSystem to write the property into + * @param outFS the {@link POIFSFileSystem} to write the property into * * @throws IOException if an error when writing to the * {@link POIFSFileSystem} occurs diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java index 1f3485d8e4..78a4e4fd9e 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java @@ -393,7 +393,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss * @see #HSSFWorkbook(POIFSFileSystem) * @exception IOException if the stream cannot be read */ - @SuppressWarnings("resource") // NPOIFSFileSystem always closes the stream + @SuppressWarnings("resource") // POIFSFileSystem always closes the stream public HSSFWorkbook(InputStream s, boolean preserveNodes) throws IOException { diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbookFactory.java b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbookFactory.java index 96196707f6..af9b26fe42 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbookFactory.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbookFactory.java @@ -41,7 +41,7 @@ public class HSSFWorkbookFactory extends WorkbookFactory { } /** - * Creates a HSSFWorkbook from the given NPOIFSFileSystem

+ * Creates a HSSFWorkbook from the given {@link POIFSFileSystem}

* Note that in order to properly release resources the * Workbook should be closed after use. */ diff --git a/src/java/org/apache/poi/poifs/eventfilesystem/POIFSReader.java b/src/java/org/apache/poi/poifs/eventfilesystem/POIFSReader.java index 718709f51f..ee7c9ad4e0 100644 --- a/src/java/org/apache/poi/poifs/eventfilesystem/POIFSReader.java +++ b/src/java/org/apache/poi/poifs/eventfilesystem/POIFSReader.java @@ -78,9 +78,9 @@ public class POIFSReader } /** - * Read from a NPOIFSFileSystem and process the documents we get + * Read from a {@link POIFSFileSystem} and process the documents we get * - * @param poifs the NPOIFSFileSystem from which to read the data + * @param poifs the POIFSFileSystem from which to read the data * * @exception IOException on errors reading, or on invalid data */ diff --git a/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java b/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java index 47c7e7ff4b..e91da26fb5 100644 --- a/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java +++ b/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java @@ -49,8 +49,8 @@ public class DirectoryNode // Our list of entries, kept sorted to preserve order private final ArrayList _entries = new ArrayList<>(); - // the NPOIFSFileSytem we belong to - private final POIFSFileSystem _nfilesystem; + // the POIFSFileSystem we belong to + private final POIFSFileSystem _filesystem; // the path described by this document private final POIFSDocumentPath _path; @@ -60,15 +60,15 @@ public class DirectoryNode * is intended strictly for the internal use of this package * * @param property the DirectoryProperty for this DirectoryEntry - * @param nfilesystem the NPOIFSFileSystem we belong to + * @param filesystem the {@link POIFSFileSystem} we belong to * @param parent the parent of this entry */ DirectoryNode(final DirectoryProperty property, - final POIFSFileSystem nfilesystem, + final POIFSFileSystem filesystem, final DirectoryNode parent) { super(property, parent); - this._nfilesystem = nfilesystem; + this._filesystem = filesystem; if (parent == null) { @@ -91,7 +91,7 @@ public class DirectoryNode if (child.isDirectory()) { DirectoryProperty childDir = (DirectoryProperty) child; - childNode = new DirectoryNode(childDir, _nfilesystem, this); + childNode = new DirectoryNode(childDir, _filesystem, this); } else { @@ -116,7 +116,7 @@ public class DirectoryNode */ public POIFSFileSystem getFileSystem() { - return _nfilesystem; + return _filesystem; } /** @@ -175,7 +175,7 @@ public class DirectoryNode DocumentNode rval = new DocumentNode(property, this); (( DirectoryProperty ) getProperty()).addChild(property); - _nfilesystem.addDocument(document); + _filesystem.addDocument(document); _entries.add(rval); _byname.put(property.getName(), rval); @@ -228,7 +228,7 @@ public class DirectoryNode _byname.remove(entry.getName()); try { - _nfilesystem.remove(entry); + _filesystem.remove(entry); } catch (IOException e) { // TODO Work out how to report this, given we can't change the method signature... throw new RuntimeException(e); @@ -349,7 +349,7 @@ public class DirectoryNode final InputStream stream) throws IOException { - return createDocument(new POIFSDocument(name, _nfilesystem, stream)); + return createDocument(new POIFSDocument(name, _filesystem, stream)); } /** @@ -368,7 +368,7 @@ public class DirectoryNode final POIFSWriterListener writer) throws IOException { - return createDocument(new POIFSDocument(name, size, _nfilesystem, writer)); + return createDocument(new POIFSDocument(name, size, _filesystem, writer)); } /** @@ -386,8 +386,8 @@ public class DirectoryNode { DirectoryProperty property = new DirectoryProperty(name); - DirectoryNode rval = new DirectoryNode(property, _nfilesystem, this); - _nfilesystem.addDirectory(property); + DirectoryNode rval = new DirectoryNode(property, _filesystem, this); + _filesystem.addDirectory(property); (( DirectoryProperty ) getProperty()).addChild(property); _entries.add(rval); diff --git a/src/java/org/apache/poi/poifs/filesystem/DocumentFactoryHelper.java b/src/java/org/apache/poi/poifs/filesystem/DocumentFactoryHelper.java index e53f58475d..9ac5e94018 100644 --- a/src/java/org/apache/poi/poifs/filesystem/DocumentFactoryHelper.java +++ b/src/java/org/apache/poi/poifs/filesystem/DocumentFactoryHelper.java @@ -38,7 +38,7 @@ public final class DocumentFactoryHelper { } /** - * Wrap the OLE2 data in the NPOIFSFileSystem into a decrypted stream by using + * Wrap the OLE2 data in the {@link POIFSFileSystem} into a decrypted stream by using * the given password. * * @param fs The OLE2 stream for the document @@ -48,7 +48,7 @@ public final class DocumentFactoryHelper { */ public static InputStream getDecryptedStream(final POIFSFileSystem fs, String password) throws IOException { - // wrap the stream in a FilterInputStream to close the NPOIFSFileSystem + // wrap the stream in a FilterInputStream to close the POIFSFileSystem // as well when the resulting OPCPackage is closed return new FilterInputStream(getDecryptedStream(fs.getRoot(), password)) { @Override diff --git a/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java b/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java index 8254b86d8a..cbb4ccba54 100644 --- a/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java +++ b/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java @@ -104,7 +104,7 @@ public class VBAMacroReader implements Closeable { while ((zipEntry = zis.getNextEntry()) != null) { if (endsWithIgnoreCase(zipEntry.getName(), VBA_PROJECT_OOXML)) { try { - // Make a NPOIFS from the contents, and close the stream + // Make a POIFSFileSystem from the contents, and close the stream this.fs = new POIFSFileSystem(zis); return; } catch (IOException e) { diff --git a/src/java/org/apache/poi/sl/usermodel/SlideShowFactory.java b/src/java/org/apache/poi/sl/usermodel/SlideShowFactory.java index 460e93bb23..bda928cfce 100644 --- a/src/java/org/apache/poi/sl/usermodel/SlideShowFactory.java +++ b/src/java/org/apache/poi/sl/usermodel/SlideShowFactory.java @@ -36,7 +36,7 @@ import org.apache.poi.util.IOUtils; public class SlideShowFactory { /** - * Creates a SlideShow from the given NPOIFSFileSystem. + * Creates a SlideShow from the given POIFSFileSystem. * * @param fs The {@link POIFSFileSystem} to read the document from * @@ -52,7 +52,7 @@ public class SlideShowFactory { } /** - * Creates a SlideShow from the given NPOIFSFileSystem, which may + * Creates a SlideShow from the given POIFSFileSystem, which may * be password protected * * @param fs The {@link POIFSFileSystem} to read the document from @@ -70,7 +70,7 @@ public class SlideShowFactory { } /** - * Creates a SlideShow from the given NPOIFSFileSystem. + * Creates a SlideShow from the given DirectoryNode. * * @param root The {@link DirectoryNode} to start reading the document from * @@ -87,7 +87,7 @@ public class SlideShowFactory { /** - * Creates a SlideShow from the given NPOIFSFileSystem, which may + * Creates a SlideShow from the given DirectoryNode, which may * be password protected * * @param root The {@link DirectoryNode} to start reading the document from diff --git a/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java b/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java index 45fa47d3ed..ca291a68a7 100644 --- a/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java +++ b/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java @@ -62,7 +62,7 @@ public class WorkbookFactory { } /** - * Creates a HSSFWorkbook from the given NPOIFSFileSystem

+ * Creates a HSSFWorkbook from the given POIFSFileSystem

* * Note that in order to properly release resources the * Workbook should be closed after use. @@ -78,7 +78,7 @@ public class WorkbookFactory { } /** - * Creates a Workbook from the given NPOIFSFileSystem, which may + * Creates a Workbook from the given POIFSFileSystem, which may * be password protected * * @param fs The {@link POIFSFileSystem} to read the document from @@ -94,7 +94,7 @@ public class WorkbookFactory { /** - * Creates a Workbook from the given NPOIFSFileSystem. + * Creates a Workbook from the given DirectoryNode. * * @param root The {@link DirectoryNode} to start reading the document from * @@ -108,7 +108,7 @@ public class WorkbookFactory { /** - * Creates a Workbook from the given NPOIFSFileSystem, which may + * Creates a Workbook from the given DirectoryNode, which may * be password protected * * @param root The {@link DirectoryNode} to start reading the document from diff --git a/src/ooxml/java/org/apache/poi/ooxml/extractor/ExtractorFactory.java b/src/ooxml/java/org/apache/poi/ooxml/extractor/ExtractorFactory.java index 412cacfeac..70360e64e5 100644 --- a/src/ooxml/java/org/apache/poi/ooxml/extractor/ExtractorFactory.java +++ b/src/ooxml/java/org/apache/poi/ooxml/extractor/ExtractorFactory.java @@ -404,7 +404,7 @@ public final class ExtractorFactory { } finally { IOUtils.closeQuietly(is); - // also close the NPOIFSFileSystem here as we read all the data + // also close the POIFSFileSystem here as we read all the data // while decrypting fs.close(); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index bdc9b6ddc8..683ad8a0e6 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -1505,7 +1505,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { @Test public void bug55692_stream() throws IOException { - // Directly on a Stream, will go via NPOIFS and spot it's + // Directly on a Stream, will go via POIFS and spot it's // actually a .xlsx file encrypted with the default password, and open Workbook wb = WorkbookFactory.create( POIDataSamples.getPOIFSInstance().openResourceAsStream("protect.xlsx")); @@ -1515,8 +1515,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { } @Test - public void bug55692_npoifs() throws IOException { - // Via a NPOIFSFileSystem, will spot it's actually a .xlsx file + public void bug55692_poifs2() throws IOException { + // Via a POIFSFileSystem, will spot it's actually a .xlsx file // encrypted with the default password, and open POIFSFileSystem fsNP = new POIFSFileSystem( POIDataSamples.getPOIFSInstance().openResourceAsStream("protect.xlsx")); diff --git a/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java b/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java index dc2ecc776a..6ae0663eb2 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java +++ b/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java @@ -117,7 +117,7 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor { /** * Creates a PowerPointExtractor, from a specific place - * inside an open NPOIFSFileSystem + * inside an open {@link POIFSFileSystem} * * @param dir the POIFS Directory containing the PowerPoint document */ diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java index 2343ccc489..5cc28e4f54 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java @@ -148,8 +148,8 @@ public final class HSLFSlideShow implements SlideShow + * Creates a HSLFSlideShow from the given {@link POIFSFileSystem}

* Note that in order to properly release resources the * SlideShow should be closed after use. */ diff --git a/src/scratchpad/testcases/org/apache/poi/hpbf/extractor/TestPublisherTextExtractor.java b/src/scratchpad/testcases/org/apache/poi/hpbf/extractor/TestPublisherTextExtractor.java index 06b7c98a81..c6353dae6d 100644 --- a/src/scratchpad/testcases/org/apache/poi/hpbf/extractor/TestPublisherTextExtractor.java +++ b/src/scratchpad/testcases/org/apache/poi/hpbf/extractor/TestPublisherTextExtractor.java @@ -98,11 +98,11 @@ public final class TestPublisherTextExtractor { // And with NPOIFS sample = _samples.openResourceAsStream("Sample.pub"); POIFSFileSystem fs = new POIFSFileSystem(sample); - HPBFDocument docNPOIFS = new HPBFDocument(fs); - ext = new PublisherTextExtractor(docNPOIFS); + HPBFDocument docPOIFS = new HPBFDocument(fs); + ext = new PublisherTextExtractor(docPOIFS); assertEquals(SAMPLE_TEXT, ext.getText()); ext.close(); - docNPOIFS.close(); + docPOIFS.close(); fs.close(); sample.close(); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java b/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java index 9fa47b4107..9cb01825e6 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java @@ -394,9 +394,9 @@ public final class TestExtractor { public void testDifferentPOIFS() throws IOException { // Open the two filesystems File pptFile = slTests.getFile("basic_test_ppt_file.ppt"); - try (final POIFSFileSystem npoifs = new POIFSFileSystem(pptFile, true)) { + try (final POIFSFileSystem poifs = new POIFSFileSystem(pptFile, true)) { // Open directly - try (SlideShow ppt = SlideShowFactory.create(npoifs.getRoot()); + try (SlideShow ppt = SlideShowFactory.create(poifs.getRoot()); SlideShowExtractor extractor = new SlideShowExtractor<>(ppt)) { assertEquals(EXPECTED_PAGE1+EXPECTED_PAGE2, extractor.getText()); } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java index f2a111ea3b..73756e5332 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java @@ -992,15 +992,15 @@ public final class TestBugs { //It isn't pretty, but it works... private Map getMacrosFromHSLF(String fileName) throws IOException { InputStream is = null; - POIFSFileSystem npoifs = null; + POIFSFileSystem poifs = null; try { is = new FileInputStream(POIDataSamples.getSlideShowInstance().getFile(fileName)); - npoifs = new POIFSFileSystem(is); - //TODO: should we run the VBAMacroReader on this npoifs? + poifs = new POIFSFileSystem(is); + //TODO: should we run the VBAMacroReader on this poifs? //TBD: We know that ppt typically don't store macros in the regular place, //but _can_ they? - HSLFSlideShow ppt = new HSLFSlideShow(npoifs); + HSLFSlideShow ppt = new HSLFSlideShow(poifs); //get macro persist id DocInfoListContainer list = (DocInfoListContainer)ppt.getDocumentRecord().findFirstOfType(RecordTypes.List.typeID); @@ -1018,7 +1018,7 @@ public final class TestBugs { ppt.close(); } finally { - IOUtils.closeQuietly(npoifs); + IOUtils.closeQuietly(poifs); IOUtils.closeQuietly(is); } return null; diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java b/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java index ea6fc3966e..5d919c7a15 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java @@ -343,9 +343,9 @@ public final class TestWordExtractor { public void testDifferentPOIFS() throws Exception { // Open the two filesystems File file = docTests.getFile("test2.doc"); - try (POIFSFileSystem npoifs = new POIFSFileSystem(file, true)) { + try (POIFSFileSystem poifs = new POIFSFileSystem(file, true)) { - DirectoryNode dir = npoifs.getRoot(); + DirectoryNode dir = poifs.getRoot(); // Open directly @SuppressWarnings("resource") diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java index bb42d77125..5495fa7d6a 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java @@ -606,7 +606,7 @@ public class TestBugs{ } /** - * [RESOLVED FIXED] Bug 51671 - HWPFDocument.write based on NPOIFSFileSystem + * [RESOLVED FIXED] Bug 51671 - HWPFDocument.write based on POIFSFileSystem * throws a NullPointerException */ @Test @@ -614,9 +614,9 @@ public class TestBugs{ { InputStream is = POIDataSamples.getDocumentInstance() .openResourceAsStream("empty.doc"); - try (POIFSFileSystem npoifsFileSystem = new POIFSFileSystem(is)) { + try (POIFSFileSystem poifsFileSystem = new POIFSFileSystem(is)) { HWPFDocument hwpfDocument = new HWPFDocument( - npoifsFileSystem.getRoot()); + poifsFileSystem.getRoot()); hwpfDocument.write(new ByteArrayOutputStream()); hwpfDocument.close(); } diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java index 8c57ffdd34..19504bd108 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java @@ -135,7 +135,7 @@ public final class TestHWPFWrite extends HWPFTestCase { } @Test(expected=IllegalStateException.class) - public void testInvalidInPlaceWriteNPOIFS() throws Exception { + public void testInvalidInPlaceWritePOIFS() throws Exception { // Can't work for Read-Only files POIFSFileSystem fs = new POIFSFileSystem(SAMPLES.getFile("SampleDoc.doc"), true); HWPFDocument doc = new HWPFDocument(fs.getRoot()); diff --git a/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java b/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java index 235ced3432..ff1fb0be45 100644 --- a/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java +++ b/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java @@ -495,11 +495,11 @@ public class TestWrite { } /** - * Tests that when using NPOIFS, we can do an in-place write + * Tests that when using POIFS, we can do an in-place write * without needing to stream in + out the whole kitchen sink */ @Test - public void inPlaceNPOIFSWrite() throws Exception { + public void inPlacePOIFSWrite() throws Exception { // We need to work on a File for in-place changes, so create a temp one final File copy = TempFile.createTempFile("Test-HPSF", "ole2"); copy.deleteOnExit(); diff --git a/src/testcases/org/apache/poi/hpsf/extractor/TestHPSFPropertiesExtractor.java b/src/testcases/org/apache/poi/hpsf/extractor/TestHPSFPropertiesExtractor.java index 47ecf04d7c..e510df94f8 100644 --- a/src/testcases/org/apache/poi/hpsf/extractor/TestHPSFPropertiesExtractor.java +++ b/src/testcases/org/apache/poi/hpsf/extractor/TestHPSFPropertiesExtractor.java @@ -183,9 +183,9 @@ public final class TestHPSFPropertiesExtractor { @Test public void test61300Extractor() throws IOException { - try (POIFSFileSystem npoifs = new POIFSFileSystem( + try (POIFSFileSystem poifs = new POIFSFileSystem( POIDataSamples.getPOIFSInstance().getFile("61300.bin"))) { - HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(npoifs); + HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(poifs); assertContains(ext.getText(), "PID_CODEPAGE = 1252"); } } diff --git a/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java b/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java index 323b59fcb9..acfc68cfc8 100644 --- a/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java +++ b/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java @@ -283,7 +283,7 @@ public final class TestOldExcelExtractor { } @Test - public void testNPOIFSFileSystem() throws IOException { + public void testPOIFSFileSystem() throws IOException { File file = HSSFTestDataSamples.getSampleFile("FormulaRefs.xls"); try (POIFSFileSystem fs = new POIFSFileSystem(file)) { OldExcelExtractor extractor = new OldExcelExtractor(fs); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index 7153e3f859..9d9c277def 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -2331,34 +2331,29 @@ public final class TestBugs extends BaseTestBugzillaIssues { * File with exactly 256 data blocks (+header block) * shouldn't break on POIFS loading */ - @SuppressWarnings("resource") @Test public void bug51461() throws Exception { byte[] data = HSSFITestDataProvider.instance.getTestDataFileContent("51461.xls"); HSSFWorkbook wbPOIFS = new HSSFWorkbook(new POIFSFileSystem( new ByteArrayInputStream(data)).getRoot(), false); - HSSFWorkbook wbNPOIFS = new HSSFWorkbook(new POIFSFileSystem( + HSSFWorkbook wbPOIFS2 = new HSSFWorkbook(new POIFSFileSystem( new ByteArrayInputStream(data)).getRoot(), false); assertEquals(2, wbPOIFS.getNumberOfSheets()); - assertEquals(2, wbNPOIFS.getNumberOfSheets()); + assertEquals(2, wbPOIFS2.getNumberOfSheets()); } - /** - * Large row numbers and NPOIFS vs POIFS - */ - @SuppressWarnings("resource") @Test public void bug51535() throws Exception { byte[] data = HSSFITestDataProvider.instance.getTestDataFileContent("51535.xls"); HSSFWorkbook wbPOIFS = new HSSFWorkbook(new POIFSFileSystem( new ByteArrayInputStream(data)).getRoot(), false); - HSSFWorkbook wbNPOIFS = new HSSFWorkbook(new POIFSFileSystem( + HSSFWorkbook wbPOIFS2 = new HSSFWorkbook(new POIFSFileSystem( new ByteArrayInputStream(data)).getRoot(), false); - for (HSSFWorkbook wb : new HSSFWorkbook[]{wbPOIFS, wbNPOIFS}) { + for (HSSFWorkbook wb : new HSSFWorkbook[]{wbPOIFS, wbPOIFS2}) { assertEquals(3, wb.getNumberOfSheets()); // Check directly @@ -3095,10 +3090,10 @@ public final class TestBugs extends BaseTestBugzillaIssues { @Test(expected = RuntimeException.class) public void test61300() throws Exception { - POIFSFileSystem npoifs = new POIFSFileSystem(HSSFTestDataSamples.openSampleFileStream("61300.xls")); + POIFSFileSystem poifs = new POIFSFileSystem(HSSFTestDataSamples.openSampleFileStream("61300.xls")); DocumentEntry entry = - (DocumentEntry) npoifs.getRoot().getEntry(SummaryInformation.DEFAULT_STREAM_NAME); + (DocumentEntry) poifs.getRoot().getEntry(SummaryInformation.DEFAULT_STREAM_NAME); // this will throw an Exception "RuntimeException: Can't read negative number of bytes" new PropertySet(new DocumentInputStream(entry)); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java index 0167ccc3d0..e3f4aeaef2 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java @@ -621,8 +621,8 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook { DirectoryNode[] files = new DirectoryNode[2]; try (POIFSFileSystem poifsFileSystem = new POIFSFileSystem(HSSFTestDataSamples.openSampleFileStream("Simple.xls"))) { files[0] = poifsFileSystem.getRoot(); - try (POIFSFileSystem npoifsFileSystem = new POIFSFileSystem(HSSFTestDataSamples.getSampleFile("Simple.xls"))) { - files[1] = npoifsFileSystem.getRoot(); + try (POIFSFileSystem poifsFileSystem2 = new POIFSFileSystem(HSSFTestDataSamples.getSampleFile("Simple.xls"))) { + files[1] = poifsFileSystem2.getRoot(); // Open without preserving nodes for (DirectoryNode dir : files) { @@ -653,8 +653,8 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook { DirectoryNode[] files = new DirectoryNode[2]; try (POIFSFileSystem poifsFileSystem = new POIFSFileSystem(HSSFTestDataSamples.openSampleFileStream("WithEmbeddedObjects.xls"))) { files[0] = poifsFileSystem.getRoot(); - try (POIFSFileSystem npoifsFileSystem = new POIFSFileSystem(HSSFTestDataSamples.getSampleFile("WithEmbeddedObjects.xls"))) { - files[1] = npoifsFileSystem.getRoot(); + try (POIFSFileSystem poifsFileSystem2 = new POIFSFileSystem(HSSFTestDataSamples.getSampleFile("WithEmbeddedObjects.xls"))) { + files[1] = poifsFileSystem2.getRoot(); // Check the embedded parts for (DirectoryNode root : files) { @@ -682,19 +682,18 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook { } /** - * Checks that we can open a workbook with NPOIFS, and write it out + * Checks that we can open a workbook with POIFS, and write it out * again (via POIFS) and have it be valid */ @Test - public void writeWorkbookFromNPOIFS() throws IOException { + public void writeWorkbookFromPOIFS() throws IOException { try (InputStream is = HSSFTestDataSamples.openSampleFileStream("WithEmbeddedObjects.xls"); - POIFSFileSystem fs = new POIFSFileSystem(is)) { - // Start as NPOIFS + POIFSFileSystem fs = new POIFSFileSystem(is)) { + HSSFWorkbook wb = new HSSFWorkbook(fs.getRoot(), true); assertEquals(3, wb.getNumberOfSheets()); assertEquals("Root xls", wb.getSheetAt(0).getRow(0).getCell(0).getStringCellValue()); - // Will switch to POIFS HSSFWorkbook wbBack = HSSFTestDataSamples.writeOutAndReadBack(wb); assertEquals(3, wbBack.getNumberOfSheets()); assertEquals("Root xls", wbBack.getSheetAt(0).getRow(0).getCell(0).getStringCellValue()); @@ -1151,11 +1150,7 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook { final File file = POIDataSamples.getSpreadSheetInstance().getFile(filename); Workbook wb; - // File via POIFileStream (java.io) - wb = new HSSFWorkbook(new POIFSFileSystem(file)); - assertCloseDoesNotModifyFile(filename, wb); - - // File via NPOIFileStream (java.nio) + // File via POIFileStream (java.nio) wb = new HSSFWorkbook(new POIFSFileSystem(file)); assertCloseDoesNotModifyFile(filename, wb); diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java b/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java index 6ca6f614d9..59839672e3 100644 --- a/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java +++ b/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java @@ -43,7 +43,7 @@ public class TestDocument { * Integration test -- really about all we can do */ @Test - public void testNPOIFSDocument() throws IOException { + public void testPOIFSDocument() throws IOException { try (POIFSFileSystem poifs = new POIFSFileSystem()) { diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java b/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java index 6f14705685..ba03fcaf69 100644 --- a/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java +++ b/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java @@ -55,20 +55,20 @@ public final class TestDocumentInputStream { _workbook_data[j] = (byte) (j * j); } - // Now create the NPOIFS Version + // Now create the POIFS Version byte[] _workbook_data_only = new byte[_workbook_size]; System.arraycopy(_workbook_data, 0, _workbook_data_only, 0, _workbook_size); - POIFSFileSystem npoifs = new POIFSFileSystem(); + POIFSFileSystem poifs = new POIFSFileSystem(); // Make it easy when debugging to see what isn't the doc byte[] minus1 = new byte[512]; Arrays.fill(minus1, (byte) -1); - npoifs.getBlockAt(-1).put(minus1); - npoifs.getBlockAt(0).put(minus1); - npoifs.getBlockAt(1).put(minus1); + poifs.getBlockAt(-1).put(minus1); + poifs.getBlockAt(0).put(minus1); + poifs.getBlockAt(1).put(minus1); - // Create the NPOIFS document - _workbook_n = (DocumentNode) npoifs.createDocument( + // Create the POIFS document + _workbook_n = (DocumentNode) poifs.createDocument( new ByteArrayInputStream(_workbook_data_only), "Workbook" ); @@ -440,12 +440,12 @@ public final class TestDocumentInputStream { DocumentInputStream stream; - try (POIFSFileSystem npoifs = new POIFSFileSystem(sample)) { + try (POIFSFileSystem poifs = new POIFSFileSystem(sample)) { // Ensure we have what we expect on the root - assertEquals(npoifs, npoifs.getRoot().getFileSystem()); + assertEquals(poifs, poifs.getRoot().getFileSystem()); // Check inside - DirectoryNode root = npoifs.getRoot(); + DirectoryNode root = poifs.getRoot(); // Top Level Entry top = root.getEntry("Contents"); assertTrue(top.isDocumentEntry()); diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestEntryUtils.java b/src/testcases/org/apache/poi/poifs/filesystem/TestEntryUtils.java index adb6cabe4f..7dca078a3e 100644 --- a/src/testcases/org/apache/poi/poifs/filesystem/TestEntryUtils.java +++ b/src/testcases/org/apache/poi/poifs/filesystem/TestEntryUtils.java @@ -123,7 +123,7 @@ public class TestEntryUtils { assertTrue(EntryUtils.areDocumentsIdentical(entryA1, entryB1)); - // Can work with NPOIFS + POIFS + // Can work with POIFS ByteArrayOutputStream tmpO = new ByteArrayOutputStream(); fs.writeFilesystem(tmpO); diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java b/src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java index dc220d7f40..128a86aadc 100644 --- a/src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java +++ b/src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java @@ -34,7 +34,7 @@ import org.junit.After; import org.junit.Test; /** - * Tests bugs across both POIFSFileSystem and NPOIFSFileSystem + * Tests bugs for POIFSFileSystem */ public final class TestFileSystemBugs { private static POIDataSamples _samples = POIDataSamples.getPOIFSInstance(); @@ -115,7 +115,7 @@ public final class TestFileSystemBugs { * Ensure that a file with a corrupted property in the * properties table can still be loaded, and the remaining * properties used - * Note - only works for NPOIFSFileSystem, POIFSFileSystem + * Note - only works for POIFSFileSystem * can't cope with this level of corruption */ @Test diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSStream.java b/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSStream.java index eb88186a8e..0f0eeba31f 100644 --- a/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSStream.java +++ b/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSStream.java @@ -2605,11 +2605,11 @@ public final class TestPOIFSStream { } /** - * Test that we can read a file with NPOIFS, create a new NPOIFS instance, + * Test that we can read a file with POIFS, create a new POIFS instance, * write it out, read it with POIFS, and see the original data */ @Test - public void NPOIFSReadCopyWritePOIFSRead() throws IOException { + public void POIFSReadCopyWritePOIFSRead() throws IOException { File testFile = POIDataSamples.getSpreadSheetInstance().getFile("Simple.xls"); POIFSFileSystem src = new POIFSFileSystem(testFile); byte[] wbDataExp = IOUtils.toByteArray(src.createDocumentInputStream("Workbook")); diff --git a/src/testcases/org/apache/poi/poifs/macros/TestVBAMacroReader.java b/src/testcases/org/apache/poi/poifs/macros/TestVBAMacroReader.java index c6853f156c..caf1222359 100644 --- a/src/testcases/org/apache/poi/poifs/macros/TestVBAMacroReader.java +++ b/src/testcases/org/apache/poi/poifs/macros/TestVBAMacroReader.java @@ -148,24 +148,24 @@ public class TestVBAMacroReader { fromFile(POIDataSamples.getDiagramInstance(), "SimpleMacro.vsdm"); } - //////////////////////////////// From NPOIFS ///////////////////////////// + //////////////////////////////// From POIFS ///////////////////////////// @Test - public void HSSFFromNPOIFS() throws Exception { - fromNPOIFS(POIDataSamples.getSpreadSheetInstance(), "SimpleMacro.xls"); + public void HSSFFromPOIFS() throws Exception { + fromPOIFS(POIDataSamples.getSpreadSheetInstance(), "SimpleMacro.xls"); } @Ignore("bug 59302: Found 0 macros") @Test - public void HSLFFromNPOIFS() throws Exception { - fromNPOIFS(POIDataSamples.getSlideShowInstance(), "SimpleMacro.ppt"); + public void HSLFFromPOIFS() throws Exception { + fromPOIFS(POIDataSamples.getSlideShowInstance(), "SimpleMacro.ppt"); } @Test - public void HWPFFromNPOIFS() throws Exception { - fromNPOIFS(POIDataSamples.getDocumentInstance(), "SimpleMacro.doc"); + public void HWPFFromPOIFS() throws Exception { + fromPOIFS(POIDataSamples.getDocumentInstance(), "SimpleMacro.doc"); } @Ignore("Found 0 macros") @Test - public void HDGFFromNPOIFS() throws Exception { - fromNPOIFS(POIDataSamples.getDiagramInstance(), "SimpleMacro.vsd"); + public void HDGFFromPOIFS() throws Exception { + fromPOIFS(POIDataSamples.getDiagramInstance(), "SimpleMacro.vsd"); } private void fromFile(POIDataSamples dataSamples, String filename) throws IOException { @@ -183,7 +183,7 @@ public class TestVBAMacroReader { } } - private void fromNPOIFS(POIDataSamples dataSamples, String filename) throws IOException { + private void fromPOIFS(POIDataSamples dataSamples, String filename) throws IOException { File f = dataSamples.getFile(filename); try (POIFSFileSystem fs = new POIFSFileSystem(f)) { try (VBAMacroReader r = new VBAMacroReader(fs)) { diff --git a/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShowFactory.java b/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShowFactory.java index 702c0e845c..d62d787d94 100644 --- a/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShowFactory.java +++ b/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShowFactory.java @@ -55,12 +55,12 @@ public abstract class BaseTestSlideShowFactory { @SuppressWarnings("resource") protected static void testFactoryFromNative(String file) throws Exception { SlideShow ss; - // from NPOIFS + // from POIFS if (file.endsWith(".ppt")) { - POIFSFileSystem npoifs = new POIFSFileSystem(fromFile(file)); - ss = SlideShowFactory.create(npoifs); + POIFSFileSystem poifs = new POIFSFileSystem(fromFile(file)); + ss = SlideShowFactory.create(poifs); assertNotNull(ss); - npoifs.close(); + poifs.close(); assertCloseDoesNotModifyFile(file, ss); } // from OPCPackage @@ -92,15 +92,15 @@ public abstract class BaseTestSlideShowFactory { @SuppressWarnings("resource") protected static void testFactoryFromProtectedNative(String protectedFile, String password) throws Exception { SlideShow ss; - // Encryption layer is a BIFF8 binary format that can be read by NPOIFSFileSystem, + // Encryption layer is a BIFF8 binary format that can be read by POIFSFileSystem, // used for both HSLF and XSLF - // from protected NPOIFS + // from protected POIFS if (protectedFile.endsWith(".ppt") || protectedFile.endsWith(".pptx")) { - POIFSFileSystem npoifs = new POIFSFileSystem(fromFile(protectedFile)); - ss = SlideShowFactory.create(npoifs, password); + POIFSFileSystem poifs = new POIFSFileSystem(fromFile(protectedFile)); + ss = SlideShowFactory.create(poifs, password); assertNotNull(ss); - npoifs.close(); + poifs.close(); assertCloseDoesNotModifyFile(protectedFile, ss); } else { -- 2.39.5