vertx / io.vertx.reactivex.core.parsetools / RecordParser

RecordParser

open class RecordParser : ReadStream<Buffer>, Handler<Buffer>

A helper class which allows you to easily parse protocols which are delimited by a sequence of bytes, or fixed size records.

Instances of this class take as input io.vertx.reactivex.core.buffer.Buffer instances containing raw bytes, and output records.

For example, if I had a simple ASCII text protocol delimited by '\n' and the input was the following:

 buffer1:HELLO\nHOW ARE Y buffer2:OU?\nI AM buffer3: DOING OK buffer4:\n 
Then the output would be:

 buffer1:HELLO buffer2:HOW ARE YOU? buffer3:I AM DOING OK 
Instances of this class can be changed between delimited mode and fixed size record mode on the fly as individual records are read, this allows you to parse protocols where, for example, the first 5 records might all be fixed size (of potentially different sizes), followed by some delimited records, followed by more fixed size records.

Instances of this class can't currently be used for protocols where the text is encoded with something other than a 1-1 byte-char mapping.

Please see the documentation for more information.

NOTE: This class has been automatically generated from the io.vertx.core.parsetools.RecordParser non RX-ified interface using Vert.x codegen.

Constructors

<init>

RecordParser(delegate: RecordParser)

Properties

__TYPE_ARG

static val __TYPE_ARG: TypeArg<RecordParser>

Functions

delimitedMode

open fun delimitedMode(delim: String): Unit

Flip the parser into delimited mode, and where the delimiter can be represented by the String 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.

open fun delimitedMode(delim: Buffer): Unit

Flip the parser into delimited mode, and where the delimiter can be represented by the delimiter delim.

This method can be called multiple times with different values of delim while data is being parsed.

endHandler

open fun endHandler(endHandler: Handler<Void>): RecordParser

equals

open fun equals(other: Any?): Boolean

exceptionHandler

open fun exceptionHandler(handler: Handler<Throwable>): RecordParser

fixedSizeMode

open fun fixedSizeMode(size: Int): Unit

Flip the parser into fixed size mode, where the record size is specified by size in bytes.

This method can be called multiple times with different values of size while data is being parsed.

getDelegate

open fun getDelegate(): RecordParser

handle

open fun handle(buffer: Buffer): Unit

This method is called to provide the parser with data.

handler

open fun handler(handler: Handler<Buffer>): RecordParser

hashCode

open fun hashCode(): Int

newDelimited

open static fun newDelimited(delim: String, output: Handler<Buffer>): RecordParser
open static fun newDelimited(delim: Buffer, output: Handler<Buffer>): RecordParser

Like io.vertx.reactivex.core.parsetools.RecordParser#newDelimited but set the output that will receive whole records which have been parsed.

open static fun newDelimited(delim: String, stream: ReadStream<Buffer>): RecordParser
open static fun newDelimited(delim: String, stream: Flowable<Buffer>): RecordParser
open static fun newDelimited(delim: String, stream: Observable<Buffer>): RecordParser
open static fun newDelimited(delim: Buffer, stream: ReadStream<Buffer>): RecordParser
open static fun newDelimited(delim: Buffer, stream: Flowable<Buffer>): RecordParser
open static fun newDelimited(delim: Buffer, stream: Observable<Buffer>): RecordParser

Like io.vertx.reactivex.core.parsetools.RecordParser#newDelimited but wraps the stream. The stream handlers will be set/unset when the io.vertx.reactivex.core.parsetools.RecordParser#handler is set. The pause()/resume() operations are propagated to the stream.

open static fun newDelimited(delim: String): RecordParser

Create a new 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.

open static fun newDelimited(delim: Buffer): RecordParser

Create a new RecordParser instance, initially in delimited mode, and where the delimiter can be represented by the Buffer delim.

newFixed

open static fun newFixed(size: Int): RecordParser

Create a new 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.

open static fun newFixed(size: Int, output: Handler<Buffer>): RecordParser

Like io.vertx.reactivex.core.parsetools.RecordParser#newFixed but set the output that will receive whole records which have been parsed.

open static fun newFixed(size: Int, stream: ReadStream<Buffer>): RecordParser
open static fun newFixed(size: Int, stream: Flowable<Buffer>): RecordParser
open static fun newFixed(size: Int, stream: Observable<Buffer>): RecordParser

Like io.vertx.reactivex.core.parsetools.RecordParser#newFixed but wraps the stream. The stream handlers will be set/unset when the io.vertx.reactivex.core.parsetools.RecordParser#handler is set. The pause()/resume() operations are propagated to the stream.

newInstance

open static fun newInstance(arg: RecordParser): RecordParser

pause

open fun pause(): RecordParser

resume

open fun resume(): RecordParser

setOutput

open fun setOutput(output: Handler<Buffer>): Unit

toFlowable

open fun toFlowable(): Flowable<Buffer>

toObservable

open fun toObservable(): Observable<Buffer>

toString

open fun toString(): String