#56791 Make NPOIFS the default when POIFSFileSystem is requested
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1681804 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b8d9c978ad
commit
b2d1c1b6ac
@ -145,14 +145,15 @@ public class DirectoryNode
|
||||
|
||||
/**
|
||||
* @return the filesystem that this belongs to
|
||||
* TODO Temporary workaround during #56791
|
||||
*/
|
||||
public POIFSFileSystem getFileSystem()
|
||||
public NPOIFSFileSystem getFileSystem()
|
||||
{
|
||||
return (POIFSFileSystem)_ofilesystem;
|
||||
return _nfilesystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is OPOIFS based, return the NPOIFSFileSystem
|
||||
* that this belong to, otherwise Null if NPOIFS based
|
||||
* @return the filesystem that this belongs to
|
||||
*/
|
||||
public OPOIFSFileSystem getOFileSystem()
|
||||
@ -161,6 +162,8 @@ public class DirectoryNode
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is NPOIFS based, return the NPOIFSFileSystem
|
||||
* that this belong to, otherwise Null if OPOIFS based
|
||||
* @return the filesystem that this belongs to
|
||||
*/
|
||||
public NPOIFSFileSystem getNFileSystem()
|
||||
|
@ -32,7 +32,7 @@ import org.apache.poi.util.CloseIgnoringInputStream;
|
||||
*/
|
||||
|
||||
public class POIFSFileSystem
|
||||
extends OPOIFSFileSystem // TODO Temporary workaround during #56791
|
||||
extends NPOIFSFileSystem // TODO Temporary workaround during #56791
|
||||
implements POIFSViewable
|
||||
{
|
||||
/**
|
||||
@ -95,14 +95,14 @@ public class POIFSFileSystem
|
||||
* @param inp An InputStream which supports either mark/reset, or is a PushbackInputStream
|
||||
*/
|
||||
public static boolean hasPOIFSHeader(InputStream inp) throws IOException {
|
||||
return OPOIFSFileSystem.hasPOIFSHeader(inp);
|
||||
return NPOIFSFileSystem.hasPOIFSHeader(inp);
|
||||
}
|
||||
/**
|
||||
* Checks if the supplied first 8 bytes of a stream / file
|
||||
* has a POIFS (OLE2) header.
|
||||
*/
|
||||
public static boolean hasPOIFSHeader(byte[] header8Bytes) {
|
||||
return OPOIFSFileSystem.hasPOIFSHeader(header8Bytes);
|
||||
return NPOIFSFileSystem.hasPOIFSHeader(header8Bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,10 +31,7 @@ import org.apache.poi.poifs.storage.RawDataBlock;
|
||||
|
||||
/**
|
||||
* Class to test DocumentInputStream functionality
|
||||
*
|
||||
* @author Marc Johnson
|
||||
*/
|
||||
|
||||
public final class TestDocumentInputStream extends TestCase {
|
||||
private DocumentNode _workbook_n;
|
||||
private DocumentNode _workbook_o;
|
||||
@ -95,7 +92,7 @@ public final class TestDocumentInputStream extends TestCase {
|
||||
* test constructor
|
||||
*/
|
||||
public void testConstructor() throws IOException {
|
||||
DocumentInputStream ostream = new DocumentInputStream(_workbook_o);
|
||||
DocumentInputStream ostream = new ODocumentInputStream(_workbook_o);
|
||||
DocumentInputStream nstream = new NDocumentInputStream(_workbook_n);
|
||||
|
||||
assertEquals(_workbook_size, _workbook_o.getSize());
|
||||
@ -103,6 +100,9 @@ public final class TestDocumentInputStream extends TestCase {
|
||||
|
||||
assertEquals(_workbook_size, ostream.available());
|
||||
assertEquals(_workbook_size, nstream.available());
|
||||
|
||||
ostream.close();
|
||||
nstream.close();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -514,12 +514,14 @@ public final class TestDocumentInputStream extends TestCase {
|
||||
|
||||
NPOIFSFileSystem npoifs = new NPOIFSFileSystem(sample);
|
||||
try {
|
||||
POIFSFileSystem opoifs = new POIFSFileSystem(new FileInputStream(sample));
|
||||
OPOIFSFileSystem opoifs = new OPOIFSFileSystem(new FileInputStream(sample));
|
||||
|
||||
// Ensure we have what we expect on the root
|
||||
assertEquals(npoifs, npoifs.getRoot().getNFileSystem());
|
||||
assertEquals(null, npoifs.getRoot().getFileSystem());
|
||||
assertEquals(opoifs, opoifs.getRoot().getFileSystem());
|
||||
assertEquals(npoifs, npoifs.getRoot().getFileSystem());
|
||||
assertEquals(null, npoifs.getRoot().getOFileSystem());
|
||||
assertEquals(null, opoifs.getRoot().getFileSystem());
|
||||
assertEquals(opoifs, opoifs.getRoot().getOFileSystem());
|
||||
assertEquals(null, opoifs.getRoot().getNFileSystem());
|
||||
|
||||
// Check inside
|
||||
|
Loading…
Reference in New Issue
Block a user