io.vertx.rxjava.core.parsetools

## Class RecordParser

- java.lang.Object
- - io.vertx.rxjava.core.parsetools.RecordParser

- All Implemented Interfaces:
    Handler<Buffer>

      public class RecordParser
      extends Object
      implements 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 `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 `original` non RX-ified interface using Vert.x codegen.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static TypeArg<RecordParser>` | `__TYPE_ARG`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RecordParser(RecordParser delegate)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    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 .
    `void` | `fixedSizeMode(int size)` Flip the parser into fixed size mode, where the record size is specified by `size` in bytes.
    `RecordParser` | `getDelegate()`
    `void` | `handle(Buffer buffer)` This method is called to provide the parser with data.
    `static RecordParser` | `newDelimited(Buffer delim, 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, 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, Handler<Buffer> output)` Create a new `RecordParser` instance, initially in fixed size mode, and where the record size is specified by the `size` parameter.
    `static RecordParser` | `newInstance(RecordParser arg)`
    `void` | `setOutput(Handler<Buffer> output)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### __TYPE_ARG

          public static final TypeArg<RecordParser> __TYPE_ARG

  - ### Constructor Detail

    - #### RecordParser

          public RecordParser(RecordParser delegate)

  - ### Method Detail

    - #### getDelegate

          public RecordParser getDelegate()

    - #### setOutput

          public void setOutput(Handler<Buffer> output)

    - #### newDelimited

          public static RecordParser newDelimited(String delim,
                                                  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 . Don't use this if your String contains other than latin-1 characters.

      `output` Will receive whole records which have been parsed.

      Parameters:
        `delim` - the initial delimiter string
        `output` - handler that will receive the output
      Returns:

    - #### newDelimited

          public static RecordParser newDelimited(Buffer delim,
                                                  Handler<Buffer> output)

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

      Parameters:
        `delim` - the initial delimiter buffer
        `output` - handler that will receive the output
      Returns:

    - #### newFixed

          public static RecordParser newFixed(int size,
                                              Handler<Buffer> output)

      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.

      Parameters:
        `size` - the initial record size
        `output` - handler that will receive the output
      Returns:

    - #### delimitedMode

          public 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 . 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.

      Parameters:
        `delim` - the new delimeter

    - #### delimitedMode

          public void delimitedMode(Buffer delim)

      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.

      Parameters:
        `delim` - the new delimiter

    - #### fixedSizeMode

          public void fixedSizeMode(int size)

      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.

      Parameters:
        `size` - the new record size

    - #### handle

          public void handle(Buffer buffer)

      This method is called to provide the parser with data.
      Specified by:
        `handle` in interface `Handler<Buffer>`
      Parameters:
        `buffer` - a chunk of data

    - #### newInstance

          public static RecordParser newInstance(RecordParser arg)

Copyright © 2017. All rights reserved.