Package org.jline.utils
Class PumpReader
java.lang.Object
java.io.Reader
org.jline.utils.PumpReader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
A reader implementation with an associated writer for buffered character transfer.
The PumpReader class provides a Reader implementation with an associated Writer that allows characters to be written to the writer and then read from the reader. This creates a character pipe or pump that can be used to transfer character data between different components.
This class is particularly useful for:
- Creating character streams for testing without actual I/O
- Buffering characters between producer and consumer threads
- Implementing character-based pipes with flow control
- Simulating input for terminal emulation
The PumpReader maintains internal buffers for reading and writing, with both buffers backed by the same array. It provides methods for reading characters with optional timeouts and for checking the availability of characters without blocking.
This class is used in JLine for various purposes, including implementing non-blocking readers and for testing terminal input handling without actual terminal devices.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
void
close()
createInputStream
(Charset charset) int
read()
int
read
(char[] cbuf, int off, int len) int
read
(CharBuffer target) boolean
ready()
Methods inherited from class java.io.Reader
mark, markSupported, nullReader, read, reset, skip, transferTo
-
Constructor Details
-
PumpReader
public PumpReader() -
PumpReader
public PumpReader(int bufferSize)
-
-
Method Details
-
getWriter
-
createInputStream
-
ready
public boolean ready() -
available
public int available() -
read
- Overrides:
read
in classReader
- Throws:
IOException
-
read
- Specified by:
read
in classReader
- Throws:
IOException
-
read
- Specified by:
read
in interfaceReadable
- Overrides:
read
in classReader
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classReader
- Throws:
IOException
-