1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-04 23:55:26 +02:00

Apply patch for bug 161777: Javadoc for HostShellAdapter, HostShellOutputStream

This commit is contained in:
Martin Oberhuber 2006-11-16 09:39:07 +00:00
parent efc2a3dbca
commit 087fc65285
2 changed files with 52 additions and 2 deletions

View file

@ -23,6 +23,14 @@ import org.eclipse.rse.services.shells.IHostShell;
import org.eclipse.rse.services.shells.IHostShellChangeEvent;
import org.eclipse.rse.services.shells.IHostShellOutputListener;
/**
* This class represents a host shell process. It does not
* represent one process running in the shell. This means
* that the output of multiple shell commands will be returned
* until the shell exits.
* @author Ewa Matejska
*
*/
public class HostShellAdapter extends Process implements
IHostShellOutputListener {
@ -34,7 +42,11 @@ IHostShellOutputListener {
private PipedOutputStream hostShellInput = null;
private PipedOutputStream hostShellError = null;
/**
*
* @param hostShell An instance of the IHostShell class.
* @throws java.io.IOException
*/
public HostShellAdapter(IHostShell hostShell) throws java.io.IOException {
this.hostShell = hostShell;
hostShellInput = new PipedOutputStream();
@ -46,6 +58,9 @@ IHostShellOutputListener {
this.hostShell.getStandardErrorReader().addOutputListener(this);
}
/**
* Exits the shell.
*/
public synchronized void destroy() {
hostShell.exit();
notifyAll();
@ -60,6 +75,10 @@ IHostShellOutputListener {
}
}
/**
* There is no relevant exit value to return when the shell exits.
* This always returns 0.
*/
public synchronized int exitValue() {
if(hostShell.isActive())
throw new IllegalThreadStateException();
@ -67,18 +86,30 @@ IHostShellOutputListener {
return 0;
}
/**
* Returns the error stream of the shell.
*/
public InputStream getErrorStream() {
return errorStream;
}
/**
* Returns the input stream for the shell.
*/
public InputStream getInputStream() {
return inputStream;
}
/**
* Returns the output stream for the shell.
*/
public OutputStream getOutputStream() {
return outputStream;
}
/**
* Waits for the shell to exit.
*/
public synchronized int waitFor() throws InterruptedException {
while(hostShell.isActive()) {

View file

@ -16,24 +16,43 @@ import java.io.OutputStream;
import org.eclipse.rse.services.shells.IHostShell;
/**
* An adapter between the OutputStream and the IHostShell objects.
* @author Ewa Matejska
* @see IHostShell
* @see java.io.OutputStream
*/
public class HostShellOutputStream extends OutputStream {
private IHostShell hostShell;
/**
* @param hostShell An instance of the IHostShell class.
* The output will be sent to this instance.
*/
public HostShellOutputStream(IHostShell hostShell) {
this.hostShell = hostShell;
}
/**
* Writes one byte to the shell.
*/
public void write(byte[] b) {
if(hostShell != null && b != null)
hostShell.writeToShell(new String(b));
}
/**
* Writes multiple bytes to the shell.
*/
public void write(byte[] b, int off, int len) {
if(hostShell != null && b != null)
hostShell.writeToShell(new String(b, off, len));
}
/**
* Writes one character to the shell.
*/
public void write(int b) throws IOException {
char[] array = { (char) b };
if(hostShell != null)