1 11 package org.eclipse.debug.internal.core; 12 13 14 import java.io.IOException ; 15 16 import org.eclipse.debug.core.model.IStreamMonitor; 17 import org.eclipse.debug.core.model.IStreamsProxy; 18 import org.eclipse.debug.core.model.IStreamsProxy2; 19 20 24 25 public class StreamsProxy implements IStreamsProxy, IStreamsProxy2 { 26 29 private OutputStreamMonitor fOutputMonitor; 30 33 private OutputStreamMonitor fErrorMonitor; 34 37 private InputStreamMonitor fInputMonitor; 38 42 private boolean fClosed= false; 43 50 public StreamsProxy(Process process, String encoding) { 51 if (process == null) { 52 return; 53 } 54 fOutputMonitor= new OutputStreamMonitor(process.getInputStream(), encoding); 55 fErrorMonitor= new OutputStreamMonitor(process.getErrorStream(), encoding); 56 fInputMonitor= new InputStreamMonitor(process.getOutputStream()); 57 fOutputMonitor.startMonitoring(); 58 fErrorMonitor.startMonitoring(); 59 fInputMonitor.startMonitoring(); 60 } 61 62 68 public void close() { 69 if (!fClosed) { 70 fClosed= true; 71 fOutputMonitor.close(); 72 fErrorMonitor.close(); 73 fInputMonitor.close(); 74 } 75 } 76 77 83 public void kill() { 84 fClosed= true; 85 fOutputMonitor.kill(); 86 fErrorMonitor.kill(); 87 fInputMonitor.close(); 88 } 89 90 93 public IStreamMonitor getErrorStreamMonitor() { 94 return fErrorMonitor; 95 } 96 97 100 public IStreamMonitor getOutputStreamMonitor() { 101 return fOutputMonitor; 102 } 103 104 107 public void write(String input) throws IOException { 108 if (!fClosed) { 109 fInputMonitor.write(input); 110 } else { 111 throw new IOException (); 112 } 113 } 114 115 118 public void closeInputStream() throws IOException { 119 if (!fClosed) { 120 fInputMonitor.closeInputStream(); 121 } else { 122 throw new IOException (); 123 } 124 125 } 126 127 } 128 | Popular Tags |