public class RecordParserImpl extends Object implements RecordParser
| Modifier and Type | Method and Description |
|---|---|
void |
delimitedMode(Buffer delim)
Flip the parser into delimited mode, and where the delimiter can be represented
by the delimiter
delim. |
void |
delimitedMode(String delim)
Flip the parser into delimited mode, and where the delimiter can be represented
by the String
delim encoded in latin-1 . |
RecordParser |
endHandler(Handler<Void> handler)
Set an end handler.
|
RecordParser |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the read stream.
|
RecordParser |
fetch(long amount)
Fetch the specified
amount of elements. |
void |
fixedSizeMode(int size)
Flip the parser into fixed size mode, where the record size is specified by
size in bytes. |
void |
handle(Buffer buffer)
This method is called to provide the parser with data.
|
RecordParser |
handler(Handler<Buffer> handler)
Set a data handler.
|
static Buffer |
latin1StringToBytes(String str)
Helper method to convert a latin-1 String to an array of bytes for use as a delimiter
Please do not use this for non latin-1 characters
|
RecordParser |
maxRecordSize(int size)
Set the maximum allowed size for a record when using the delimited mode.
|
static RecordParser |
newDelimited(Buffer delim,
ReadStream<Buffer> stream,
Handler<Buffer> output)
Create a new
RecordParser instance, initially in delimited mode, and where the delimiter can be represented
by the buffer delim. |
static RecordParser |
newDelimited(String delim,
ReadStream<Buffer> stream,
Handler<Buffer> output)
Create a new
RecordParser instance, initially in delimited mode, and where the delimiter can be represented
by the String delim endcoded in latin-1 . |
static RecordParser |
newFixed(int size,
ReadStream<Buffer> stream,
Handler<Buffer> output)
Create a new
RecordParser instance, initially in fixed size mode, and where the record size is specified
by the size parameter. |
RecordParser |
pause()
Pause the
ReadStream, it sets the buffer in fetch mode and clears the actual demand. |
RecordParser |
resume()
Resume reading, and sets the buffer in
flowing mode. |
void |
setOutput(Handler<Buffer> output) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitnewDelimited, newDelimited, newDelimited, newDelimited, newDelimited, newDelimited, newFixed, newFixed, newFixedpipe, pipeTo, pipeTopublic void setOutput(Handler<Buffer> output)
setOutput in interface RecordParserpublic static Buffer latin1StringToBytes(String str)
str - the stringpublic static RecordParser newDelimited(String delim, ReadStream<Buffer> stream, Handler<Buffer> output)
RecordParser instance, initially in delimited mode, and where the delimiter can be represented
by the String delim endcoded in latin-1 . Don't use this if your String contains other than latin-1 characters.
output Will receive whole records which have been parsed.
delim - the initial delimiter stringoutput - handler that will receive the outputpublic static RecordParser newDelimited(Buffer delim, ReadStream<Buffer> stream, Handler<Buffer> output)
RecordParser instance, initially in delimited mode, and where the delimiter can be represented
by the buffer delim.
output Will receive whole records which have been parsed.
delim - the initial delimiter bufferoutput - handler that will receive the outputpublic static RecordParser newFixed(int size, ReadStream<Buffer> stream, Handler<Buffer> output)
RecordParser instance, initially in fixed size mode, and where the record size is specified
by the size parameter.
output Will receive whole records which have been parsed.
size - the initial record sizeoutput - handler that will receive the outputpublic void delimitedMode(String delim)
delim encoded in latin-1 . Don't use this if your String contains other than latin-1 characters.
This method can be called multiple times with different values of delim while data is being parsed.
delimitedMode in interface RecordParserdelim - the new delimeterpublic void delimitedMode(Buffer delim)
delim.
This method can be called multiple times with different values of delim while data is being parsed.
delimitedMode in interface RecordParserdelim - the new delimiterpublic void fixedSizeMode(int size)
size in bytes.
This method can be called multiple times with different values of size while data is being parsed.
fixedSizeMode in interface RecordParsersize - the new record sizepublic RecordParser maxRecordSize(int size)
If a record is longer than specified, an IllegalStateException will be thrown.
maxRecordSize in interface RecordParsersize - the maximum record sizepublic void handle(Buffer buffer)
handle in interface Handler<Buffer>handle in interface RecordParserbuffer - a chunk of datapublic RecordParser exceptionHandler(Handler<Throwable> handler)
ReadStreamexceptionHandler in interface RecordParserexceptionHandler in interface ReadStream<Buffer>exceptionHandler in interface StreamBasehandler - the exception handlerpublic RecordParser handler(Handler<Buffer> handler)
ReadStreamhandler in interface RecordParserhandler in interface ReadStream<Buffer>public RecordParser pause()
ReadStreamReadStream, it sets the buffer in fetch mode and clears the actual demand.
While it's paused, no data will be sent to the data handler.
pause in interface RecordParserpause in interface ReadStream<Buffer>public RecordParser fetch(long amount)
ReadStreamamount of elements. If the ReadStream has been paused, reading will
recommence with the specified amount of items, otherwise the specified amount will
be added to the current stream demand.fetch in interface RecordParserfetch in interface ReadStream<Buffer>public RecordParser resume()
ReadStreamflowing mode.
If the ReadStream has been paused, reading will recommence on it.resume in interface RecordParserresume in interface ReadStream<Buffer>public RecordParser endHandler(Handler<Void> handler)
ReadStreamendHandler in interface RecordParserendHandler in interface ReadStream<Buffer>Copyright © 2020. All rights reserved.