Package org.apache.poi.ooxml.extractor
Class ExtractorFactory
java.lang.Object
org.apache.poi.ooxml.extractor.ExtractorFactory
Figures out the correct POITextExtractor for your supplied
document, and returns it.
Note 1 - will fail for many file formats if the POI Scratchpad jar is not present on the runtime classpath
Note 2 - rather than using this, for most cases you would be better off switching to Apache Tika instead!
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends POITextExtractor>
Tstatic POITextExtractor
static POITextExtractor
Tries to determine the actual type of file and produces a matching text-extractor for it.static <T extends POITextExtractor>
TcreateExtractor
(DirectoryNode poifsDir) static <T extends POITextExtractor>
Tstatic Boolean
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.static POITextExtractor[]
Returns an array of text extractors, one for each of the embedded documents in the file (if there are any).static POITextExtractor[]
Returns an array of text extractors, one for each of the embedded documents in the file (if there are any).static POITextExtractor[]
Deprecated.Use the method with correct "embedded"static POITextExtractor[]
Deprecated.Use the method with correct "embedded"static boolean
Should this thread use event based extractors is available? Checks the all-threads one first, then thread specific.static boolean
Should this thread prefer event based over usermodel based extractors? (usermodel extractors tend to be more accurate, but use more memory) Default is false.static void
setAllThreadsPreferEventExtractors
(Boolean preferEventExtractors) Should all threads prefer event based over usermodel based extractors? If set, will take preference over the Thread level setting.static void
setThreadPrefersEventExtractors
(boolean preferEventExtractors) Should this thread prefer event based over usermodel based extractors? Will only be used if the All Threads setting is null.
-
Field Details
-
CORE_DOCUMENT_REL
- See Also:
-
-
Method Details
-
getThreadPrefersEventExtractors
public static boolean getThreadPrefersEventExtractors()Should this thread prefer event based over usermodel based extractors? (usermodel extractors tend to be more accurate, but use more memory) Default is false. -
getAllThreadsPreferEventExtractors
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. -
setThreadPrefersEventExtractors
public static void setThreadPrefersEventExtractors(boolean preferEventExtractors) Should this thread prefer event based over usermodel based extractors? Will only be used if the All Threads setting is null. -
setAllThreadsPreferEventExtractors
Should all threads prefer event based over usermodel based extractors? If set, will take preference over the Thread level setting. -
getPreferEventExtractor
public static boolean getPreferEventExtractor()Should this thread use event based extractors is available? Checks the all-threads one first, then thread specific. -
createExtractor
public static <T extends POITextExtractor> T createExtractor(File f) throws IOException, OpenXML4JException, org.apache.xmlbeans.XmlException - Throws:
IOException
OpenXML4JException
org.apache.xmlbeans.XmlException
-
createExtractor
public static POITextExtractor createExtractor(InputStream inp) throws IOException, OpenXML4JException, org.apache.xmlbeans.XmlException - Throws:
IOException
OpenXML4JException
org.apache.xmlbeans.XmlException
-
createExtractor
public static POITextExtractor createExtractor(OPCPackage pkg) throws IOException, OpenXML4JException, org.apache.xmlbeans.XmlException Tries to determine the actual type of file and produces a matching text-extractor for it.- Parameters:
pkg
- AnOPCPackage
.- Returns:
- A
POIXMLTextExtractor
for the given file. - Throws:
IOException
- If an error occurs while reading the fileOpenXML4JException
- If an error parsing the OpenXML file format is found.org.apache.xmlbeans.XmlException
- If an XML parsing error occurs.IllegalArgumentException
- If no matching file type could be found.
-
createExtractor
public static <T extends POITextExtractor> T createExtractor(POIFSFileSystem fs) throws IOException, OpenXML4JException, org.apache.xmlbeans.XmlException - Throws:
IOException
OpenXML4JException
org.apache.xmlbeans.XmlException
-
createExtractor
public static <T extends POITextExtractor> T createExtractor(DirectoryNode poifsDir) throws IOException, OpenXML4JException, org.apache.xmlbeans.XmlException - Throws:
IOException
OpenXML4JException
org.apache.xmlbeans.XmlException
-
getEmbededDocsTextExtractors
@Deprecated @Removal(version="4.2") public static POITextExtractor[] getEmbededDocsTextExtractors(POIOLE2TextExtractor ext) throws IOException, OpenXML4JException, org.apache.xmlbeans.XmlException Deprecated.Use the method with correct "embedded"Returns an array of text extractors, one for each of the embedded documents in the file (if there are any). If there are no embedded documents, you'll get back an empty array. Otherwise, you'll get one openPOITextExtractor
for each embedded file.- Throws:
IOException
OpenXML4JException
org.apache.xmlbeans.XmlException
-
getEmbeddedDocsTextExtractors
public static POITextExtractor[] getEmbeddedDocsTextExtractors(POIOLE2TextExtractor ext) throws IOException, OpenXML4JException, org.apache.xmlbeans.XmlException Returns an array of text extractors, one for each of the embedded documents in the file (if there are any). If there are no embedded documents, you'll get back an empty array. Otherwise, you'll get one openPOITextExtractor
for each embedded file.- Throws:
IOException
OpenXML4JException
org.apache.xmlbeans.XmlException
-
getEmbededDocsTextExtractors
@Deprecated @Removal(version="4.2") @NotImplemented public static POITextExtractor[] getEmbededDocsTextExtractors(POIXMLTextExtractor ext) Deprecated.Use the method with correct "embedded"Returns an array of text extractors, one for each of the embedded documents in the file (if there are any). If there are no embedded documents, you'll get back an empty array. Otherwise, you'll get one openPOITextExtractor
for each embedded file. -
getEmbeddedDocsTextExtractors
@NotImplemented public static POITextExtractor[] getEmbeddedDocsTextExtractors(POIXMLTextExtractor ext) Returns an array of text extractors, one for each of the embedded documents in the file (if there are any). If there are no embedded documents, you'll get back an empty array. Otherwise, you'll get one openPOITextExtractor
for each embedded file.
-