public class TextLineDemarcator extends AbstractDemarcator
InputStream. It works similar to the BufferedReader and its
BufferedReader.readLine() methods except that it does not create a
String representing the text line and instead returns the offset info for the
computed text line. See nextOffsetInfo() and
nextOffsetInfo(byte[]) for more details.
NOTE: Not intended for multi-thread usage hence not Thread-safe.
| Modifier and Type | Class and Description |
|---|---|
static class |
TextLineDemarcator.OffsetInfo
Container to hold offset and meta info for a computed text line.
|
| Modifier and Type | Field and Description |
|---|---|
private static int |
CR |
private static int |
LF |
availableBytesLength, buffer, index, INIT_BUFFER_SIZE, mark, offset| Constructor and Description |
|---|
TextLineDemarcator(InputStream is)
Constructs an instance of demarcator with provided
InputStream
and default buffer size. |
TextLineDemarcator(InputStream is,
int initialBufferSize)
Constructs an instance of demarcator with provided
InputStream
and initial buffer size. |
| Modifier and Type | Method and Description |
|---|---|
TextLineDemarcator.OffsetInfo |
nextOffsetInfo()
Will compute the next offset info for a text line (line terminated
by either '\r', '\n' or '\r\n').
|
TextLineDemarcator.OffsetInfo |
nextOffsetInfo(byte[] startsWith)
Will compute the next offset info for a text line (line terminated
by either '\r', '\n' or '\r\n').
|
close, extractDataToken, fillpublic TextLineDemarcator(InputStream is)
InputStream
and default buffer size.public TextLineDemarcator(InputStream is, int initialBufferSize)
InputStream
and initial buffer size.public TextLineDemarcator.OffsetInfo nextOffsetInfo() throws IOException
TextLineDemarcator.OffsetInfo where
TextLineDemarcator.OffsetInfo.isStartsWithMatch() will always return true.IOExceptionpublic TextLineDemarcator.OffsetInfo nextOffsetInfo(byte[] startsWith) throws IOException
TextLineDemarcator.OffsetInfo where
TextLineDemarcator.OffsetInfo.isStartsWithMatch() will return true if
startsWith was successfully matched with the starting bytes
of the text line.
NOTE: The reason for 2 'nextOffsetInfo(..)' operations is that the
'startsWith' argument will force the actual token to be extracted and
then matched introducing the overhead for System.arrayCopy and matching
logic which is an optional scenario and is avoided all together if
'startsWith' is not provided (i.e., null).IOExceptionCopyright © 2023 Apache NiFi Project. All rights reserved.