Overview Package Class Tree Deprecated Index Help
PREV CLASS NEXT CLASS FRAMES NO FRAMES All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

ptolemy.util
Class StreamExec

java.lang.Object
 extended byptolemy.util.StreamExec
All Implemented Interfaces:
ExecuteCommands

public class StreamExec
extends java.lang.Object
implements ExecuteCommands

Execute commands in a subprocess. This class does not use swing, for a graphical interface, see JTextAreaExec.

Sample usage:

 
 List execCommands = new LinkedList();
 execCommands.add("date");
 execCommands.add("sleep 3");
 execCommands.add("date");
 execCommands.add("notACommand");
 final StreamExec exec = new StreamExec();
 exec.setCommands(execCommands);
 exec.start();
 

Loosely based on Example1.java from http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html

See also http://developer.java.sun.com/developer/qow/archive/135/index.jsp and http://jw.itworld.com/javaworld/jw-12-2000/jw-1229-traps.html

Since:
Ptolemy II 5.2
Version:
$Id: StreamExec.java,v 1.12 2006年03月29日 20:59:34 cxh Exp $
Author:
Christopher Hylands
See Also:
JTextAreaExec
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (cxh)

Constructor Summary
StreamExec()
Create a StreamExec.
Method Summary
protected void _setProgressBarMaximum(int size)
Set the maximum of the progress bar.
void cancel()
Cancel any running commands.
void clear()
Clear the text area, status bar and progress bar.
int getLastSubprocessReturnCode()
Return the return code of the last subprocess that was executed.
void setCommands(java.util.List commands)
Set the list of commands.
void setWorkingDirectory(java.io.File workingDirectory)
Set the working directory of the subprocess.
void start()
Start running the commands.
void stderr(java.lang.String text)
Append the text message to stderr.
void stdout(java.lang.String text)
Append the text message to the output.
void updateStatusBar(java.lang.String text)
Set the text of the status bar.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

StreamExec

public StreamExec()
Create a StreamExec.

Method Detail

cancel

public void cancel()
Cancel any running commands.

Specified by:
cancel in interface ExecuteCommands

clear

public void clear()
Clear the text area, status bar and progress bar.

Specified by:
clear in interface ExecuteCommands

getLastSubprocessReturnCode

public int getLastSubprocessReturnCode()
Return the return code of the last subprocess that was executed.

Specified by:
getLastSubprocessReturnCode in interface ExecuteCommands
Returns:
the return code of the last subprocess that was executed.

setCommands

public void setCommands(java.util.List commands)
Set the list of commands.

Specified by:
setCommands in interface ExecuteCommands
Parameters:
commands - A list of Strings, where each element is a command.

setWorkingDirectory

public void setWorkingDirectory(java.io.File workingDirectory)
Set the working directory of the subprocess.

Specified by:
setWorkingDirectory in interface ExecuteCommands
Parameters:
workingDirectory - The working directory of the subprocess. If this argument is null, then the subprocess is executed in the working directory of the current process.

start

public void start()
Start running the commands.

Specified by:
start in interface ExecuteCommands

stderr

public void stderr(java.lang.String text)
Append the text message to stderr. A derived class could append to a StringBuffer. @link{JTextAreaExec} appends to a JTextArea. The output automatically gets a trailing newline appended.

Specified by:
stderr in interface ExecuteCommands
Parameters:
text - The text to append to standard error.

stdout

public void stdout(java.lang.String text)
Append the text message to the output. A derived class could append to a StringBuffer. @link{JTextAreaExec} appends to a JTextArea. The output automatically gets a trailing newline appended.

Specified by:
stdout in interface ExecuteCommands
Parameters:
text - The text to append to standard out.

updateStatusBar

public void updateStatusBar(java.lang.String text)
Set the text of the status bar. In this base class, do nothing, derived classes may update a status bar.

Specified by:
updateStatusBar in interface ExecuteCommands
Parameters:
text - The text with which the status bar is updated.

_setProgressBarMaximum

protected void _setProgressBarMaximum(int size)
Set the maximum of the progress bar. In this base class, do nothing, derived classes may update the size of the progress bar.

Parameters:
size - The maximum size of the progress bar.

Overview Package Class Tree Deprecated Index Help
PREV CLASS NEXT CLASS FRAMES NO FRAMES All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

AltStyle によって変換されたページ (->オリジナル) /