mirror of https://github.com/apache/poi.git
Don't create separate instances for NullFileHandler, but rather use a common static instance
This can save some memory during regression testing. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1875268 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
260fec1a8b
commit
e807eed528
|
@ -139,7 +139,7 @@ public class POIFileScanner {
|
||||||
}
|
}
|
||||||
} catch (IOException | RuntimeException e2) {
|
} catch (IOException | RuntimeException e2) {
|
||||||
System.out.println("Could not open POIFSFileSystem for OLE2 file " + testFile + ": " + e + " and " + e2);
|
System.out.println("Could not open POIFSFileSystem for OLE2 file " + testFile + ": " + e + " and " + e2);
|
||||||
return new TestAllFiles.NullFileHandler();
|
return TestAllFiles.NullFileHandler.instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ public class POIFileScanner {
|
||||||
}
|
}
|
||||||
} catch (IOException | RuntimeException e2) {
|
} catch (IOException | RuntimeException e2) {
|
||||||
System.out.println("Could not open POIFSFileSystem for OOXML file " + testFile + ": " + e + " and " + e2);
|
System.out.println("Could not open POIFSFileSystem for OOXML file " + testFile + ": " + e + " and " + e2);
|
||||||
return new TestAllFiles.NullFileHandler();
|
return TestAllFiles.NullFileHandler.instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,12 +168,12 @@ public class POIFileScanner {
|
||||||
case RTF:
|
case RTF:
|
||||||
case PDF:
|
case PDF:
|
||||||
case HTML:
|
case HTML:
|
||||||
return new TestAllFiles.NullFileHandler();
|
return TestAllFiles.NullFileHandler.instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Did not get a handler for extension " + TestAllFiles.getExtension(file) +
|
System.out.println("Did not get a handler for extension " + TestAllFiles.getExtension(file) +
|
||||||
" of file " + file + ": " + magic);
|
" of file " + file + ": " + magic);
|
||||||
return new TestAllFiles.NullFileHandler();
|
return TestAllFiles.NullFileHandler.instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
|
|
|
@ -146,8 +146,8 @@ public class TestAllFiles {
|
||||||
HANDLERS.put(".vstx", new XDGFFileHandler());
|
HANDLERS.put(".vstx", new XDGFFileHandler());
|
||||||
|
|
||||||
// Visio - not handled yet
|
// Visio - not handled yet
|
||||||
HANDLERS.put(".vst", new NullFileHandler());
|
HANDLERS.put(".vst", NullFileHandler.instance);
|
||||||
HANDLERS.put(".vss", new NullFileHandler());
|
HANDLERS.put(".vss", NullFileHandler.instance);
|
||||||
|
|
||||||
// POIFS
|
// POIFS
|
||||||
HANDLERS.put(".ole2", new POIFSFileHandler());
|
HANDLERS.put(".ole2", new POIFSFileHandler());
|
||||||
|
@ -159,65 +159,65 @@ public class TestAllFiles {
|
||||||
HANDLERS.put(".dat", IGNORE_SCRATCHPAD ? new HPSFFileHandler() : new HMEFFileHandler());
|
HANDLERS.put(".dat", IGNORE_SCRATCHPAD ? new HPSFFileHandler() : new HMEFFileHandler());
|
||||||
|
|
||||||
// TODO: are these readable by some of the formats?
|
// TODO: are these readable by some of the formats?
|
||||||
HANDLERS.put(".wri", new NullFileHandler());
|
HANDLERS.put(".wri", NullFileHandler.instance);
|
||||||
HANDLERS.put(".shw", new NullFileHandler());
|
HANDLERS.put(".shw", NullFileHandler.instance);
|
||||||
HANDLERS.put(".zvi", new NullFileHandler());
|
HANDLERS.put(".zvi", NullFileHandler.instance);
|
||||||
HANDLERS.put(".mpp", new NullFileHandler());
|
HANDLERS.put(".mpp", NullFileHandler.instance);
|
||||||
HANDLERS.put(".qwp", new NullFileHandler());
|
HANDLERS.put(".qwp", NullFileHandler.instance);
|
||||||
HANDLERS.put(".wps", new NullFileHandler());
|
HANDLERS.put(".wps", NullFileHandler.instance);
|
||||||
HANDLERS.put(".bin", new NullFileHandler());
|
HANDLERS.put(".bin", NullFileHandler.instance);
|
||||||
HANDLERS.put(".xps", new NullFileHandler());
|
HANDLERS.put(".xps", NullFileHandler.instance);
|
||||||
HANDLERS.put(".sldprt", new NullFileHandler());
|
HANDLERS.put(".sldprt", NullFileHandler.instance);
|
||||||
HANDLERS.put(".mdb", new NullFileHandler());
|
HANDLERS.put(".mdb", NullFileHandler.instance);
|
||||||
HANDLERS.put(".vml", new NullFileHandler());
|
HANDLERS.put(".vml", NullFileHandler.instance);
|
||||||
|
|
||||||
// ignore some file types, images, other formats, ...
|
// ignore some file types, images, other formats, ...
|
||||||
HANDLERS.put(".txt", new NullFileHandler());
|
HANDLERS.put(".txt", NullFileHandler.instance);
|
||||||
HANDLERS.put(".pdf", new NullFileHandler());
|
HANDLERS.put(".pdf", NullFileHandler.instance);
|
||||||
HANDLERS.put(".rtf", new NullFileHandler());
|
HANDLERS.put(".rtf", NullFileHandler.instance);
|
||||||
HANDLERS.put(".gif", new NullFileHandler());
|
HANDLERS.put(".gif", NullFileHandler.instance);
|
||||||
HANDLERS.put(".html", new NullFileHandler());
|
HANDLERS.put(".html", NullFileHandler.instance);
|
||||||
HANDLERS.put(".png", new NullFileHandler());
|
HANDLERS.put(".png", NullFileHandler.instance);
|
||||||
HANDLERS.put(".wmf", new NullFileHandler());
|
HANDLERS.put(".wmf", NullFileHandler.instance);
|
||||||
HANDLERS.put(".emf", new NullFileHandler());
|
HANDLERS.put(".emf", NullFileHandler.instance);
|
||||||
HANDLERS.put(".dib", new NullFileHandler());
|
HANDLERS.put(".dib", NullFileHandler.instance);
|
||||||
HANDLERS.put(".svg", new NullFileHandler());
|
HANDLERS.put(".svg", NullFileHandler.instance);
|
||||||
HANDLERS.put(".pict", new NullFileHandler());
|
HANDLERS.put(".pict", NullFileHandler.instance);
|
||||||
HANDLERS.put(".jpg", new NullFileHandler());
|
HANDLERS.put(".jpg", NullFileHandler.instance);
|
||||||
HANDLERS.put(".jpeg", new NullFileHandler());
|
HANDLERS.put(".jpeg", NullFileHandler.instance);
|
||||||
HANDLERS.put(".tif", new NullFileHandler());
|
HANDLERS.put(".tif", NullFileHandler.instance);
|
||||||
HANDLERS.put(".tiff", new NullFileHandler());
|
HANDLERS.put(".tiff", NullFileHandler.instance);
|
||||||
HANDLERS.put(".wav", new NullFileHandler());
|
HANDLERS.put(".wav", NullFileHandler.instance);
|
||||||
HANDLERS.put(".xml", new NullFileHandler());
|
HANDLERS.put(".xml", NullFileHandler.instance);
|
||||||
HANDLERS.put(".csv", new NullFileHandler());
|
HANDLERS.put(".csv", NullFileHandler.instance);
|
||||||
HANDLERS.put(".ods", new NullFileHandler());
|
HANDLERS.put(".ods", NullFileHandler.instance);
|
||||||
HANDLERS.put(".ttf", new NullFileHandler());
|
HANDLERS.put(".ttf", NullFileHandler.instance);
|
||||||
HANDLERS.put(".fntdata", new NullFileHandler());
|
HANDLERS.put(".fntdata", NullFileHandler.instance);
|
||||||
// VBA source files
|
// VBA source files
|
||||||
HANDLERS.put(".vba", new NullFileHandler());
|
HANDLERS.put(".vba", NullFileHandler.instance);
|
||||||
HANDLERS.put(".bas", new NullFileHandler());
|
HANDLERS.put(".bas", NullFileHandler.instance);
|
||||||
HANDLERS.put(".frm", new NullFileHandler());
|
HANDLERS.put(".frm", NullFileHandler.instance);
|
||||||
HANDLERS.put(".frx", new NullFileHandler()); //binary
|
HANDLERS.put(".frx", NullFileHandler.instance); //binary
|
||||||
HANDLERS.put(".cls", new NullFileHandler());
|
HANDLERS.put(".cls", NullFileHandler.instance);
|
||||||
|
|
||||||
// map some files without extension
|
// map some files without extension
|
||||||
HANDLERS.put("spreadsheet/BigSSTRecord", new NullFileHandler());
|
HANDLERS.put("spreadsheet/BigSSTRecord", NullFileHandler.instance);
|
||||||
HANDLERS.put("spreadsheet/BigSSTRecord2", new NullFileHandler());
|
HANDLERS.put("spreadsheet/BigSSTRecord2", NullFileHandler.instance);
|
||||||
HANDLERS.put("spreadsheet/BigSSTRecord2CR1", new NullFileHandler());
|
HANDLERS.put("spreadsheet/BigSSTRecord2CR1", NullFileHandler.instance);
|
||||||
HANDLERS.put("spreadsheet/BigSSTRecord2CR2", new NullFileHandler());
|
HANDLERS.put("spreadsheet/BigSSTRecord2CR2", NullFileHandler.instance);
|
||||||
HANDLERS.put("spreadsheet/BigSSTRecord2CR3", new NullFileHandler());
|
HANDLERS.put("spreadsheet/BigSSTRecord2CR3", NullFileHandler.instance);
|
||||||
HANDLERS.put("spreadsheet/BigSSTRecord2CR4", new NullFileHandler());
|
HANDLERS.put("spreadsheet/BigSSTRecord2CR4", NullFileHandler.instance);
|
||||||
HANDLERS.put("spreadsheet/BigSSTRecord2CR5", new NullFileHandler());
|
HANDLERS.put("spreadsheet/BigSSTRecord2CR5", NullFileHandler.instance);
|
||||||
HANDLERS.put("spreadsheet/BigSSTRecord2CR6", new NullFileHandler());
|
HANDLERS.put("spreadsheet/BigSSTRecord2CR6", NullFileHandler.instance);
|
||||||
HANDLERS.put("spreadsheet/BigSSTRecord2CR7", new NullFileHandler());
|
HANDLERS.put("spreadsheet/BigSSTRecord2CR7", NullFileHandler.instance);
|
||||||
HANDLERS.put("spreadsheet/BigSSTRecordCR", new NullFileHandler());
|
HANDLERS.put("spreadsheet/BigSSTRecordCR", NullFileHandler.instance);
|
||||||
HANDLERS.put("spreadsheet/test_properties1", new NullFileHandler());
|
HANDLERS.put("spreadsheet/test_properties1", NullFileHandler.instance);
|
||||||
|
|
||||||
// keystore files
|
// keystore files
|
||||||
HANDLERS.put(".pfx", new NullFileHandler());
|
HANDLERS.put(".pfx", NullFileHandler.instance);
|
||||||
HANDLERS.put(".pem", new NullFileHandler());
|
HANDLERS.put(".pem", NullFileHandler.instance);
|
||||||
HANDLERS.put(".jks", new NullFileHandler());
|
HANDLERS.put(".jks", NullFileHandler.instance);
|
||||||
HANDLERS.put(".pkcs12", new NullFileHandler());
|
HANDLERS.put(".pkcs12", NullFileHandler.instance);
|
||||||
|
|
||||||
Map<String,String> passmap = new HashMap<>();
|
Map<String,String> passmap = new HashMap<>();
|
||||||
passmap.put("slideshow/Password_Protected-hello.ppt", "hello");
|
passmap.put("slideshow/Password_Protected-hello.ppt", "hello");
|
||||||
|
@ -484,6 +484,8 @@ public class TestAllFiles {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class NullFileHandler implements FileHandler {
|
public static class NullFileHandler implements FileHandler {
|
||||||
|
public static final FileHandler instance = new NullFileHandler();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleFile(InputStream stream, String path) {
|
public void handleFile(InputStream stream, String path) {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue