com.google.enterprise.adaptor.prebuilt
Class CommandLineTransform

java.lang.Object
  extended by com.google.enterprise.adaptor.prebuilt.CommandLineTransform
All Implemented Interfaces:
DocumentTransform

public class CommandLineTransform
extends Object
implements DocumentTransform

A conduit that allows a simple way to create a document transform based on a command line program.


Constructor Summary
CommandLineTransform()
           
 
Method Summary
static CommandLineTransform create(Map<String,String> config)
          Accepts keys "cmd", "workingDirectory", and "arg?".
 boolean getCommandAcceptsParameters()
           
 List<String> getTransformCommand()
           
 File getWorkingDirectory()
           
 void setCommandAcceptsParameters(boolean commandAcceptsParameters)
          This controls whether the input parameters to the transform call are passed along to the actual call to the command.
 void setTransformCommand(List<String> transformCommand)
          Sets the command that is in charge of transforming the document content.
 void setWorkingDirectory(File dir)
          Sets the working directory.
 void transform(Metadata metadata, Map<String,String> params)
          Any changes to metadata and params will be passed on to subsequent transforms.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandLineTransform

public CommandLineTransform()
Method Detail

create

public static CommandLineTransform create(Map<String,String> config)
Accepts keys "cmd", "workingDirectory", and "arg?". The "arg?" configuration values should be numerically increasing starting from one: "arg1", "arg2", "arg3, ...


transform

public void transform(Metadata metadata,
                      Map<String,String> params)
Description copied from interface: DocumentTransform
Any changes to metadata and params will be passed on to subsequent transforms. This method must be thread-safe.

Specified by:
transform in interface DocumentTransform

setCommandAcceptsParameters

public void setCommandAcceptsParameters(boolean commandAcceptsParameters)
This controls whether the input parameters to the transform call are passed along to the actual call to the command. This is useful in the case where a binary might return erros when unexpected command line flags are passed in.


getCommandAcceptsParameters

public boolean getCommandAcceptsParameters()

setTransformCommand

public void setTransformCommand(List<String> transformCommand)
Sets the command that is in charge of transforming the document content. This command should take input on stdin, and print the output to stdout. e.g. /path/to/command metadataFile paramsFile Errors should be printed to stderr. If anything is printed to stderr, it will cause a failure for this transform operation.


getTransformCommand

public List<String> getTransformCommand()

setWorkingDirectory

public void setWorkingDirectory(File dir)
Sets the working directory. Must be valid.

Throws:
IllegalArgumentException - if dir is not a directory

getWorkingDirectory

public File getWorkingDirectory()
Returns:
The working directory for the command line process.