public class ExternalEmbedder extends Object implements Embedder
Modifier and Type | Field and Description |
---|---|
static String |
METADATA_COMMAND_ARGUMENTS_SERIALIZED_TOKEN
Token to be replaced with a String array of metadata assignment command
arguments
|
static String |
METADATA_COMMAND_ARGUMENTS_TOKEN
Token to be replaced with a String array of metadata assignment command
arguments
|
Constructor and Description |
---|
ExternalEmbedder() |
Modifier and Type | Method and Description |
---|---|
static boolean |
check(String[] checkCmd,
int... errorValue)
Checks to see if the command can be run.
|
static boolean |
check(String checkCmd,
int... errorValue)
Checks to see if the command can be run.
|
void |
embed(Metadata metadata,
InputStream inputStream,
OutputStream outputStream,
ParseContext context)
Executes the configured external command and passes the given document
stream as a simple XHTML document to the given SAX content handler.
|
String[] |
getCommand()
Gets the command to be run.
|
String |
getCommandAppendOperator()
Gets the operator to append rather than replace a value for the command
line tool, i.e.
|
String |
getCommandAssignmentDelimeter()
Gets the delimiter for multiple assignments for the command line tool,
i.e.
|
String |
getCommandAssignmentOperator()
Gets the assignment operator for the command line tool, i.e.
|
protected List<String> |
getCommandMetadataSegments(Metadata metadata)
Constructs a collection of command line arguments responsible for setting
individual metadata fields based on the given
metadata . |
Map<Property,String[]> |
getMetadataCommandArguments()
Gets the map of Metadata keys to command line parameters.
|
Set<MediaType> |
getSupportedEmbedTypes() |
Set<MediaType> |
getSupportedEmbedTypes(ParseContext context)
Returns the set of media types supported by this embedder when used with
the given parse context.
|
boolean |
isQuoteAssignmentValues()
Gets whether or not to quote assignment values, i.e.
|
protected static String |
serializeMetadata(List<String> metadataCommandArguments)
Serializes a collection of metadata command line arguments into a single
string.
|
void |
setCommand(String... command)
Sets the command to be run.
|
void |
setCommandAppendOperator(String commandAppendOperator)
Sets the operator to append rather than replace a value for the command
line tool, i.e.
|
void |
setCommandAssignmentDelimeter(String commandAssignmentDelimeter)
Sets the delimiter for multiple assignments for the command line tool,
i.e.
|
void |
setCommandAssignmentOperator(String commandAssignmentOperator)
Sets the assignment operator for the command line tool, i.e.
|
void |
setMetadataCommandArguments(Map<Property,String[]> arguments)
Sets the map of Metadata keys to command line parameters.
|
void |
setQuoteAssignmentValues(boolean quoteAssignmentValues)
Sets whether or not to quote assignment values, i.e.
|
void |
setSupportedEmbedTypes(Set<MediaType> supportedEmbedTypes) |
public static final String METADATA_COMMAND_ARGUMENTS_TOKEN
public static final String METADATA_COMMAND_ARGUMENTS_SERIALIZED_TOKEN
public Set<MediaType> getSupportedEmbedTypes(ParseContext context)
Embedder
The name differs from the precedence of Parser.getSupportedTypes(ParseContext)
so that parser implementations may also choose to implement this interface.
getSupportedEmbedTypes
in interface Embedder
context
- parse contextpublic String[] getCommand()
#INPUT_FILE_TOKEN
or #OUTPUT_FILE_TOKEN
if the command
needs filenames.public void setCommand(String... command)
#INPUT_FILE_TOKEN
or #OUTPUT_FILE_TOKEN
if the command
needs filenames.Runtime.exec(String[])
public String getCommandAssignmentOperator()
public void setCommandAssignmentOperator(String commandAssignmentOperator)
commandAssignmentOperator
- public String getCommandAssignmentDelimeter()
public void setCommandAssignmentDelimeter(String commandAssignmentDelimeter)
commandAssignmentDelimeter
- public String getCommandAppendOperator()
public void setCommandAppendOperator(String commandAppendOperator)
commandAppendOperator
- public boolean isQuoteAssignmentValues()
public void setQuoteAssignmentValues(boolean quoteAssignmentValues)
quoteAssignmentValues
- public Map<Property,String[]> getMetadataCommandArguments()
public void setMetadataCommandArguments(Map<Property,String[]> arguments)
arguments
- protected List<String> getCommandMetadataSegments(Metadata metadata)
metadata
.metadata
- the metadata to embedprotected static String serializeMetadata(List<String> metadataCommandArguments)
metadataCommandArguments
- public void embed(Metadata metadata, InputStream inputStream, OutputStream outputStream, ParseContext context) throws IOException, TikaException
setMetadataCommandArguments(Map)
has been called to set arguments.embed
in interface Embedder
metadata
- document metadata (input and output)inputStream
- the document stream (input)outputStream
- the output stream to write the metadata embedded data tocontext
- parse contextIOException
- if the document stream could not be readTikaException
- if the document could not be parsedpublic static boolean check(String checkCmd, int... errorValue)
checkCmd
- the check command to runerrorValue
- what is considered an error value?public static boolean check(String[] checkCmd, int... errorValue)
checkCmd
- the check command to runerrorValue
- what is considered an error value?Copyright © 2007-2014 The Apache Software Foundation. All Rights Reserved.