From: <cr...@us...> - 2008-09-21 04:44:52
|
Revision: 4567 http://jnode.svn.sourceforge.net/jnode/?rev=4567&view=rev Author: crawley Date: 2008-09-21 04:44:44 +0000 (Sun, 21 Sep 2008) Log Message: ----------- Implementing 'isTTY' functionality. Modified Paths: -------------- trunk/core/src/core/org/jnode/util/ReaderInputStream.java trunk/core/src/core/org/jnode/util/WriterOutputStream.java trunk/core/src/driver/org/jnode/driver/console/spi/ConsoleWriter.java trunk/core/src/driver/org/jnode/driver/console/textscreen/KeyboardReader.java trunk/shell/src/shell/org/jnode/shell/io/CommandIOMarker.java trunk/shell/src/shell/org/jnode/shell/io/CommandInput.java trunk/shell/src/shell/org/jnode/shell/io/CommandInputOutput.java trunk/shell/src/shell/org/jnode/shell/io/CommandOutput.java trunk/shell/src/shell/org/jnode/shell/proclet/AbstractProxyPrintStream.java trunk/shell/src/shell/org/jnode/shell/proclet/ProcletContext.java trunk/shell/src/shell/org/jnode/shell/proclet/ProcletIOContext.java trunk/shell/src/shell/org/jnode/shell/proclet/ProcletProxyInputStream.java trunk/shell/src/shell/org/jnode/shell/proclet/ProcletProxyPrintStream.java trunk/shell/src/shell/org/jnode/shell/proclet/ProcletProxyStream.java Added Paths: ----------- trunk/core/src/core/org/jnode/util/ConsoleStream.java trunk/core/src/core/org/jnode/util/IOUtils.java trunk/core/src/core/org/jnode/util/ProxyStream.java trunk/core/src/core/org/jnode/util/ProxyStreamException.java Removed Paths: ------------- trunk/shell/src/shell/org/jnode/shell/proclet/ProxyStream.java trunk/shell/src/shell/org/jnode/shell/proclet/ProxyStreamException.java Added: trunk/core/src/core/org/jnode/util/ConsoleStream.java =================================================================== --- trunk/core/src/core/org/jnode/util/ConsoleStream.java (rev 0) +++ trunk/core/src/core/org/jnode/util/ConsoleStream.java 2008-09-21 04:44:44 UTC (rev 4567) @@ -0,0 +1,10 @@ +package org.jnode.util; + +/** + * This is a marker interface that is implemented by console readers and writers. + * + * @author crawley@jnode,org + */ +public interface ConsoleStream { + +} Added: trunk/core/src/core/org/jnode/util/IOUtils.java =================================================================== --- trunk/core/src/core/org/jnode/util/IOUtils.java (rev 0) +++ trunk/core/src/core/org/jnode/util/IOUtils.java 2008-09-21 04:44:44 UTC (rev 4567) @@ -0,0 +1,145 @@ +/* + * $Id: CommandShell.java 4556 2008-09-13 08:02:20Z crawley $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.jnode.util; + +import java.io.Closeable; +import java.io.FilterInputStream; +import java.io.FilterOutputStream; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintStream; +import java.io.Reader; +import java.io.Writer; +import java.lang.reflect.Field; +import java.security.PrivilegedAction; + +import org.apache.log4j.Logger; +import org.jnode.driver.console.spi.ConsoleWriter; +import org.jnode.driver.console.textscreen.KeyboardReader; + +/** + * Common utility code for higher-level operations on IO streams. Notwithstanding the + * nominal access for the class and its methods, user (command) code should avoid using + * this class directly. You should program against the + * {@link org.jnode.shell.io.CommandIO} API instead. + * + * @author cr...@jn... + */ +public class IOUtils { + + private IOUtils() { + // Prevent instantiation + } + + public static boolean isTTY(Closeable stream) { + if (stream instanceof ConsoleStream) { + return true; + } else if (stream instanceof ProxyStream<?>) { + try { + return isTTY(((ProxyStream<?>) stream).getRealStream()); + } catch (ProxyStreamException ex) { + return false; + } + } else if (stream instanceof OutputStreamWriter) { + return isTTY(findOutputStream((OutputStreamWriter) stream)); + } else if (stream instanceof InputStreamReader) { + return isTTY(findInputStream((InputStreamReader) stream)); + } else if (stream instanceof ReaderInputStream) { + return isTTY(((ReaderInputStream) stream).getReader()); + } else if (stream instanceof WriterOutputStream) { + return isTTY(((WriterOutputStream) stream).getWriter()); + } else if (stream instanceof FilterInputStream) { + return isTTY(findInputStream((FilterInputStream) stream)); + } else if (stream instanceof FilterOutputStream) { + return isTTY(findOutputStream((FilterOutputStream) stream)); + } else { + return false; + } + } + + private static InputStream findInputStream(final FilterInputStream inputStream) { + return new PrivilegedAction<InputStream>() { + public InputStream run() { + try { + Class<FilterInputStream> cls = FilterInputStream.class; + Field field = cls.getDeclaredField("in"); + Object in = field.get(inputStream); + return (InputStream) in; + } catch (Exception ex) { + Logger.getLogger(IOUtils.class).error("Cannot extract the 'in' field", ex); + return null; + } + }}.run(); + } + + private static OutputStream findOutputStream(final FilterOutputStream outputStream) { + return new PrivilegedAction<OutputStream>() { + public OutputStream run() { + try { + Class<FilterOutputStream> cls = FilterOutputStream.class; + Field field = cls.getDeclaredField("out"); + Object out = field.get(outputStream); + return (OutputStream) out; + } catch (Exception ex) { + Logger.getLogger(IOUtils.class).error("Cannot extract the 'out' field", ex); + return null; + } + }}.run(); + } + + + private static OutputStream findOutputStream(final OutputStreamWriter writer) { + // This implementation is based on the knowledge that an OutputStreamWriter + // uses the underlying OutputStream as its 'lock' object. + return new PrivilegedAction<OutputStream>() { + public OutputStream run() { + try { + Class<Writer> cls = Writer.class; + Field field = cls.getDeclaredField("lock"); + Object lock = field.get(writer); + return (OutputStream) lock; + } catch (Exception ex) { + Logger.getLogger(IOUtils.class).error("Cannot extract the 'lock' field", ex); + return null; + } + }}.run(); + } + + private static InputStream findInputStream(final InputStreamReader reader) { + // This implementation is based on the knowledge that an InputStreamReader + // uses the underlying InputStream as its 'lock' object. + return new PrivilegedAction<InputStream>() { + public InputStream run() { + try { + Class<Reader> cls = Reader.class; + Field field = cls.getDeclaredField("lock"); + Object lock = field.get(reader); + return (InputStream) lock; + } catch (Exception ex) { + Logger.getLogger(IOUtils.class).error("Cannot extract the 'lock' field", ex); + return null; + } + }}.run(); + } + +} Added: trunk/core/src/core/org/jnode/util/ProxyStream.java =================================================================== --- trunk/core/src/core/org/jnode/util/ProxyStream.java (rev 0) +++ trunk/core/src/core/org/jnode/util/ProxyStream.java 2008-09-21 04:44:44 UTC (rev 4567) @@ -0,0 +1,61 @@ +/* + * $Id: ThreadCommandInvoker.java 3374 2007-08-02 18:15:27Z lsantha $ + * + * JNode.org + * Copyright (C) 2007-2008 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.util; + +import java.io.Closeable; + +/** + * Proxy streams have an underlying stream and offer methods for getting that + * stream. + * + * @author cr...@jn... + */ +public interface ProxyStream<T extends Closeable> extends Closeable { + + /** + * Get the underlying (non-proxy) stream for this proxy. If there are + * multiple layers of proxying, these are unwound. + * + * @return a real (non-proxied) stream. + */ + public T getRealStream() throws ProxyStreamException; + + /** + * Get the stream that this proxy stream wraps. The result may also be a + * proxy stream. + * + * @return the wrapped stream for this proxy. + */ + public T getProxiedStream() throws ProxyStreamException; + + /** + * Determine if this proxy refers to the same underlying stream as another + * stream object. + * + * @param other + * @return <code>true</code> if this object and <code>other</code> + * resolve to the same underlying stream, otherwise false. Note: the + * 'otherwise' covers cases where <code>other</code> is + * <code>null</code>. + */ + public boolean sameStream(T other) throws ProxyStreamException; +} Added: trunk/core/src/core/org/jnode/util/ProxyStreamException.java =================================================================== --- trunk/core/src/core/org/jnode/util/ProxyStreamException.java (rev 0) +++ trunk/core/src/core/org/jnode/util/ProxyStreamException.java 2008-09-21 04:44:44 UTC (rev 4567) @@ -0,0 +1,44 @@ +/* + * $Id: ThreadCommandInvoker.java 3374 2007-08-02 18:15:27Z lsantha $ + * + * JNode.org + * Copyright (C) 2007-2008 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.util; + +import java.io.IOException; + +/** + * This exception indicates an error in a proxy stream mechanism + * + * @author cr...@jn... + */ +public class ProxyStreamException extends IOException { + + private static final long serialVersionUID = 1L; + + public ProxyStreamException(String message) { + super(message); + } + + public ProxyStreamException(String message, Throwable ex) { + super(message); + this.initCause(ex); + } + +} Modified: trunk/core/src/core/org/jnode/util/ReaderInputStream.java =================================================================== --- trunk/core/src/core/org/jnode/util/ReaderInputStream.java 2008-09-20 19:37:34 UTC (rev 4566) +++ trunk/core/src/core/org/jnode/util/ReaderInputStream.java 2008-09-21 04:44:44 UTC (rev 4567) @@ -23,6 +23,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.Reader; +import java.io.Writer; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.Charset; @@ -144,4 +145,8 @@ bytes.flip(); return count; } + + public Reader getReader() { + return reader; + } } Modified: trunk/core/src/core/org/jnode/util/WriterOutputStream.java =================================================================== --- trunk/core/src/core/org/jnode/util/WriterOutputStream.java 2008-09-20 19:37:34 UTC (rev 4566) +++ trunk/core/src/core/org/jnode/util/WriterOutputStream.java 2008-09-21 04:44:44 UTC (rev 4567) @@ -121,4 +121,8 @@ public void write(byte[] b) throws IOException { this.write(b, 0, b.length); } + + Writer getWriter() { + return writer; + } } Modified: trunk/core/src/driver/org/jnode/driver/console/spi/ConsoleWriter.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/console/spi/ConsoleWriter.java 2008-09-20 19:37:34 UTC (rev 4566) +++ trunk/core/src/driver/org/jnode/driver/console/spi/ConsoleWriter.java 2008-09-21 04:44:44 UTC (rev 4567) @@ -24,13 +24,14 @@ import java.io.IOException; import java.io.Writer; import org.jnode.driver.console.TextConsole; +import org.jnode.util.ConsoleStream; import org.jnode.vm.Unsafe; /** * @author epr * @author Levente S\u00e1ntha (ls...@us...) */ -public class ConsoleWriter extends Writer { +public class ConsoleWriter extends Writer implements ConsoleStream { private TextConsole console; private int fgColor; Modified: trunk/core/src/driver/org/jnode/driver/console/textscreen/KeyboardReader.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/console/textscreen/KeyboardReader.java 2008-09-20 19:37:34 UTC (rev 4566) +++ trunk/core/src/driver/org/jnode/driver/console/textscreen/KeyboardReader.java 2008-09-21 04:44:44 UTC (rev 4567) @@ -11,6 +11,7 @@ import org.jnode.driver.input.KeyboardEvent; import org.jnode.system.event.FocusEvent; import org.jnode.system.event.FocusListener; +import org.jnode.util.ConsoleStream; /** @@ -22,7 +23,7 @@ * <li>listens to keyboard focus events. * </ul> * <p/> - * Future enhancements include: + * Possible future enhancements include: * <ul> * <li>a "raw" mode in which characters and other keyboard events are delivered without line editing, * <li>a "no echo" mode in which line editing occurs without echoing of input characters, @@ -40,8 +41,8 @@ * * @author cr...@jn... */ -public class KeyboardReader extends Reader - implements FocusListener { +public class KeyboardReader extends Reader + implements FocusListener, ConsoleStream { public static final byte CTRL_L = 12; public static final byte CTRL_D = 4; Modified: trunk/shell/src/shell/org/jnode/shell/io/CommandIOMarker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/io/CommandIOMarker.java 2008-09-20 19:37:34 UTC (rev 4566) +++ trunk/shell/src/shell/org/jnode/shell/io/CommandIOMarker.java 2008-09-21 04:44:44 UTC (rev 4567) @@ -89,6 +89,4 @@ public Writer getWriter() throws CommandIOException { throw new CommandIOException("I/O not supported on CommandIOMarker"); } - - } Modified: trunk/shell/src/shell/org/jnode/shell/io/CommandInput.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/io/CommandInput.java 2008-09-20 19:37:34 UTC (rev 4566) +++ trunk/shell/src/shell/org/jnode/shell/io/CommandInput.java 2008-09-21 04:44:44 UTC (rev 4567) @@ -30,6 +30,7 @@ import java.io.UnsupportedEncodingException; import java.io.Writer; +import org.jnode.util.IOUtils; import org.jnode.util.ReaderInputStream; /** @@ -77,8 +78,12 @@ @Override public boolean isTTY() { - // TODO Auto-generated method stub - return false; + Object obj = getSystemObject(); + if (obj instanceof Reader) { + return IOUtils.isTTY((Reader) obj); + } else { + return IOUtils.isTTY((InputStream) obj); + } } public void close() throws IOException { @@ -109,6 +114,4 @@ public Writer getWriter() throws CommandIOException { throw new CommandIOException("Output not supported"); } - - } Modified: trunk/shell/src/shell/org/jnode/shell/io/CommandInputOutput.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/io/CommandInputOutput.java 2008-09-20 19:37:34 UTC (rev 4566) +++ trunk/shell/src/shell/org/jnode/shell/io/CommandInputOutput.java 2008-09-21 04:44:44 UTC (rev 4567) @@ -31,6 +31,7 @@ import java.io.UnsupportedEncodingException; import java.io.Writer; +import org.jnode.util.IOUtils; import org.jnode.util.ReaderInputStream; import org.jnode.util.WriterOutputStream; @@ -58,10 +59,7 @@ this.reader = reader; this.writer = writer; } - - /* (non-Javadoc) - * @see org.jnode.shell.io.CommandIOIF#getOutputStream() - */ + public synchronized OutputStream getOutputStream() { if (outputStream == null) { outputStream = new WriterOutputStream(writer, getEncoding()); @@ -69,9 +67,6 @@ return outputStream; } - /* (non-Javadoc) - * @see org.jnode.shell.io.CommandIOIF#getPrintStream() - */ public PrintStream getPrintStream() { if (printStream == null) { if (outputStream instanceof PrintStream) { @@ -82,10 +77,7 @@ } return printStream; } - - /* (non-Javadoc) - * @see org.jnode.shell.io.CommandIOIF#getWriter() - */ + public synchronized Writer getWriter() throws CommandIOException { if (writer == null) { try { @@ -97,9 +89,6 @@ return writer; } - /* (non-Javadoc) - * @see org.jnode.shell.io.CommandIOIF#getPrintWriter() - */ public PrintWriter getPrintWriter() { if (printWriter == null) { if (writer instanceof PrintWriter) { @@ -110,20 +99,14 @@ } return printWriter; } - - /* (non-Javadoc) - * @see org.jnode.shell.io.CommandIOIF#getInputStream() - */ + public synchronized InputStream getInputStream() { if (inputStream == null) { inputStream = new ReaderInputStream(reader, getEncoding()); } return inputStream; } - - /* (non-Javadoc) - * @see org.jnode.shell.io.CommandIOIF#getReader() - */ + public Reader getReader() throws CommandIOException { if (reader == null) { try { @@ -134,25 +117,21 @@ } return reader; } - - /* (non-Javadoc) - * @see org.jnode.shell.io.CommandIOIF#getDirection() - */ + public final int getDirection() { return DIRECTION_INOUT; } - /* (non-Javadoc) - * @see org.jnode.shell.io.CommandIOIF#isTTY() - */ @Override public boolean isTTY() { - return false; + Object obj = getSystemObject(); + if (obj instanceof Writer) { + return IOUtils.isTTY((Writer) obj); + } else { + return IOUtils.isTTY((OutputStream) obj); + } } - /* (non-Javadoc) - * @see org.jnode.shell.io.CommandIOIF#close() - */ @Override public void close() throws IOException { flush(); Modified: trunk/shell/src/shell/org/jnode/shell/io/CommandOutput.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/io/CommandOutput.java 2008-09-20 19:37:34 UTC (rev 4566) +++ trunk/shell/src/shell/org/jnode/shell/io/CommandOutput.java 2008-09-21 04:44:44 UTC (rev 4567) @@ -30,6 +30,7 @@ import java.io.UnsupportedEncodingException; import java.io.Writer; +import org.jnode.util.IOUtils; import org.jnode.util.WriterOutputStream; /** @@ -99,7 +100,12 @@ @Override public boolean isTTY() { - return false; + Object obj = getSystemObject(); + if (obj instanceof Writer) { + return IOUtils.isTTY((Writer) obj); + } else { + return IOUtils.isTTY((OutputStream) obj); + } } public void close() throws IOException { Modified: trunk/shell/src/shell/org/jnode/shell/proclet/AbstractProxyPrintStream.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/proclet/AbstractProxyPrintStream.java 2008-09-20 19:37:34 UTC (rev 4566) +++ trunk/shell/src/shell/org/jnode/shell/proclet/AbstractProxyPrintStream.java 2008-09-21 04:44:44 UTC (rev 4567) @@ -53,6 +53,8 @@ import java.util.Formatter; import java.util.Locale; +import org.jnode.util.ProxyStream; + /** * This class provides some infrastructure for PrintStream proxies. * Modified: trunk/shell/src/shell/org/jnode/shell/proclet/ProcletContext.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/proclet/ProcletContext.java 2008-09-20 19:37:34 UTC (rev 4566) +++ trunk/shell/src/shell/org/jnode/shell/proclet/ProcletContext.java 2008-09-21 04:44:44 UTC (rev 4567) @@ -30,6 +30,8 @@ import org.jnode.shell.CommandThread; import org.jnode.shell.CommandThreadImpl; +import org.jnode.util.ProxyStream; +import org.jnode.util.ProxyStreamException; import org.jnode.vm.VmExit; import org.jnode.vm.VmSystem; Modified: trunk/shell/src/shell/org/jnode/shell/proclet/ProcletIOContext.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/proclet/ProcletIOContext.java 2008-09-20 19:37:34 UTC (rev 4566) +++ trunk/shell/src/shell/org/jnode/shell/proclet/ProcletIOContext.java 2008-09-21 04:44:44 UTC (rev 4567) @@ -24,6 +24,7 @@ import java.io.InputStream; import java.io.PrintStream; +import org.jnode.util.ProxyStreamException; import org.jnode.vm.IOContext; import org.jnode.vm.VmSystem; Modified: trunk/shell/src/shell/org/jnode/shell/proclet/ProcletProxyInputStream.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/proclet/ProcletProxyInputStream.java 2008-09-20 19:37:34 UTC (rev 4566) +++ trunk/shell/src/shell/org/jnode/shell/proclet/ProcletProxyInputStream.java 2008-09-21 04:44:44 UTC (rev 4567) @@ -24,6 +24,8 @@ import java.io.IOException; import java.io.InputStream; +import org.jnode.util.ProxyStream; +import org.jnode.util.ProxyStreamException; import org.jnode.vm.VmSystem; /** Modified: trunk/shell/src/shell/org/jnode/shell/proclet/ProcletProxyPrintStream.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/proclet/ProcletProxyPrintStream.java 2008-09-20 19:37:34 UTC (rev 4566) +++ trunk/shell/src/shell/org/jnode/shell/proclet/ProcletProxyPrintStream.java 2008-09-21 04:44:44 UTC (rev 4567) @@ -23,6 +23,8 @@ import java.io.PrintStream; +import org.jnode.util.ProxyStream; +import org.jnode.util.ProxyStreamException; import org.jnode.vm.VmSystem; /** Modified: trunk/shell/src/shell/org/jnode/shell/proclet/ProcletProxyStream.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/proclet/ProcletProxyStream.java 2008-09-20 19:37:34 UTC (rev 4566) +++ trunk/shell/src/shell/org/jnode/shell/proclet/ProcletProxyStream.java 2008-09-21 04:44:44 UTC (rev 4567) @@ -23,6 +23,8 @@ import java.io.Closeable; +import org.jnode.util.ProxyStream; + interface ProcletProxyStream<T extends Closeable> extends ProxyStream<T> { } Deleted: trunk/shell/src/shell/org/jnode/shell/proclet/ProxyStream.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/proclet/ProxyStream.java 2008-09-20 19:37:34 UTC (rev 4566) +++ trunk/shell/src/shell/org/jnode/shell/proclet/ProxyStream.java 2008-09-21 04:44:44 UTC (rev 4567) @@ -1,61 +0,0 @@ -/* - * $Id: ThreadCommandInvoker.java 3374 2007-08-02 18:15:27Z lsantha $ - * - * JNode.org - * Copyright (C) 2007-2008 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.shell.proclet; - -import java.io.Closeable; - -/** - * Proxy streams have an underlying stream and offer methods for getting that - * stream. - * - * @author cr...@jn... - */ -public interface ProxyStream<T extends Closeable> { - - /** - * Get the underlying (non-proxy) stream for this proxy. If there are - * multiple layers of proxying, these are unwound. - * - * @return a real (non-proxied) stream. - */ - public T getRealStream() throws ProxyStreamException; - - /** - * Get the stream that this proxy stream wraps. The result may also be a - * proxy stream. - * - * @return the wrapped stream for this proxy. - */ - public T getProxiedStream() throws ProxyStreamException; - - /** - * Determine if this proxy refers to the same underlying stream as another - * stream object. - * - * @param other - * @return <code>true</code> if this object and <code>other</code> - * resolve to the same underlying stream, otherwise false. Note: the - * 'otherwise' covers cases where <code>other</code> is - * <code>null</code>. - */ - public boolean sameStream(T other) throws ProxyStreamException; -} Deleted: trunk/shell/src/shell/org/jnode/shell/proclet/ProxyStreamException.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/proclet/ProxyStreamException.java 2008-09-20 19:37:34 UTC (rev 4566) +++ trunk/shell/src/shell/org/jnode/shell/proclet/ProxyStreamException.java 2008-09-21 04:44:44 UTC (rev 4567) @@ -1,44 +0,0 @@ -/* - * $Id: ThreadCommandInvoker.java 3374 2007-08-02 18:15:27Z lsantha $ - * - * JNode.org - * Copyright (C) 2007-2008 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.shell.proclet; - -import java.io.IOException; - -/** - * This exception indicates an error in a proxy stream mechanism - * - * @author cr...@jn... - */ -public class ProxyStreamException extends IOException { - - private static final long serialVersionUID = 1L; - - public ProxyStreamException(String message) { - super(message); - } - - public ProxyStreamException(String message, Throwable ex) { - super(message); - this.initCause(ex); - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |