Package org.apache.tika.parser.external2
Class ExternalParser
- java.lang.Object
- 
- org.apache.tika.parser.external2.ExternalParser
 
- 
- All Implemented Interfaces:
- Serializable,- Initializable,- Parser
 
 public class ExternalParser extends Object implements Parser, Initializable This is a next generation external parser that uses some of the more recent additions to Tika. This is an experimental alternative to theExternalParser. Specifically, it relies more on configuration than the SPI model. Further, users can specify a parser to handle the output of the external process.- See Also:
- Serialized Form
 
- 
- 
Field SummaryFields Modifier and Type Field Description static longDEFAULT_TIMEOUT_MSstatic StringINPUT_FILE_TOKENstatic StringOUTPUT_FILE_TOKEN
 - 
Constructor SummaryConstructors Constructor Description ExternalParser()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckInitialization(InitializableProblemHandler problemHandler)ParsergetOutputParser()Set<MediaType>getSupportedTypes(ParseContext context)Returns the set of media types supported by this parser when used with the given parse context.voidinitialize(Map<String,Param> params)voidparse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context)Parses a document stream into a sequence of XHTML SAX events.voidsetCommandLine(List<String> commandLine)Use this to specify the full commandLine.voidsetMaxStdErr(int maxStdErr)voidsetMaxStdOut(int maxStdOut)voidsetOutputParser(Parser parser)This parser is called on the output of the process.voidsetReturnStderr(boolean returnStderr)If set to true, this will return the stderr in the metadata viaExternalProcess.STD_ERR.voidsetReturnStdout(boolean returnStdout)If set to true, this will return the stdout in the metadata viaExternalProcess.STD_OUT.voidsetSupportedTypes(List<String> supportedTypes)This is set during initialization from a tika-config.voidsetTimeoutMs(long timeoutMs)
 
- 
- 
- 
Field Detail- 
DEFAULT_TIMEOUT_MSpublic static final long DEFAULT_TIMEOUT_MS - See Also:
- Constant Field Values
 
 - 
INPUT_FILE_TOKENpublic static final String INPUT_FILE_TOKEN - See Also:
- Constant Field Values
 
 - 
OUTPUT_FILE_TOKENpublic static final String OUTPUT_FILE_TOKEN - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getSupportedTypespublic Set<MediaType> getSupportedTypes(ParseContext context) Description copied from interface:ParserReturns the set of media types supported by this parser when used with the given parse context.- Specified by:
- getSupportedTypesin interface- Parser
- Parameters:
- context- parse context
- Returns:
- immutable set of media types
 
 - 
parsepublic void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException Description copied from interface:ParserParses a document stream into a sequence of XHTML SAX events. Fills in related document metadata in the given metadata object.The given document stream is consumed but not closed by this method. The responsibility to close the stream remains on the caller. Information about the parsing context can be passed in the context parameter. See the parser implementations for the kinds of context information they expect. - Specified by:
- parsein interface- Parser
- Parameters:
- stream- the document stream (input)
- handler- handler for the XHTML SAX events (output)
- metadata- document metadata (input and output)
- context- parse context
- Throws:
- IOException- if the document stream could not be read
- SAXException- if the SAX events could not be processed
- TikaException- if the document could not be parsed
 
 - 
setSupportedTypes@Field public void setSupportedTypes(List<String> supportedTypes) This is set during initialization from a tika-config. Any calls after initialization will result in aIllegalStateException.- Parameters:
- supportedTypes-
 
 - 
setTimeoutMs@Field public void setTimeoutMs(long timeoutMs) 
 - 
setMaxStdErr@Field public void setMaxStdErr(int maxStdErr) 
 - 
setMaxStdOut@Field public void setMaxStdOut(int maxStdOut) 
 - 
setCommandLine@Field public void setCommandLine(List<String> commandLine) Use this to specify the full commandLine. The commandline must include at leastINPUT_FILE_TOKEN. If the external process writes to an output file, specifyOUTPUT_FILE_TOKEN.- Parameters:
- commandLine-
 
 - 
setReturnStdout@Field public void setReturnStdout(boolean returnStdout) If set to true, this will return the stdout in the metadata viaExternalProcess.STD_OUT. Default isfalsebecause this should normally be handled by the outputParser- Parameters:
- returnStdout-
 
 - 
setReturnStderr@Field public void setReturnStderr(boolean returnStderr) If set to true, this will return the stderr in the metadata viaExternalProcess.STD_ERR. Default istrue- Parameters:
- returnStderr-
 
 - 
setOutputParser@Field public void setOutputParser(Parser parser) This parser is called on the output of the process. If the process writes to an output file, specified byOUTPUT_FILE_TOKEN, this parser will parse that file, otherwise it will parse the UTF-8 encoded bytes from the process' STD_OUT.- Parameters:
- parser-
 
 - 
getOutputParserpublic Parser getOutputParser() 
 - 
initializepublic void initialize(Map<String,Param> params) throws TikaConfigException - Specified by:
- initializein interface- Initializable
- Parameters:
- params- params to use for initialization
- Throws:
- TikaConfigException
 
 - 
checkInitializationpublic void checkInitialization(InitializableProblemHandler problemHandler) throws TikaConfigException - Specified by:
- checkInitializationin interface- Initializable
- Parameters:
- problemHandler- if there is a problem and no custom initializableProblemHandler has been configured via Initializable parameters, this is called to respond.
- Throws:
- TikaConfigException
 
 
- 
 
-