org.apache.commons.net.telnet
Class TelnetInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended byjava.io.FilterInputStream
          extended byjava.io.BufferedInputStream
              extended byorg.apache.commons.net.telnet.TelnetInputStream
All Implemented Interfaces:
java.lang.Runnable

final class TelnetInputStream
extends java.io.BufferedInputStream
implements java.lang.Runnable

Author:
Daniel F. Savarese, Bruno D'Avanzo

Field Summary
private  int __bytesAvailable
           
private  TelnetClient __client
           
private  boolean __hasReachedEOF
           
private  java.io.IOException __ioException
           
private  boolean __isClosed
           
private  int[] __queue
           
private  int __queueHead
           
private  int __queueTail
           
private  boolean __readIsWaiting
           
private  int __receiveState
           
private  int[] __suboption
           
private  int __suboption_count
           
private  java.lang.Thread __thread
           
private  boolean __threaded
           
private  boolean _ayt_flag
           
(package private) static int _STATE_CR
           
(package private) static int _STATE_DATA
           
(package private) static int _STATE_DO
           
(package private) static int _STATE_DONT
           
(package private) static int _STATE_IAC
           
(package private) static int _STATE_IAC_SB
           
(package private) static int _STATE_SB
           
(package private) static int _STATE_SE
           
(package private) static int _STATE_WILL
           
(package private) static int _STATE_WONT
           
 
Fields inherited from class java.io.BufferedInputStream
buf, count, marklimit, markpos, pos
 
Fields inherited from class java.io.FilterInputStream
in
 
Fields inherited from class java.io.InputStream
 
Constructor Summary
(package private) TelnetInputStream(java.io.InputStream input, TelnetClient client)
           
 
Method Summary
private  void __processChar(int ch)
           
private  int __read()
           
(package private)  void _start()
           
 int available()
           
 void close()
           
 boolean markSupported()
          Returns false.
 int read()
           
 int read(byte[] buffer)
          Reads the next number of bytes from the stream into an array and returns the number of bytes read.
 int read(byte[] buffer, int offset, int length)
          Reads the next number of bytes from the stream into an array and returns the number of bytes read.
 void run()
           
 
Methods inherited from class java.io.BufferedInputStream
mark, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_STATE_DATA

static final int _STATE_DATA
See Also:
Constant Field Values

_STATE_IAC

static final int _STATE_IAC
See Also:
Constant Field Values

_STATE_WILL

static final int _STATE_WILL
See Also:
Constant Field Values

_STATE_WONT

static final int _STATE_WONT
See Also:
Constant Field Values

_STATE_DO

static final int _STATE_DO
See Also:
Constant Field Values

_STATE_DONT

static final int _STATE_DONT
See Also:
Constant Field Values

_STATE_SB

static final int _STATE_SB
See Also:
Constant Field Values

_STATE_SE

static final int _STATE_SE
See Also:
Constant Field Values

_STATE_CR

static final int _STATE_CR
See Also:
Constant Field Values

_STATE_IAC_SB

static final int _STATE_IAC_SB
See Also:
Constant Field Values

__hasReachedEOF

private boolean __hasReachedEOF

__isClosed

private boolean __isClosed

__readIsWaiting

private boolean __readIsWaiting

__receiveState

private int __receiveState

__queueHead

private int __queueHead

__queueTail

private int __queueTail

__bytesAvailable

private int __bytesAvailable

__queue

private int[] __queue

__client

private TelnetClient __client

__thread

private java.lang.Thread __thread

__ioException

private java.io.IOException __ioException

__suboption

private int[] __suboption

__suboption_count

private int __suboption_count

_ayt_flag

private boolean _ayt_flag

__threaded

private boolean __threaded
Constructor Detail

TelnetInputStream

TelnetInputStream(java.io.InputStream input,
                  TelnetClient client)
Method Detail

_start

void _start()

__read

private int __read()
            throws java.io.IOException
Throws:
java.io.IOException

__processChar

private void __processChar(int ch)
                    throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

read

public int read()
         throws java.io.IOException
Throws:
java.io.IOException

read

public int read(byte[] buffer)
         throws java.io.IOException
Reads the next number of bytes from the stream into an array and returns the number of bytes read. Returns -1 if the end of the stream has been reached.

Parameters:
buffer - The byte array in which to store the data.
Returns:
The number of bytes read. Returns -1 if the end of the message has been reached.
Throws:
java.io.IOException - If an error occurs in reading the underlying stream.

read

public int read(byte[] buffer,
                int offset,
                int length)
         throws java.io.IOException
Reads the next number of bytes from the stream into an array and returns the number of bytes read. Returns -1 if the end of the message has been reached. The characters are stored in the array starting from the given offset and up to the length specified.

Parameters:
buffer - The byte array in which to store the data.
offset - The offset into the array at which to start storing data.
length - The number of bytes to read.
Returns:
The number of bytes read. Returns -1 if the end of the stream has been reached.
Throws:
java.io.IOException - If an error occurs while reading the underlying stream.

markSupported

public boolean markSupported()
Returns false. Mark is not supported.


available

public int available()
              throws java.io.IOException
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException

run

public void run()
Specified by:
run in interface java.lang.Runnable