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 class
Command.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 void
execute()
java.lang.String[]
getCommand()
java.io.File
getDir()
java.lang.String[]
getEnvp()
int
getExitCode()
byte[]
getStderr()
byte[]
getStdout()
long
getTimeout()
void
setCommand(java.lang.String command)
void
setCommand(java.lang.String[] commandArray)
void
setDir(java.io.File dir)
void
setEnvp(java.lang.String[] envp)
void
setStdin(java.io.InputStream stdin)
void
setTimeout(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[]).
-
-