mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-19 14:15:50 +02:00
Apply patch for bug 161777: Javadoc for HostShellAdapter, HostShellOutputStream
This commit is contained in:
parent
efc2a3dbca
commit
087fc65285
2 changed files with 52 additions and 2 deletions
|
@ -23,6 +23,14 @@ import org.eclipse.rse.services.shells.IHostShell;
|
||||||
import org.eclipse.rse.services.shells.IHostShellChangeEvent;
|
import org.eclipse.rse.services.shells.IHostShellChangeEvent;
|
||||||
import org.eclipse.rse.services.shells.IHostShellOutputListener;
|
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
|
public class HostShellAdapter extends Process implements
|
||||||
IHostShellOutputListener {
|
IHostShellOutputListener {
|
||||||
|
|
||||||
|
@ -34,7 +42,11 @@ IHostShellOutputListener {
|
||||||
private PipedOutputStream hostShellInput = null;
|
private PipedOutputStream hostShellInput = null;
|
||||||
private PipedOutputStream hostShellError = 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 {
|
public HostShellAdapter(IHostShell hostShell) throws java.io.IOException {
|
||||||
this.hostShell = hostShell;
|
this.hostShell = hostShell;
|
||||||
hostShellInput = new PipedOutputStream();
|
hostShellInput = new PipedOutputStream();
|
||||||
|
@ -46,6 +58,9 @@ IHostShellOutputListener {
|
||||||
this.hostShell.getStandardErrorReader().addOutputListener(this);
|
this.hostShell.getStandardErrorReader().addOutputListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exits the shell.
|
||||||
|
*/
|
||||||
public synchronized void destroy() {
|
public synchronized void destroy() {
|
||||||
hostShell.exit();
|
hostShell.exit();
|
||||||
notifyAll();
|
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() {
|
public synchronized int exitValue() {
|
||||||
if(hostShell.isActive())
|
if(hostShell.isActive())
|
||||||
throw new IllegalThreadStateException();
|
throw new IllegalThreadStateException();
|
||||||
|
@ -67,18 +86,30 @@ IHostShellOutputListener {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the error stream of the shell.
|
||||||
|
*/
|
||||||
public InputStream getErrorStream() {
|
public InputStream getErrorStream() {
|
||||||
return errorStream;
|
return errorStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the input stream for the shell.
|
||||||
|
*/
|
||||||
public InputStream getInputStream() {
|
public InputStream getInputStream() {
|
||||||
return inputStream;
|
return inputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the output stream for the shell.
|
||||||
|
*/
|
||||||
public OutputStream getOutputStream() {
|
public OutputStream getOutputStream() {
|
||||||
return outputStream;
|
return outputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Waits for the shell to exit.
|
||||||
|
*/
|
||||||
public synchronized int waitFor() throws InterruptedException {
|
public synchronized int waitFor() throws InterruptedException {
|
||||||
|
|
||||||
while(hostShell.isActive()) {
|
while(hostShell.isActive()) {
|
||||||
|
|
|
@ -16,24 +16,43 @@ import java.io.OutputStream;
|
||||||
|
|
||||||
import org.eclipse.rse.services.shells.IHostShell;
|
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 {
|
public class HostShellOutputStream extends OutputStream {
|
||||||
|
|
||||||
private IHostShell hostShell;
|
private IHostShell hostShell;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param hostShell An instance of the IHostShell class.
|
||||||
|
* The output will be sent to this instance.
|
||||||
|
*/
|
||||||
public HostShellOutputStream(IHostShell hostShell) {
|
public HostShellOutputStream(IHostShell hostShell) {
|
||||||
this.hostShell = hostShell;
|
this.hostShell = hostShell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes one byte to the shell.
|
||||||
|
*/
|
||||||
public void write(byte[] b) {
|
public void write(byte[] b) {
|
||||||
if(hostShell != null && b != null)
|
if(hostShell != null && b != null)
|
||||||
hostShell.writeToShell(new String(b));
|
hostShell.writeToShell(new String(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes multiple bytes to the shell.
|
||||||
|
*/
|
||||||
public void write(byte[] b, int off, int len) {
|
public void write(byte[] b, int off, int len) {
|
||||||
if(hostShell != null && b != null)
|
if(hostShell != null && b != null)
|
||||||
hostShell.writeToShell(new String(b, off, len));
|
hostShell.writeToShell(new String(b, off, len));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes one character to the shell.
|
||||||
|
*/
|
||||||
public void write(int b) throws IOException {
|
public void write(int b) throws IOException {
|
||||||
char[] array = { (char) b };
|
char[] array = { (char) b };
|
||||||
if(hostShell != null)
|
if(hostShell != null)
|
||||||
|
|
Loading…
Add table
Reference in a new issue