@SuppressWarnings("unchecked") public static <T extends POITextExtractor> T createExtractor(InputStream input) throws IOException { Class<?> cls = getOOXMLClass(); if (cls != null) { // Use Reflection to get us the full OOXML-enabled version try { Method m = cls.getDeclaredMethod("createExtractor", InputStream.class); return (T)m.invoke(null, input); } catch (IllegalArgumentException iae) { throw iae; } catch (Exception e) { throw new IllegalArgumentException("Error creating Extractor for InputStream", e); } } else { // Best hope it's OLE2.... return createExtractor(new POIFSFileSystem(input)); } }
/** * Should this thread use event based extractors is available? * Checks the all-threads one first, then thread specific. */ public static boolean getPreferEventExtractor() { return OLE2ExtractorFactory.getPreferEventExtractor(); }
/** * Should all threads prefer event based over usermodel based extractors? * (usermodel extractors tend to be more accurate, but use more memory) * Default is to use the thread level setting, which defaults to false. */ public static Boolean getAllThreadsPreferEventExtractors() { return OLE2ExtractorFactory.getAllThreadsPreferEventExtractors(); }
if (getPreferEventExtractor()) { return new EventBasedExcelExtractor(poifsDir); Class<?> cls = getScratchpadClass(); try { Method m = cls.getDeclaredMethod("createExtractor", DirectoryNode.class);
Class<?> cls = getScratchpadClass(); try { Method m = cls.getDeclaredMethod( e.add(createExtractor((DirectoryNode) dir )); e.add(createExtractor(stream)); } catch (Exception xe) {
@SuppressWarnings("unchecked") public static <T extends POITextExtractor> T createExtractor(POIFSFileSystem fs) throws IOException { return (T)createExtractor(fs.getRoot()); }
/** * Should this thread prefer event based over usermodel based extractors? * (usermodel extractors tend to be more accurate, but use more memory) * Default is false. */ public static boolean getThreadPrefersEventExtractors() { return OLE2ExtractorFactory.getThreadPrefersEventExtractors(); }
/** * Should this thread prefer event based over usermodel based extractors? * Will only be used if the All Threads setting is null. */ public static void setThreadPrefersEventExtractors(boolean preferEventExtractors) { OLE2ExtractorFactory.setThreadPrefersEventExtractors(preferEventExtractors); }
/** * Should all threads prefer event based over usermodel based extractors? * If set, will take preference over the Thread level setting. */ public static void setAllThreadsPreferEventExtractors(Boolean preferEventExtractors) { OLE2ExtractorFactory.setAllThreadsPreferEventExtractors(preferEventExtractors); }
if (getPreferEventExtractor()) { return new EventBasedExcelExtractor(poifsDir); Class<?> cls = getScratchpadClass(); try { Method m = cls.getDeclaredMethod("createExtractor", DirectoryNode.class);
Class<?> cls = getScratchpadClass(); try { Method m = cls.getDeclaredMethod( e.add(createExtractor((DirectoryNode) dir )); e.add(createExtractor(stream)); } catch (Exception xe) {
@SuppressWarnings("unchecked") public static <T extends POITextExtractor> T createExtractor(DirectoryNode poifsDir) throws IOException, OpenXML4JException, XmlException { // First, check for OOXML for (String entryName : poifsDir.getEntryNames()) { if (entryName.equals("Package")) { OPCPackage pkg = OPCPackage.open(poifsDir.createDocumentInputStream("Package")); return (T)createExtractor(pkg); } } // If not, ask the OLE2 code to check, with Scratchpad if possible return (T)OLE2ExtractorFactory.createExtractor(poifsDir); }
/** * Should this thread prefer event based over usermodel based extractors? * (usermodel extractors tend to be more accurate, but use more memory) * Default is false. */ public static boolean getThreadPrefersEventExtractors() { return OLE2ExtractorFactory.getThreadPrefersEventExtractors(); }
/** * Should this thread prefer event based over usermodel based extractors? * Will only be used if the All Threads setting is null. */ public static void setThreadPrefersEventExtractors(boolean preferEventExtractors) { OLE2ExtractorFactory.setThreadPrefersEventExtractors(preferEventExtractors); }
/** * Should all threads prefer event based over usermodel based extractors? * If set, will take preference over the Thread level setting. */ public static void setAllThreadsPreferEventExtractors(Boolean preferEventExtractors) { OLE2ExtractorFactory.setAllThreadsPreferEventExtractors(preferEventExtractors); }
@SuppressWarnings("unchecked") public static <T extends POITextExtractor> T createExtractor(InputStream input) throws IOException { Class<?> cls = getOOXMLClass(); if (cls != null) { // Use Reflection to get us the full OOXML-enabled version try { Method m = cls.getDeclaredMethod("createExtractor", InputStream.class); return (T)m.invoke(null, input); } catch (IllegalArgumentException iae) { throw iae; } catch (Exception e) { throw new IllegalArgumentException("Error creating Extractor for InputStream", e); } } else { // Best hope it's OLE2.... return createExtractor(new POIFSFileSystem(input)); } }
@SuppressWarnings("unchecked") public static <T extends POITextExtractor> T createExtractor(POIFSFileSystem fs) throws IOException { return (T)createExtractor(fs.getRoot()); }
/** * Should this thread use event based extractors is available? * Checks the all-threads one first, then thread specific. */ public static boolean getPreferEventExtractor() { return OLE2ExtractorFactory.getPreferEventExtractor(); }
/** * Should all threads prefer event based over usermodel based extractors? * (usermodel extractors tend to be more accurate, but use more memory) * Default is to use the thread level setting, which defaults to false. */ public static Boolean getAllThreadsPreferEventExtractors() { return OLE2ExtractorFactory.getAllThreadsPreferEventExtractors(); }
@SuppressWarnings("unchecked") public static <T extends POITextExtractor> T createExtractor(DirectoryNode poifsDir) throws IOException, OpenXML4JException, XmlException { // First, check for OOXML for (String entryName : poifsDir.getEntryNames()) { if (entryName.equals("Package")) { OPCPackage pkg = OPCPackage.open(poifsDir.createDocumentInputStream("Package")); return (T)createExtractor(pkg); } } // If not, ask the OLE2 code to check, with Scratchpad if possible return (T)OLE2ExtractorFactory.createExtractor(poifsDir); }