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 intbytesAvailableprivate TelnetClientclientprivate static intEOFEnd of file has been reachedprivate booleanhasReachedEOFprivate java.io.IOExceptionioExceptionprivate booleanisClosedprivate int[]queueprivate intqueueHeadprivate intqueueTailprivate booleanreadIsWaitingprivate intreceiveState(package private) static intSTATE_CR(package private) static intSTATE_DATA(package private) static intSTATE_DO(package private) static intSTATE_DONT(package private) static intSTATE_IAC(package private) static intSTATE_IAC_SB(package private) static intSTATE_SB(package private) static intSTATE_SE(package private) static intSTATE_WILL(package private) static intSTATE_WONTprivate int[]suboptionprivate intsuboptionCountprivate java.lang.Threadthreadprivate booleanthreadedprivate static intWOULD_BLOCKRead 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 intavailable()voidclose()booleanmarkSupported()Returns false.private booleanprocessChar(int ch)intread()private intread(boolean mayBlock)Get the next byte of data.intread(byte[] buffer)Reads the next number of bytes from the stream into an array and returns the number of bytes read.intread(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.voidrun()(package private) voidstart()
-
-
-
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
-
suboptionCount
private int suboptionCount
-
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.IOExceptionGet 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:
readin classjava.io.BufferedInputStream- Throws:
java.io.IOException
-
read
public int read(byte[] buffer) throws java.io.IOExceptionReads 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:
readin 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.IOExceptionReads 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:
readin 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:
markSupportedin classjava.io.BufferedInputStream
-
available
public int available() throws java.io.IOException- Overrides:
availablein classjava.io.BufferedInputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.BufferedInputStream- Throws:
java.io.IOException
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
-