ptolemy.util
Interface ExecuteCommands

All Known Implementing Classes:
JTextAreaExec, StreamExec, StringBufferExec

public interface ExecuteCommands

Interface for classes execute commands in a subprocess.

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: ExecuteCommands.java 53095 2009-04-12 19:12:45Z cxh $
Author:
Christopher Brooks
See Also:
StreamExec
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (cxh)

Method Summary
 void appendToPath(java.lang.String directoryName)
          Append to the path of the subprocess.
 void cancel()
          Cancel any running commands.
 void clear()
          Clear the text area, status bar and progress bar.
 java.lang.String getenv(java.lang.String key)
          Get the value of the environment of the subprocess.
 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 stderr.
 void updateStatusBar(java.lang.String text)
          Set the text of the status bar.
 

Method Detail

appendToPath

void appendToPath(java.lang.String directoryName)
Append to the path of the subprocess.

Parameters:
directoryName - The name of the directory to append to the path.

cancel

void cancel()
Cancel any running commands.


clear

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


getenv

java.lang.String getenv(java.lang.String key)
Get the value of the environment of the subprocess.

Parameters:
key - The key to be looked up.
Returns:
The value of the key. If the key is not set, then null is returned. If appendToPath() has been called, and the key parameter is "PATH", then the current value of the PATH of the subprocess will be returned. Note that this may be different from the PATH of the current process.

getLastSubprocessReturnCode

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

Returns:
the return code of the last subprocess that was executed.

setCommands

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

Parameters:
commands - A list of Strings, where each element is a command.

setWorkingDirectory

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

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

void start()
Start running the commands.


stderr

void stderr(java.lang.String text)
Append the text message to stderr. Classes that implement this method could append to a StringBuffer or JTextArea. The output automatically gets a trailing newline appended.

Parameters:
text - The text to append to standard error.

stdout

void stdout(java.lang.String text)
Append the text message to stderr. Classes that implement this method could append to a StringBuffer or JTextArea. The output automatically gets a trailing newline appended.

Parameters:
text - The text to append to standard out.

updateStatusBar

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.

Parameters:
text - The text with which the status bar is updated.