1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-09 10:05:24 +02:00

Improve Javadoc in HostShellProcessAdapter

This commit is contained in:
Martin Oberhuber 2006-11-16 10:13:23 +00:00
parent 2d7ba36e38
commit 2f2da842d1
2 changed files with 26 additions and 9 deletions

View file

@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Ewa Matejska (PalmSource) * Ewa Matejska (PalmSource)
* Martin Oberhuber (Wind River) - moved from org.eclipse.rse.remotecdt (bug 161777) * Martin Oberhuber (Wind River) - moved from org.eclipse.rse.remotecdt (bug 161777)
* Martin Oberhuber (Wind River) - improved Javadoc
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.services.shells; package org.eclipse.rse.services.shells;
@ -27,6 +28,7 @@ public class HostShellOutputStream extends OutputStream {
private IHostShell hostShell; private IHostShell hostShell;
/** /**
* Constructor.
* @param hostShell An instance of the IHostShell class. * @param hostShell An instance of the IHostShell class.
* The output will be sent to this instance. * The output will be sent to this instance.
*/ */
@ -36,6 +38,7 @@ public class HostShellOutputStream extends OutputStream {
/** /**
* Writes one byte to the shell. * Writes one byte to the shell.
* @see java.io.OutputStream#write(byte[])
*/ */
public void write(byte[] b) { public void write(byte[] b) {
if(hostShell != null && b != null) if(hostShell != null && b != null)
@ -44,7 +47,8 @@ public class HostShellOutputStream extends OutputStream {
/** /**
* Writes multiple bytes to the shell. * Writes multiple bytes to the shell.
*/ * @see java.io.OutputStream#write(byte[], int, int)
*/
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));
@ -52,6 +56,7 @@ public class HostShellOutputStream extends OutputStream {
/** /**
* Writes one character to the shell. * Writes one character to the shell.
* @see java.io.OutputStream#write(int)
*/ */
public void write(int b) throws IOException { public void write(int b) throws IOException {
char[] array = { (char) b }; char[] array = { (char) b };

View file

@ -10,6 +10,7 @@
* Martin Oberhuber (Wind River) - adapt to IHostOutput API (bug 161773, 158312) * Martin Oberhuber (Wind River) - adapt to IHostOutput API (bug 161773, 158312)
* Martin Oberhuber (Wind River) - moved from org.eclipse.rse.remotecdt (bug 161777) * Martin Oberhuber (Wind River) - moved from org.eclipse.rse.remotecdt (bug 161777)
* Martin Oberhuber (Wind River) - renamed from HostShellAdapter (bug 161777) * Martin Oberhuber (Wind River) - renamed from HostShellAdapter (bug 161777)
* Martin Oberhuber (Wind River) - improved Javadoc
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.services.shells; package org.eclipse.rse.services.shells;
@ -25,9 +26,9 @@ import java.io.PipedOutputStream;
* This class represents a host shell process. It does not * This class represents a host shell process. It does not
* represent one process running in the shell. This means * represent one process running in the shell. This means
* that the output of multiple shell commands will be returned * that the output of multiple shell commands will be returned
* until the shell exits. * until the shell exits.
*
* @author Ewa Matejska * @author Ewa Matejska
*
*/ */
public class HostShellProcessAdapter extends Process implements public class HostShellProcessAdapter extends Process implements
IHostShellOutputListener { IHostShellOutputListener {
@ -41,7 +42,7 @@ IHostShellOutputListener {
private PipedOutputStream hostShellError = null; private PipedOutputStream hostShellError = null;
/** /**
* * Constructor.
* @param hostShell An instance of the IHostShell class. * @param hostShell An instance of the IHostShell class.
* @throws java.io.IOException * @throws java.io.IOException
*/ */
@ -57,7 +58,8 @@ IHostShellOutputListener {
} }
/** /**
* Exits the shell. * Exits the shell.
* @see java.lang.Process#destroy()
*/ */
public synchronized void destroy() { public synchronized void destroy() {
hostShell.exit(); hostShell.exit();
@ -69,13 +71,14 @@ IHostShellOutputListener {
errorStream.close(); errorStream.close();
outputStream.close(); outputStream.close();
} catch (IOException e) { } catch (IOException e) {
//FIXME IOException when closing one of the streams will leave others open
// Ignore // Ignore
} }
} }
/** /**
* There is no relevant exit value to return when the shell exits. * There is no relevant exit value to return when the shell exits.
* This always returns 0. * This always returns 0.
*/ */
public synchronized int exitValue() { public synchronized int exitValue() {
if(hostShell.isActive()) if(hostShell.isActive())
@ -85,7 +88,8 @@ IHostShellOutputListener {
} }
/** /**
* Returns the error stream of the shell. * Returns the error stream of the shell.
* @see java.lang.Process#getErrorStream()
*/ */
public InputStream getErrorStream() { public InputStream getErrorStream() {
return errorStream; return errorStream;
@ -93,6 +97,7 @@ IHostShellOutputListener {
/** /**
* Returns the input stream for the shell. * Returns the input stream for the shell.
* @see java.lang.Process#getInputStream()
*/ */
public InputStream getInputStream() { public InputStream getInputStream() {
return inputStream; return inputStream;
@ -100,13 +105,15 @@ IHostShellOutputListener {
/** /**
* Returns the output stream for the shell. * Returns the output stream for the shell.
* @see java.lang.Process#getOutputStream()
*/ */
public OutputStream getOutputStream() { public OutputStream getOutputStream() {
return outputStream; return outputStream;
} }
/** /**
* Waits for the shell to exit. * Waits for the shell to exit.
* @see java.lang.Process#waitFor()
*/ */
public synchronized int waitFor() throws InterruptedException { public synchronized int waitFor() throws InterruptedException {
@ -136,6 +143,11 @@ IHostShellOutputListener {
return 0; return 0;
} }
/**
* Process an RSE Shell event, by writing the lines of text contained
* in the event into the adapter's streams.
* @see org.eclipse.rse.services.shells.IHostShellOutputListener#shellOutputChanged(org.eclipse.rse.services.shells.IHostShellChangeEvent)
*/
public void shellOutputChanged(IHostShellChangeEvent event) { public void shellOutputChanged(IHostShellChangeEvent event) {
IHostOutput[] input = event.getLines(); IHostOutput[] input = event.getLines();
OutputStream outputStream = event.isError() ? hostShellError : hostShellInput; OutputStream outputStream = event.isError() ? hostShellError : hostShellInput;