public interface CharSeeker extends Closeable, SourceTraceability
CharReadable. Uses a Mark
as keeper of position. Once a seek(Mark, int) has succeeded the characters specified by
the mark can be extracted into a value of an arbitrary type.
Typical usage is:
CharSeeker seeker = ...
Mark mark = new Mark();
int[] delimiters = new int[] {'\t',','};
while ( seeker.seek( mark, delimiters ) )
{
String value = seeker.extract( mark, Extractors.STRING );
// ... somehow manage the value
if ( mark.isEndOfLine() )
{
// ... end of line, put some logic to handle that here
}
}
Any Closeable resource that gets passed in will be closed in Closeable.close().SourceTraceability.AdapterEMPTY| Modifier and Type | Method and Description |
|---|---|
<EXTRACTOR extends Extractor<?>> |
extract(Mark mark,
EXTRACTOR extractor)
Extracts the value specified by the
Mark, previously populated by a call to seek(Mark, int). |
boolean |
seek(Mark mark,
int untilChar)
Seeks the next occurrence of any of the characters in
untilOneOfChars, or if end-of-line,
or even end-of-file. |
boolean |
tryExtract(Mark mark,
Extractor<?> extractor)
Extracts the value specified by the
Mark, previously populated by a call to seek(Mark, int). |
lineNumber, position, sourceDescriptionboolean seek(Mark mark, int untilChar) throws IOException
untilOneOfChars, or if end-of-line,
or even end-of-file.mark - the mutable Mark which will be updated with the findings, if any.untilChar - array of characters to seek.false if the end was reached and hence no value found, otherwise true.IOException - in case of I/O error.<EXTRACTOR extends Extractor<?>> EXTRACTOR extract(Mark mark, EXTRACTOR extractor)
Mark, previously populated by a call to seek(Mark, int).mark - the Mark specifying which part of a bigger piece of data contains the found value.extractor - Extractor capable of extracting the value.Extractor, which after the call carries the extracted value itself,
where either Extractor.value() or a more specific accessor method can be called to access the value.IllegalStateException - if the extraction
returns false.boolean tryExtract(Mark mark, Extractor<?> extractor)
Mark, previously populated by a call to seek(Mark, int).mark - the Mark specifying which part of a bigger piece of data contains the found value.extractor - Extractor capable of extracting the value.true if a value was extracted, otherwise false. Probably the only reason for
returning false would be if the data to extract was empty.Copyright © 2002–2016 The Neo4j Graph Database Project. All rights reserved.