public class SystemProcess
extends java.lang.Object
Functions for executing system processes.
Modifier and Type | Field and Description |
---|---|
static int |
SHOW_ERROR_OUTPUT
Bit flag.
|
static int |
SHOW_FULL_COMMAND
Bit flag.
|
static int |
SHOW_PROGRAM_NAME
Bit flag.
|
Constructor and Description |
---|
SystemProcess(StringList command)
Construct a new system process, but don't start it yet.
|
Modifier and Type | Method and Description |
---|---|
void |
checkExitCode(int code)
Check that the process exited with the specified
code . |
ByteStream |
getErrorByteStream()
Return error byte stream for the process, available only once
SystemProcess.start has been called. |
CharStream |
getErrorCharStream()
Return error char stream for the process, available only once
SystemProcess.start has been called. |
java.lang.RuntimeException |
getException(java.lang.String message)
|
java.lang.RuntimeException |
getException(java.lang.String message,
java.lang.RuntimeException cause)
Kill the process if it is still running, and return an exception indicating process failure.
|
int |
getExitCode()
Return exit code for the process, available only once
SystemProcess.waitForExit has been called. |
ByteStream |
getInputByteStream()
Return input byte stream for the process, available only once
SystemProcess.start has been called. |
CharStream |
getInputCharStream()
Return input char stream for the process, available only once
SystemProcess.start has been called. |
int |
getShowInExceptions()
Return what can be shown in exception messages? Defaults to SHOW_FULL_COMMAND + SHOW_ERROR_OUTPUT.
|
void |
kill()
Kill the process if it is running.
|
void |
setShowInExceptions(int value)
Set what can be shown in exception messages? Defaults to SHOW_FULL_COMMAND + SHOW_ERROR_OUTPUT.
|
void |
start()
Start tthe process.
|
void |
waitForExit()
Wait for the process to finish executing.
|
public static final int SHOW_FULL_COMMAND
Bit flag. Use for SystemProcess.showInExceptions
if full command should be shown.
public static final int SHOW_PROGRAM_NAME
Bit flag. Use for SystemProcess.showInExceptions
if program name should be shown.
public static final int SHOW_ERROR_OUTPUT
Bit flag. Use for SystemProcess.showInExceptions
if error output should be shown.
public SystemProcess(StringList command)
Construct a new system process, but don't start it yet.
command
- System command.public void checkExitCode(int code)
Check that the process exited with the specified code
.
code
- Expected exit code.public ByteStream getErrorByteStream()
Return error byte stream for the process, available only once SystemProcess.start
has been called.
SystemProcess.start
has been called.public CharStream getErrorCharStream()
Return error char stream for the process, available only once SystemProcess.start
has been called.
SystemProcess.start
has been called.public java.lang.RuntimeException getException(java.lang.String message)
message
- Message parameter.public java.lang.RuntimeException getException(java.lang.String message, java.lang.RuntimeException cause)
Kill the process if it is still running, and return an exception indicating process failure.
message
- (nullable) Error message.cause
- (nullable) Root cause.public int getExitCode()
Return exit code for the process, available only once SystemProcess.waitForExit
has been called.
SystemProcess.waitForExit
has been called.public ByteStream getInputByteStream()
Return input byte stream for the process, available only once SystemProcess.start
has been called.
SystemProcess.start
has been called.public CharStream getInputCharStream()
Return input char stream for the process, available only once SystemProcess.start
has been called.
SystemProcess.start
has been called.public int getShowInExceptions()
Return what can be shown in exception messages? Defaults to SHOW_FULL_COMMAND + SHOW_ERROR_OUTPUT.
SHOW_FULL_COMMAND, SHOW_PROGRAM_NAME, SHOW_ERROR_OUTPUT.
public void kill()
Kill the process if it is running.
public void setShowInExceptions(int value)
Set what can be shown in exception messages? Defaults to SHOW_FULL_COMMAND + SHOW_ERROR_OUTPUT.
SHOW_FULL_COMMAND, SHOW_PROGRAM_NAME, SHOW_ERROR_OUTPUT.
value
- What can be shown in exception messages? Defaults to SHOW_FULL_COMMAND + SHOW_ERROR_OUTPUT.public void start()
Start tthe process.
public void waitForExit()
Wait for the process to finish executing.