Package org.apache.commons.net.telnet
Class TelnetInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- java.io.BufferedInputStream
-
- org.apache.commons.net.telnet.TelnetInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Runnable
final class TelnetInputStream extends java.io.BufferedInputStream implements java.lang.Runnable
-
-
Field Summary
Fields Modifier and Type Field Description 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
(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
private static int
EOF
End of file has been reachedprivate static int
WOULD_BLOCK
Read would block
-
Constructor Summary
Constructors Constructor Description TelnetInputStream(java.io.InputStream input, TelnetClient client)
TelnetInputStream(java.io.InputStream input, TelnetClient client, boolean readerThread)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
__processChar(int ch)
private int
__read(boolean mayBlock)
Get the next byte of data.(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()
-
-
-
Field Detail
-
EOF
private static final int EOF
End of file has been reached- See Also:
- Constant Field Values
-
WOULD_BLOCK
private static final int WOULD_BLOCK
Read would block- See Also:
- Constant Field Values
-
_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 volatile boolean __isClosed
-
__readIsWaiting
private boolean __readIsWaiting
-
__receiveState
private int __receiveState
-
__queueHead
private int __queueHead
-
__queueTail
private int __queueTail
-
__bytesAvailable
private int __bytesAvailable
-
__queue
private final int[] __queue
-
__client
private final TelnetClient __client
-
__thread
private final java.lang.Thread __thread
-
__ioException
private java.io.IOException __ioException
-
__suboption
private final int[] __suboption
-
__suboption_count
private int __suboption_count
-
__threaded
private volatile boolean __threaded
-
-
Constructor Detail
-
TelnetInputStream
TelnetInputStream(java.io.InputStream input, TelnetClient client, boolean readerThread)
-
TelnetInputStream
TelnetInputStream(java.io.InputStream input, TelnetClient client)
-
-
Method Detail
-
_start
void _start()
-
__read
private int __read(boolean mayBlock) throws java.io.IOException
Get the next byte of data. IAC commands are processed internally and do not return data.- Parameters:
mayBlock
- true if method is allowed to block- Returns:
- the next byte of data, or -1 (EOF) if end of stread reached, or -2 (WOULD_BLOCK) if mayBlock is false and there is no data available
- Throws:
java.io.IOException
-
__processChar
private boolean __processChar(int ch) throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
read
public int read() throws java.io.IOException
- Overrides:
read
in classjava.io.BufferedInputStream
- 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.- Overrides:
read
in classjava.io.FilterInputStream
- 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.- Overrides:
read
in classjava.io.BufferedInputStream
- 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.- Overrides:
markSupported
in classjava.io.BufferedInputStream
-
available
public int available() throws java.io.IOException
- Overrides:
available
in classjava.io.BufferedInputStream
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.BufferedInputStream
- Throws:
java.io.IOException
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
-