jay.yydebug
Class yyInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by jay.yydebug.yyInputStream
All Implemented Interfaces:
KeyListener, Closeable, EventListener

public class yyInputStream
extends InputStream
implements KeyListener

used to reroute standard input from a TextArea. Feeds all read methods from listening to typed keys. Should not deadlock because one should generally not read from within the event thread.

While this implementation uses Java generics, code for a non-generic version has simply been commented out.


Field Summary
protected  StringBuffer line
          line edit buffer.
protected  ArrayList queue
          completed lines, ready to be read.
 
Constructor Summary
yyInputStream()
           
 
Method Summary
 int available()
           
 void close()
           
 void keyPressed(KeyEvent ke)
          this one ensures that you can only type at the end.
 void keyReleased(KeyEvent ke)
           
 void keyTyped(KeyEvent ke)
           
 int read()
           
 int read(byte[] b, int off, int len)
           
 long skip(long len)
          returns 0: cannot skip on a terminal.
 
Methods inherited from class java.io.InputStream
mark, markSupported, read, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

line

protected final StringBuffer line
line edit buffer.


queue

protected ArrayList queue
completed lines, ready to be read. Invariant: null after close().

Constructor Detail

yyInputStream

public yyInputStream()
Method Detail

available

public int available()
              throws IOException
Overrides:
available in class InputStream
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException

read

public int read()
         throws IOException
Specified by:
read in class InputStream
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

skip

public long skip(long len)
returns 0: cannot skip on a terminal.

Overrides:
skip in class InputStream

keyPressed

public void keyPressed(KeyEvent ke)
this one ensures that you can only type at the end. This is executed within the event thread.

Specified by:
keyPressed in interface KeyListener

keyTyped

public void keyTyped(KeyEvent ke)
Specified by:
keyTyped in interface KeyListener

keyReleased

public void keyReleased(KeyEvent ke)
Specified by:
keyReleased in interface KeyListener