public class ExternalParser extends AbstractParser
Modifier and Type | Class and Description |
---|---|
static interface |
ExternalParser.LineConsumer
Consumer contract
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
INPUT_FILE_TOKEN
The token, which if present in the Command string, will
be replaced with the input filename.
|
static java.lang.String |
OUTPUT_FILE_TOKEN
The token, which if present in the Command string, will
be replaced with the output filename.
|
Constructor and Description |
---|
ExternalParser() |
Modifier and Type | Method and Description |
---|---|
static boolean |
check(java.lang.String[] checkCmd,
int... errorValue) |
static boolean |
check(java.lang.String checkCmd,
int... errorValue)
Checks to see if the command can be run.
|
java.lang.String[] |
getCommand() |
ExternalParser.LineConsumer |
getIgnoredLineConsumer()
Gets lines consumer
|
java.util.Map<java.util.regex.Pattern,java.lang.String> |
getMetadataExtractionPatterns() |
java.util.Set<MediaType> |
getSupportedTypes() |
java.util.Set<MediaType> |
getSupportedTypes(ParseContext context)
Returns the set of media types supported by this parser when used
with the given parse context.
|
void |
parse(java.io.InputStream stream,
org.xml.sax.ContentHandler handler,
Metadata metadata,
ParseContext context)
Executes the configured external command and passes the given document
stream as a simple XHTML document to the given SAX content handler.
|
void |
setCommand(java.lang.String... command)
Sets the command to be run.
|
void |
setIgnoredLineConsumer(ExternalParser.LineConsumer ignoredLineConsumer)
Set a consumer for the lines ignored by the parse functions
|
void |
setMetadataExtractionPatterns(java.util.Map<java.util.regex.Pattern,java.lang.String> patterns)
Sets the map of regular expression patterns and Metadata
keys.
|
void |
setSupportedTypes(java.util.Set<MediaType> supportedTypes) |
parse
public static final java.lang.String INPUT_FILE_TOKEN
public static final java.lang.String OUTPUT_FILE_TOKEN
public java.util.Set<MediaType> getSupportedTypes(ParseContext context)
Parser
context
- parse contextpublic java.util.Set<MediaType> getSupportedTypes()
public void setSupportedTypes(java.util.Set<MediaType> supportedTypes)
public java.lang.String[] getCommand()
public void setCommand(java.lang.String... command)
INPUT_FILE_TOKEN
or OUTPUT_FILE_TOKEN
if the command needs filenames.Runtime.exec(String[])
public ExternalParser.LineConsumer getIgnoredLineConsumer()
public void setIgnoredLineConsumer(ExternalParser.LineConsumer ignoredLineConsumer)
ignoredLineConsumer
- consumer instancepublic java.util.Map<java.util.regex.Pattern,java.lang.String> getMetadataExtractionPatterns()
public void setMetadataExtractionPatterns(java.util.Map<java.util.regex.Pattern,java.lang.String> patterns)
public void parse(java.io.InputStream stream, org.xml.sax.ContentHandler handler, Metadata metadata, ParseContext context) throws java.io.IOException, org.xml.sax.SAXException, TikaException
setMetadataExtractionPatterns(Map)
has been called to set patterns.stream
- the document stream (input)handler
- handler for the XHTML SAX events (output)metadata
- document metadata (input and output)context
- parse contextjava.io.IOException
- if the document stream could not be readorg.xml.sax.SAXException
- if the SAX events could not be processedTikaException
- if the document could not be parsedpublic static boolean check(java.lang.String checkCmd, int... errorValue)
checkCmd
- The check command to runerrorValue
- What is considered an error value?public static boolean check(java.lang.String[] checkCmd, int... errorValue)
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"