mirror of https://github.com/apache/poi.git
#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
9b20ef64bc
commit
650bb1b8cb
|
@ -145,14 +145,15 @@ public class DirectoryNode
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the filesystem that this belongs to
|
* @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
|
* @return the filesystem that this belongs to
|
||||||
*/
|
*/
|
||||||
public OPOIFSFileSystem getOFileSystem()
|
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
|
* @return the filesystem that this belongs to
|
||||||
*/
|
*/
|
||||||
public NPOIFSFileSystem getNFileSystem()
|
public NPOIFSFileSystem getNFileSystem()
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.apache.poi.util.CloseIgnoringInputStream;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class POIFSFileSystem
|
public class POIFSFileSystem
|
||||||
extends OPOIFSFileSystem // TODO Temporary workaround during #56791
|
extends NPOIFSFileSystem // TODO Temporary workaround during #56791
|
||||||
implements POIFSViewable
|
implements POIFSViewable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -95,14 +95,14 @@ public class POIFSFileSystem
|
||||||
* @param inp An InputStream which supports either mark/reset, or is a PushbackInputStream
|
* @param inp An InputStream which supports either mark/reset, or is a PushbackInputStream
|
||||||
*/
|
*/
|
||||||
public static boolean hasPOIFSHeader(InputStream inp) throws IOException {
|
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
|
* Checks if the supplied first 8 bytes of a stream / file
|
||||||
* has a POIFS (OLE2) header.
|
* has a POIFS (OLE2) header.
|
||||||
*/
|
*/
|
||||||
public static boolean hasPOIFSHeader(byte[] header8Bytes) {
|
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
|
* Class to test DocumentInputStream functionality
|
||||||
*
|
|
||||||
* @author Marc Johnson
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public final class TestDocumentInputStream extends TestCase {
|
public final class TestDocumentInputStream extends TestCase {
|
||||||
private DocumentNode _workbook_n;
|
private DocumentNode _workbook_n;
|
||||||
private DocumentNode _workbook_o;
|
private DocumentNode _workbook_o;
|
||||||
|
@ -95,7 +92,7 @@ public final class TestDocumentInputStream extends TestCase {
|
||||||
* test constructor
|
* test constructor
|
||||||
*/
|
*/
|
||||||
public void testConstructor() throws IOException {
|
public void testConstructor() throws IOException {
|
||||||
DocumentInputStream ostream = new DocumentInputStream(_workbook_o);
|
DocumentInputStream ostream = new ODocumentInputStream(_workbook_o);
|
||||||
DocumentInputStream nstream = new NDocumentInputStream(_workbook_n);
|
DocumentInputStream nstream = new NDocumentInputStream(_workbook_n);
|
||||||
|
|
||||||
assertEquals(_workbook_size, _workbook_o.getSize());
|
assertEquals(_workbook_size, _workbook_o.getSize());
|
||||||
|
@ -103,6 +100,9 @@ public final class TestDocumentInputStream extends TestCase {
|
||||||
|
|
||||||
assertEquals(_workbook_size, ostream.available());
|
assertEquals(_workbook_size, ostream.available());
|
||||||
assertEquals(_workbook_size, nstream.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);
|
NPOIFSFileSystem npoifs = new NPOIFSFileSystem(sample);
|
||||||
try {
|
try {
|
||||||
POIFSFileSystem opoifs = new POIFSFileSystem(new FileInputStream(sample));
|
OPOIFSFileSystem opoifs = new OPOIFSFileSystem(new FileInputStream(sample));
|
||||||
|
|
||||||
// Ensure we have what we expect on the root
|
// Ensure we have what we expect on the root
|
||||||
assertEquals(npoifs, npoifs.getRoot().getNFileSystem());
|
assertEquals(npoifs, npoifs.getRoot().getNFileSystem());
|
||||||
assertEquals(null, npoifs.getRoot().getFileSystem());
|
assertEquals(npoifs, npoifs.getRoot().getFileSystem());
|
||||||
assertEquals(opoifs, opoifs.getRoot().getFileSystem());
|
assertEquals(null, npoifs.getRoot().getOFileSystem());
|
||||||
|
assertEquals(null, opoifs.getRoot().getFileSystem());
|
||||||
|
assertEquals(opoifs, opoifs.getRoot().getOFileSystem());
|
||||||
assertEquals(null, opoifs.getRoot().getNFileSystem());
|
assertEquals(null, opoifs.getRoot().getNFileSystem());
|
||||||
|
|
||||||
// Check inside
|
// Check inside
|
||||||
|
|
Loading…
Reference in New Issue