Package org.jline.utils
Class NonBlocking.NonBlockingInputStreamReader
- java.lang.Object
-
- java.io.Reader
-
- org.jline.utils.NonBlockingReader
-
- org.jline.utils.NonBlocking.NonBlockingInputStreamReader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Readable
- Enclosing class:
- NonBlocking
private static class NonBlocking.NonBlockingInputStreamReader extends NonBlockingReader
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.ByteBuffer
bytes
private java.nio.CharBuffer
chars
private java.nio.charset.CharsetDecoder
decoder
private NonBlockingInputStream
input
-
Fields inherited from class org.jline.utils.NonBlockingReader
EOF, READ_EXPIRED
-
-
Constructor Summary
Constructors Constructor Description NonBlockingInputStreamReader(NonBlockingInputStream inputStream, java.nio.charset.Charset encoding)
NonBlockingInputStreamReader(NonBlockingInputStream input, java.nio.charset.CharsetDecoder decoder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
protected int
read(long timeout, boolean isPeek)
Attempts to read a character from the input stream for a specific period of time.int
readBuffered(char[] b, int off, int len, long timeout)
void
shutdown()
Shuts down the thread that is handling blocking I/O.-
Methods inherited from class org.jline.utils.NonBlockingReader
available, peek, read, read, read, readBuffered, readBuffered
-
-
-
-
Field Detail
-
input
private final NonBlockingInputStream input
-
decoder
private final java.nio.charset.CharsetDecoder decoder
-
bytes
private final java.nio.ByteBuffer bytes
-
chars
private final java.nio.CharBuffer chars
-
-
Constructor Detail
-
NonBlockingInputStreamReader
public NonBlockingInputStreamReader(NonBlockingInputStream inputStream, java.nio.charset.Charset encoding)
-
NonBlockingInputStreamReader
public NonBlockingInputStreamReader(NonBlockingInputStream input, java.nio.charset.CharsetDecoder decoder)
-
-
Method Detail
-
read
protected int read(long timeout, boolean isPeek) throws java.io.IOException
Description copied from class:NonBlockingReader
Attempts to read a character from the input stream for a specific period of time.- Specified by:
read
in classNonBlockingReader
- Parameters:
timeout
- The amount of time to wait for the characterisPeek
-true
if the character read must not be consumed- Returns:
- The character read, -1 if EOF is reached, or -2 if the read timed out.
- Throws:
java.io.IOException
- if anything wrong happens
-
readBuffered
public int readBuffered(char[] b, int off, int len, long timeout) throws java.io.IOException
- Specified by:
readBuffered
in classNonBlockingReader
- Throws:
java.io.IOException
-
shutdown
public void shutdown()
Description copied from class:NonBlockingReader
Shuts down the thread that is handling blocking I/O. Note that if the thread is currently blocked waiting for I/O it will not actually shut down until the I/O is received.- Overrides:
shutdown
in classNonBlockingReader
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classjava.io.Reader
- Throws:
java.io.IOException
-
-