Package gov.usgs.earthquake.distribution
Class Command
- java.lang.Object
-
- gov.usgs.earthquake.distribution.Command
-
public class Command extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCommand.CommandTimeout
-
Constructor Summary
Constructors Constructor Description Command()Empty command constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute()java.lang.String[]getCommand()java.io.FilegetDir()java.lang.String[]getEnvp()intgetExitCode()byte[]getStderr()byte[]getStdout()longgetTimeout()voidsetCommand(java.lang.String command)voidsetCommand(java.lang.String[] commandArray)voidsetDir(java.io.File dir)voidsetEnvp(java.lang.String[] envp)voidsetStdin(java.io.InputStream stdin)voidsetTimeout(long timeout)protected static java.lang.String[]splitCommand(java.lang.String command)Split a command string into a command array.
-
-
-
Method Detail
-
execute
public void execute() throws Command.CommandTimeout, java.io.IOException, java.lang.InterruptedException- Throws:
Command.CommandTimeout- CommandTimeoutjava.io.IOException- IOExceptionjava.lang.InterruptedException- InterruptedException
-
getCommand
public java.lang.String[] getCommand()
- Returns:
- string[]
-
setCommand
public void setCommand(java.lang.String command)
- Parameters:
command- single command
-
setCommand
public void setCommand(java.lang.String[] commandArray)
- Parameters:
commandArray- string[]
-
getEnvp
public java.lang.String[] getEnvp()
- Returns:
- envp
-
setEnvp
public void setEnvp(java.lang.String[] envp)
- Parameters:
envp- String[]
-
getDir
public java.io.File getDir()
- Returns:
- dir
-
setDir
public void setDir(java.io.File dir)
- Parameters:
dir- File
-
getTimeout
public long getTimeout()
- Returns:
- timeout
-
setTimeout
public void setTimeout(long timeout)
- Parameters:
timeout- long
-
getExitCode
public int getExitCode()
- Returns:
- exitCode
-
setStdin
public void setStdin(java.io.InputStream stdin)
- Parameters:
stdin- InputStream
-
getStdout
public byte[] getStdout()
- Returns:
- stdout byte[]
-
getStderr
public byte[] getStderr()
- Returns:
- stderr byte[]
-
splitCommand
protected static java.lang.String[] splitCommand(java.lang.String command)
Split a command string into a command array. This version uses a StringTokenizer to split arguments. Quoted arguments are supported (single or double), with quotes removed before passing to runtime. Double quoting arguments will preserve quotes when passing to runtime.- Parameters:
command- command to run.- Returns:
- Array of arguments suitable for passing to Runtime.exec(String[]).
-
-