eu.scape_project.pit.proc
Class CommandLineProcess

java.lang.Object
  extended by eu.scape_project.pit.proc.CommandLineProcess

public class CommandLineProcess
extends Object

This class defines a command which can be executed on the command line. The command is constructed on the basis of a pattern that is provided as a string which contains variables of the syntax #variable#. There are required variables which are passed to the builder constructor and other optional variables that can be set using the corresponding build methods, like outFormat, for example. After setting the variable values the will be substituted in the pattern string. The getCommand method then provides a command string list which can be passed to a ProcessBuilder object. The typical use of this class is 1) Define command substitution variables: HashMap paramValuePairs = new HashMap(); paramValuePairs.put(CommandPatternVariables.INFILE, "C:\test\infile.tif"); paramValuePairs.put(CommandPatternVariables.OUTFILE,"C:\test\outfile.tif"); 2) Define command pattern: String cliCmdPattern = "cp $INFILE $OUTFILE"; 2) Create CommandLineProcessObject: CommandLineProcess clp = new CommandLineProcess(cliCmdPattern, paramValuePairs); 3) Initialise and execute process: clp.init(); clp.execute();

Version:
${global_wrapper_version}
Author:
${global_project_prefix} Project Consortium

Field Summary
static int MIN_QUERYTOKEN_LENGTH
          Denotes the minumim lenght of a query token
 
Constructor Summary
CommandLineProcess(List<String> commands)
          Construct from a list of string commands
CommandLineProcess(String pattern, HashMap<String,String> paramValuePairs, boolean sh)
           
 
Method Summary
 int execute()
          Execute process withouth further input
 int getCode()
           
 List<String> getCommand()
          Get the command string list which can be used by the Process builder object.
 String getOutput()
           
 String getProcessingLog()
           
 void init()
          Initialise process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_QUERYTOKEN_LENGTH

public static final int MIN_QUERYTOKEN_LENGTH
Denotes the minumim lenght of a query token

See Also:
Constant Field Values
Constructor Detail

CommandLineProcess

public CommandLineProcess(String pattern,
                          HashMap<String,String> paramValuePairs,
                          boolean sh)
Parameters:
pattern -
paramValuePairs -
sh - invoke the shell with the command line as the parameter

CommandLineProcess

public CommandLineProcess(List<String> commands)
Construct from a list of string commands

Parameters:
commands -
Method Detail

getProcessingLog

public String getProcessingLog()
Returns:
the objects processing log

getCommand

public List<String> getCommand()
Get the command string list which can be used by the Process builder object.

Returns:
the java.util.List of commands

init

public void init()
          throws IOException
Initialise process.

Throws:
IOException

execute

public int execute()
Execute process withouth further input

Returns:
the process return code

getCode

public int getCode()
Returns:
the process execution code

getOutput

public String getOutput()
Returns:
get the process output string


Copyright © 2013. All Rights Reserved.