Package gov.usgs.earthquake.distribution
Class Command
java.lang.Object
gov.usgs.earthquake.distribution.Command
Class encapsulates commands including command line arguments
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Static exception class for when a command times out -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute()
String[]
getDir()
String[]
getEnvp()
int
byte[]
byte[]
long
void
setCommand
(String command) void
setCommand
(String[] commandArray) void
void
void
setStdin
(InputStream stdin) void
setTimeout
(long timeout) protected static String[]
splitCommand
(String command) Split a command string into a command array.
-
Constructor Details
-
Command
public Command()Empty command constructor
-
-
Method Details
-
execute
- Throws:
Command.CommandTimeout
- CommandTimeoutIOException
- IOExceptionInterruptedException
- InterruptedException
-
getCommand
- Returns:
- string[]
-
setCommand
- Parameters:
command
- single command
-
setCommand
- Parameters:
commandArray
- string[]
-
getEnvp
- Returns:
- envp
-
setEnvp
- Parameters:
envp
- String[]
-
getDir
- Returns:
- dir
-
setDir
- 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
- Parameters:
stdin
- InputStream
-
getStdout
public byte[] getStdout()- Returns:
- stdout byte[]
-
getStderr
public byte[] getStderr()- Returns:
- stderr byte[]
-
splitCommand
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[]).
-