|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.procsched.Command
public class Command
This class is the core of the process scheduling library. This class encapsulates all the information that a process may need for running including its command line arguments, a directory to find the command, the process' i/o streams and more. This class also holds any excpetions thrown during the running of the command. These exceptions can be looked at after or during the running of the program.
| Field Summary | |
|---|---|
protected java.lang.String[] |
args
The arguments to send the to program. |
protected java.lang.String |
command
The program to execute. |
protected java.lang.String |
dir
The directory to find the program. |
protected java.util.List<java.lang.Exception> |
exceptions
A list which is the command followed by its arguements. |
protected long |
finish
When the process finishes. |
protected boolean |
running
True if the native process is running. |
protected long |
start
When the process starts. |
| Constructor Summary | |
|---|---|
Command()
This makes a defualt Command object. |
|
Command(java.lang.String command)
Makes a Command object that uses the specified command and the default working dir "." and no command line arguments. |
|
Command(java.lang.String command,
java.lang.String dir)
This will make a Command object with the specified command and working dir. |
|
Command(java.lang.String command,
java.lang.String dir,
java.lang.String[] args)
This will make a Command that takes the specified arguemnts, uses the specified command name and the specified working directory. |
|
| Method Summary | |
|---|---|
void |
addListener(CommandTerminationListener cte)
Adds a listener to this Command object. |
void |
compressStdErrStdOut(int buf)
NOT IMPLEMENTED. |
void |
compressStdOutStdErr()
NOT IMPLEMENTED. |
boolean |
errorOccured()
Returns true if at least one exception has been caught and stored. |
java.util.List<java.lang.Exception> |
exceptions()
Returns a List that stores the caught exceptions. |
static java.lang.Thread |
exec(Command c)
This method will start the command specified. |
java.lang.String[] |
getArgs()
Returns the arguments used by this Command |
java.lang.String |
getCommand()
Returns the program name used by this Command |
java.lang.String |
getDir()
Returns the program directory used by this Command |
boolean |
getMergeState()
|
java.io.InputStream |
getStdErr()
Similar to Command.getStdOut() but instead returns the stderr. |
java.io.OutputStream |
getStdIn()
This method returns the stdin of the invoked process. |
java.io.InputStream |
getStdOut()
Returns the *process'* stdout. |
void |
mergeOutput()
Merges the stderr and stdout InputStream such that by reading from the stdout you can get both stdout and stderr. |
void |
redirectStdErr(java.io.OutputStream s,
int bufSize)
Redirects the stderr stream to the specified OutputStream. |
void |
redirectStdIn(java.io.InputStream s,
int bufSize)
Uses this stream for reading stdin data. |
void |
redirectStdOut(java.io.OutputStream s,
int bufSize)
Similar to how redirectStdErr() works, only this uses stdout. |
boolean |
removeListener(CommandTerminationListener cte)
Removes a listener to this Command object. |
void |
run()
This method is called when the Command object should execute the native process. |
void |
setArgs(java.lang.String[] args)
Sets the arguements to be passed to the native program. |
void |
setCommand(java.lang.String command)
Set the name of the program to invoke. |
void |
setDir(java.lang.String dir)
Sets the directory which will be looked in for the program to invoke. |
long |
time()
Computes the time that this process has been running for. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.String command
protected java.lang.String dir
protected java.lang.String[] args
protected long start
protected long finish
protected boolean running
protected java.util.List<java.lang.Exception> exceptions
| Constructor Detail |
|---|
public Command()
public Command(java.lang.String command)
command - The name of the executable to call.
public Command(java.lang.String command,
java.lang.String dir)
command - The native executable to be executeddir - The dir to find the command
public Command(java.lang.String command,
java.lang.String dir,
java.lang.String[] args)
command - The native executable to be executeddir - The dir to find the commandargs - A String[] of the args to be sent to the
command| Method Detail |
|---|
public static java.lang.Thread exec(Command c)
c - The command to execute.
public java.lang.String[] getArgs()
public java.lang.String getCommand()
public java.lang.String getDir()
public java.io.InputStream getStdOut()
public java.io.InputStream getStdErr()
public java.io.OutputStream getStdIn()
public void setArgs(java.lang.String[] args)
args - Arguments to pass to the nativ program.public void setCommand(java.lang.String command)
command - The name of the program to invoke.public void setDir(java.lang.String dir)
dir - The directory to search for the program to invoke.public boolean getMergeState()
public void run()
run in interface java.lang.Runnablepublic void addListener(CommandTerminationListener cte)
cte - The listener.public boolean removeListener(CommandTerminationListener cte)
cte - The listener.public long time()
public boolean errorOccured()
public java.util.List<java.lang.Exception> exceptions()
public void redirectStdErr(java.io.OutputStream s,
int bufSize)
s - The stream to write stderr to.bufSize - The number or bytes to read/write at a time.
public void redirectStdOut(java.io.OutputStream s,
int bufSize)
s - The stream to write stdout to.bufSize - The number or bytes to read/write at a time.
public void redirectStdIn(java.io.InputStream s,
int bufSize)
s - The stream to get stdin from.bufSize - The number of bytes to read/write at a time.
public void compressStdErrStdOut(int buf)
throws java.io.IOException
java.io.IOExceptionpublic void compressStdOutStdErr()
public void mergeOutput()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||