public interface CharReadable extends Closeable, SourceTraceability
Readable, but focused on char[], via a SectionedCharBuffer with one of the main reasons
that Reader.read(CharBuffer) creates a new char[] as big as the data it's about to read
every call. However Reader.read(char[], int, int) doesn't, and so leaves no garbage.
The fact that this is a separate interface means that Readable instances need to be wrapped,
but that's fine since the buffer size should be reasonably big such that read(SectionedCharBuffer, int)
isn't called too often. Therefore the wrapping overhead should not be noticeable at all.
Also took the opportunity to let CharReadable extends Closeable, something that
Readable doesn't.| Modifier and Type | Interface and Description |
|---|---|
static class |
CharReadable.Adapter |
EMPTY| Modifier and Type | Method and Description |
|---|---|
int |
read(char[] into,
int offset,
int length)
Reads characters into the given array starting at
offset, reading length number of characters. |
SectionedCharBuffer |
read(SectionedCharBuffer buffer,
int from)
Reads characters into the
buffer. |
lineNumber, position, sourceDescriptionSectionedCharBuffer read(SectionedCharBuffer buffer, int from) throws IOException
buffer.
This method will block until data is available, an I/O error occurs, or the end of the stream is reached.
The caller is responsible for passing in from which index existing characters should be saved,
using compaction, before reading into the
front section of the buffer, using SectionedCharBuffer.readFrom(Reader).
The returned SectionedCharBuffer can be the same as got passed in, or another buffer if f.ex.
double-buffering is used. If this reader reached eof, i.e. equal state to that of Reader.read(char[])
returning -1 then SectionedCharBuffer.hasAvailable() for the returned instances will
return false.buffer - SectionedCharBuffer to read new data into.from - index into the buffer array where characters to save (compact) starts (inclusive).SectionedCharBuffer containing new data.IOException - if an I/O error occurs.int read(char[] into,
int offset,
int length)
throws IOException
offset, reading length number of characters.
Similar to Reader.read(char[], int, int)IOExceptionCopyright © 2002–2017 The Neo4j Graph Database Project. All rights reserved.