|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.norconex.jef.exec.SystemCommand
public class SystemCommand
Represents a program to be executed by the underlying system (on the "command line"). This class attempts to be system-independent, which means given an executable path should be sufficient to run programs on any systems (e.g. it handles prefixing an executable with OS specific commands as well as preventing process hanging on some OS when there is nowhere to display the output).
Constructor Summary | |
---|---|
SystemCommand(File workdir,
String... command)
Creates a command. |
|
SystemCommand(String... command)
Creates a command for which the execution will be in the working directory of the current process. |
Method Summary | |
---|---|
void |
abort()
Aborts the running command. |
void |
addErrorListener(IStreamListener listener)
Adds an error (STDERR) listener to this system command. |
void |
addOutputListener(IStreamListener listener)
Adds an output (STDOUT) listener to this system command. |
int |
execute()
Executes the given command and returns only when the underlying process stopped running. |
int |
execute(boolean runInBackground)
Executes the given system command. |
String[] |
getCommand()
Gets the command to be run. |
String |
getDescription()
Gets the description for this command. |
File |
getWorkdir()
Gets the command working directory. |
boolean |
isRunning()
Returns whether the command is currently running. |
void |
removeErrorListener(IStreamListener listener)
Removes an error (STDERR) listener. |
void |
removeOutputListener(IStreamListener listener)
Removes an output (STDOUT) listener. |
void |
setDescription(String description)
Sets the description for this command. |
String |
toString()
Returns the command to be executed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SystemCommand(String... command)
command
- the command to runpublic SystemCommand(File workdir, String... command)
command
- the command to runworkdir
- specifies a working directory (default inherits
the working directory of the current process.Method Detail |
---|
public String[] getCommand()
public String getDescription()
public void setDescription(String description)
description
- command descriptionpublic File getWorkdir()
public void addErrorListener(IStreamListener listener)
listener
- command error listenerpublic void removeErrorListener(IStreamListener listener)
listener
- command error listenerpublic void addOutputListener(IStreamListener listener)
listener
- command output listenerpublic void removeOutputListener(IStreamListener listener)
listener
- command output listenerpublic boolean isRunning()
true
if runningpublic void abort()
public int execute() throws InterruptedException, IOException
InterruptedException
- problem executing command
IOException
- problem executing commandpublic int execute(boolean runInBackground) throws InterruptedException, IOException
AsyncJobGroup
).
runInBackground
- true
to runs the system command in
background.
InterruptedException
- problem executing command
IOException
- problem executing commandpublic String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |