org.shlublu.javax.awt
Class TextComponentInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--org.shlublu.javax.awt.TextComponentInputStream
All Implemented Interfaces:
java.util.EventListener, java.awt.event.KeyListener

public class TextComponentInputStream
extends java.io.InputStream
implements java.awt.event.KeyListener

Creation : 1 sept 2001 InputStream which read from standard awt TextComponent. Revision 2001/12/28 : added history recall by typing 'arrows' Revision 2002/01/02 : slight amelioration on history recall

Since:
0.1
See Also:
InputStream

Constructor Summary
TextComponentInputStream(java.awt.TextComponent componentGiven)
          Constructor
TextComponentInputStream(java.awt.TextComponent componentGiven, int iHLen)
          Constructor.
 
Method Summary
 int available()
          number of available characters, according to the java.io.InputStream specification
 void close()
          Close the stream, so it can't be used anymore.
 void keyPressed(java.awt.event.KeyEvent e)
          Browse the history
 void keyReleased(java.awt.event.KeyEvent e)
          do nothing, just implement the interface
 void keyTyped(java.awt.event.KeyEvent e)
          Process key events.
 void mark(int readlimit)
          unused
 boolean markSupported()
          always return false.
 int read()
          read a char, according to the java.io.InputStream specifications
 int read(byte[] aby)
          read a in a byte array, according to the java.io.InputStream specification
 int read(byte[] aby, int iStart, int iLen)
          read a in a byte array, according to the java.io.InputStream specification
 void reset()
          always throws an IOException.
 long skip(long lSkip)
          skip the given number of available characters, according to the java.io.InputStream specification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextComponentInputStream

public TextComponentInputStream(java.awt.TextComponent componentGiven)
Constructor
Parameters:
TextComponent - The component to read from

TextComponentInputStream

public TextComponentInputStream(java.awt.TextComponent componentGiven,
                                int iHLen)
Constructor. The given int is the history length
Parameters:
TextComponent - The component to read from
int - History size
Method Detail

read

public int read()
         throws java.io.IOException
read a char, according to the java.io.InputStream specifications
Overrides:
read in class java.io.InputStream
Returns:
int the read character, or -1 if none available
Throws:
java.io.IOException - as java.lang.InputStream define

read

public int read(byte[] aby)
         throws java.io.IOException
read a in a byte array, according to the java.io.InputStream specification
Overrides:
read in class java.io.InputStream
Parameters:
byte - [] the array to read in
Returns:
int the number of read characters
Throws:
java.io.IOException - as java.lang.InputStream define
NullPointerException - if the given array is null

read

public int read(byte[] aby,
                int iStart,
                int iLen)
         throws java.io.IOException
read a in a byte array, according to the java.io.InputStream specification
Overrides:
read in class java.io.InputStream
Parameters:
byte - [] the array to read in
int - iStart the index to begin at
int - iLen the length to read
Returns:
int the number of read characters
Throws:
java.io.IOException - as java.lang.InputStream define
NullPointerException - if the given array is null
java.lang.IndexOutOfBoundsException - if the indexes or length are wrong

available

public int available()
              throws java.io.IOException
number of available characters, according to the java.io.InputStream specification
Overrides:
available in class java.io.InputStream
Returns:
int the number of readable characters
Throws:
java.io.IOException - as java.lang.InputStream define

mark

public void mark(int readlimit)
unused
Overrides:
mark in class java.io.InputStream
See Also:
InputStream.mark(int)

markSupported

public boolean markSupported()
always return false. Marks aren't supported for this stream.
Overrides:
markSupported in class java.io.InputStream
See Also:
InputStream.markSupported()

reset

public void reset()
           throws java.io.IOException
always throws an IOException.
Overrides:
reset in class java.io.InputStream
See Also:
InputStream.reset()

skip

public long skip(long lSkip)
          throws java.io.IOException
skip the given number of available characters, according to the java.io.InputStream specification
Overrides:
skip in class java.io.InputStream
Parameters:
long - the number of characters to skip
Returns:
long the number of skipped characters
Throws:
java.io.IOException - as java.lang.InputStream define

close

public void close()
           throws java.io.IOException
Close the stream, so it can't be used anymore.
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException - as java.lang.InputStream define

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Process key events. The only matched one is '\n', to append the buffer and empty the component.
Specified by:
keyTyped in interface java.awt.event.KeyListener
See Also:
TextComponentInputStream#flushIn

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Browse the history
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
do nothing, just implement the interface
Specified by:
keyReleased in interface java.awt.event.KeyListener