Top Fields Constructors Methods
io.vertx.core.parsetools.impl

public Class RecordParserImpl

extends Object
implements RecordParser
Class Inheritance
All Implemented Interfaces
io.vertx.core.parsetools.RecordParser, io.vertx.core.streams.ReadStream, io.vertx.core.streams.StreamBase, io.vertx.core.Handler
Imports
io.netty.buffer.Unpooled, io.vertx.core.Handler, io.vertx.core.buffer.Buffer, io.vertx.core.impl.Arguments, io.vertx.core.parsetools.RecordParser, io.vertx.core.streams.ReadStream, java.util.Objects

Authors
Tim Fox, Lars Timm

Field Summary

Modifier and TypeField and Description
private Buffer
buff

References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.
private byte[]
private boolean
private int
private long
private static final Buffer
EMPTY_BUFFER

References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.
private Handler<Void>
private Handler<Buffer>
private Handler<Throwable>
private int
private boolean
private int
private int
private int
private final ReadStream<Buffer>
private boolean

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
delimitedMode(String
the new delimeter
delim
)

Implements io.vertx.core.parsetools.RecordParser.delimitedMode.

Flip the parser into delimited mode, and where the delimiter can be represented by the String delim encoded in latin-1 .

public void
delimitedMode(Buffer
the new delimiter
delim
)

Implements io.vertx.core.parsetools.RecordParser.delimitedMode.

References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

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

private void
end()

public RecordParser
public RecordParser
public RecordParser
fetch(long amount)

Implements io.vertx.core.parsetools.RecordParser.fetch.

Fetch the specified amount of elements.

public void
fixedSizeMode(int
the new record size
size
)

Implements io.vertx.core.parsetools.RecordParser.fixedSizeMode.

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

public void
handle(Buffer
a chunk of data
buffer
)

Implements io.vertx.core.parsetools.RecordParser.handle.

References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

This method is called to provide the parser with data.

private void
public RecordParser
public static Buffer

Returns:

The byte[] form of the string
latin1StringToBytes
(String
the string
str
)
References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

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

public RecordParser

Returns:

a reference to this, so the API can be used fluently
maxRecordSize
(int
the maximum record size
size
)

Implements io.vertx.core.parsetools.RecordParser.maxRecordSize.

Set the maximum allowed size for a record when using the delimited mode.

public static RecordParser
newDelimited(String
the initial delimiter string
delim
,
ReadStream<Buffer> stream, Handler<Buffer>
handler that will receive the output
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 .

public static RecordParser
newDelimited(Buffer
the initial delimiter buffer
delim
,
ReadStream<Buffer> stream, Handler<Buffer>
handler that will receive the output
output
)
References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

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

public static RecordParser
newFixed(int
the initial record size
size
,
ReadStream<Buffer> stream, Handler<Buffer>
handler that will receive the output
output
)

Create a new RecordParser instance, initially in fixed size mode, and where the record size is specified by the size parameter.

private int
private int
public RecordParser
pause()

Implements io.vertx.core.parsetools.RecordParser.pause.

Pause the ReadStream, it sets the buffer in fetch mode and clears the actual demand.

public RecordParser
resume()

Implements io.vertx.core.parsetools.RecordParser.resume.

Resume reading, and sets the buffer in flowing mode.

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

buffback to summary
private Buffer buff

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

delimback to summary
private byte[] delim
delimitedback to summary
private boolean delimited
delimPosback to summary
private int delimPos
demandback to summary
private long demand
EMPTY_BUFFERback to summary
private static final Buffer EMPTY_BUFFER

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

endHandlerback to summary
private Handler<Void> endHandler
eventHandlerback to summary
private Handler<Buffer> eventHandler
exceptionHandlerback to summary
private Handler<Throwable> exceptionHandler
maxRecordSizeback to summary
private int maxRecordSize
parsingback to summary
private boolean parsing
posback to summary
private int pos
recordSizeback to summary
private int recordSize
startback to summary
private int start
streamback to summary
private final ReadStream<Buffer> stream
streamEndedback to summary
private boolean streamEnded

Constructor Detail

RecordParserImplback to summary
private RecordParserImpl(ReadStream<Buffer> stream)

Method Detail

delimitedModeback to summary
public void delimitedMode(String delim)

Implements io.vertx.core.parsetools.RecordParser.delimitedMode.

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:String

the new delimeter

delimitedModeback to summary
public void delimitedMode(Buffer delim)

Implements io.vertx.core.parsetools.RecordParser.delimitedMode.

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

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:Buffer

the new delimiter

endback to summary
private void end()
endHandlerback to summary
public RecordParser endHandler(Handler<Void> handler)

Implements io.vertx.core.parsetools.RecordParser.endHandler.

Annotations
@Override
exceptionHandlerback to summary
public RecordParser exceptionHandler(Handler<Throwable> handler)

Implements io.vertx.core.parsetools.RecordParser.exceptionHandler.

Annotations
@Override
fetchback to summary
public RecordParser fetch(long amount)

Implements io.vertx.core.parsetools.RecordParser.fetch.

Doc from io.vertx.core.streams.ReadStream.fetch.

Fetch the specified amount 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.

Returns:RecordParser

a reference to this, so the API can be used fluently

Annotations
@Override
fixedSizeModeback to summary
public void fixedSizeMode(int size)

Implements io.vertx.core.parsetools.RecordParser.fixedSizeMode.

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:int

the new record size

handleback to summary
public void handle(Buffer buffer)

Implements io.vertx.core.parsetools.RecordParser.handle.

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

This method is called to provide the parser with data.

Parameters
buffer:Buffer

a chunk of data

handleParsingback to summary
private void handleParsing()
handlerback to summary
public RecordParser handler(Handler<Buffer> handler)

Implements io.vertx.core.parsetools.RecordParser.handler.

Annotations
@Override
latin1StringToBytesback to summary
public static Buffer latin1StringToBytes(String str)

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

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

Parameters
str:String

the string

Returns:Buffer

The byte[] form of the string

maxRecordSizeback to summary
public RecordParser maxRecordSize(int size)

Implements io.vertx.core.parsetools.RecordParser.maxRecordSize.

Set the maximum allowed size for a record when using the delimited mode. The delimiter itself does not count for the record size.

If a record is longer than specified, an IllegalStateException will be thrown.

Parameters
size:int

the maximum record size

Returns:RecordParser

a reference to this, so the API can be used fluently

newDelimitedback to summary
public 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 . Don't use this if your String contains other than latin-1 characters.

output Will receive whole records which have been parsed.

Parameters
delim:String

the initial delimiter string

output:Handler<Buffer>

handler that will receive the output

newDelimitedback to summary
public static RecordParser newDelimited(Buffer delim, ReadStream<Buffer> stream, Handler<Buffer> output)

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

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:Buffer

the initial delimiter buffer

output:Handler<Buffer>

handler that will receive the output

newFixedback to summary
public 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.

output Will receive whole records which have been parsed.

Parameters
size:int

the initial record size

output:Handler<Buffer>

handler that will receive the output

parseDelimitedback to summary
private int parseDelimited()
parseFixedback to summary
private int parseFixed()
pauseback to summary
public RecordParser pause()

Implements io.vertx.core.parsetools.RecordParser.pause.

Doc from io.vertx.core.streams.ReadStream.pause.

Pause the ReadStream, 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.

Returns:RecordParser

a reference to this, so the API can be used fluently

Annotations
@Override
resumeback to summary
public RecordParser resume()

Implements io.vertx.core.parsetools.RecordParser.resume.

Doc from io.vertx.core.streams.ReadStream.resume.

Resume reading, and sets the buffer in flowing mode.

If the ReadStream has been paused, reading will recommence on it.

Returns:RecordParser

a reference to this, so the API can be used fluently

Annotations
@Override
setOutputback to summary
public void setOutput(Handler<Buffer> output)

Implements io.vertx.core.parsetools.RecordParser.setOutput.