Package org.jline.utils
Class PumpReader
java.lang.Object
java.io.Reader
org.jline.utils.PumpReader
- All Implemented Interfaces:
Closeable,AutoCloseable,Readable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate static final intprivate static final intprivate final CharBufferprivate final CharBufferprivate final PumpReader.Writer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()private intcopyFromBuffer(char[] cbuf, int off, int len) createInputStream(Charset charset) private voidencodeBytes(CharsetEncoder encoder, ByteBuffer output) (package private) voidflush()intread()intread(char[] cbuf, int off, int len) intread(CharBuffer target) (package private) intreadBytes(CharsetEncoder encoder, byte[] b, int off, int len) (package private) voidreadBytes(CharsetEncoder encoder, ByteBuffer output) booleanready()private static booleanrewind(CharBuffer buffer, CharBuffer other) private booleanAttempts to find additional input by rewinding thereadBuffer.private voidAttempts to find additional buffer space by rewinding thewriteBuffer.private booleanwait(CharBuffer buffer) Waits untilbuffer.hasRemaining() == true, or it is false and the reader isclosed.private voidBlocks until there is new space available for buffering or the reader is closed.private booleanBlocks until input is available or the reader is closed.private booleanBlocks until more input is available, even ifreadBufferalready contains some chars; or until the reader is closed.(package private) voidwrite(char c) (package private) voidwrite(char[] cbuf, int off, int len) (package private) voidMethods inherited from class java.io.Reader
mark, markSupported, nullReader, read, reset, skip, transferTo
-
Field Details
-
EOF
private static final int EOF- See Also:
-
DEFAULT_BUFFER_SIZE
private static final int DEFAULT_BUFFER_SIZE- See Also:
-
readBuffer
-
writeBuffer
-
writer
-
closed
private boolean closed
-
-
Constructor Details
-
PumpReader
public PumpReader() -
PumpReader
public PumpReader(int bufferSize)
-
-
Method Details
-
getWriter
-
createInputStream
-
waitForMoreInput
Blocks until more input is available, even ifreadBufferalready contains some chars; or until the reader is closed.- Returns:
- true if more input is available, false if no additional input is available and the reader is closed
- Throws:
InterruptedIOException- IfObject.wait()is interrupted
-
wait
Waits untilbuffer.hasRemaining() == true, or it is false and the reader isclosed.- Returns:
- true if
buffer.hasRemaining() == true; false otherwise when reader is closed - Throws:
InterruptedIOException
-
waitForInput
Blocks until input is available or the reader is closed.- Returns:
- true if input is available, false if no input is available and the reader is closed
- Throws:
InterruptedIOException- IfObject.wait()is interrupted
-
waitForBufferSpace
Blocks until there is new space available for buffering or the reader is closed.- Throws:
InterruptedIOException- IfObject.wait()is interruptedClosedException- If the reader was closed
-
rewind
-
rewindReadBuffer
private boolean rewindReadBuffer()Attempts to find additional input by rewinding thereadBuffer. Updates thewriteBufferto make read bytes available for buffering.- Returns:
- If more input is available
-
rewindWriteBuffer
private void rewindWriteBuffer()Attempts to find additional buffer space by rewinding thewriteBuffer. Updates thereadBufferto make written bytes available to the reader. -
ready
public boolean ready() -
available
public int available() -
read
- Overrides:
readin classReader- Throws:
IOException
-
copyFromBuffer
private int copyFromBuffer(char[] cbuf, int off, int len) -
read
- Specified by:
readin classReader- Throws:
IOException
-
read
- Specified by:
readin interfaceReadable- Overrides:
readin classReader- Throws:
IOException
-
encodeBytes
- Throws:
IOException
-
readBytes
- Throws:
IOException
-
readBytes
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
flush
void flush() -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classReader- Throws:
IOException
-