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

public Class JsonParserImpl

extends Object
implements JsonParser
Class Inheritance
All Implemented Interfaces
io.vertx.core.parsetools.JsonParser, io.vertx.core.streams.ReadStream, io.vertx.core.streams.StreamBase, io.vertx.core.Handler
Imports
com.fasterxml.jackson.core.JsonFactory, .JsonLocation, .JsonToken, .ObjectCodec, com.fasterxml.jackson.core.base.ParserBase, com.fasterxml.jackson.core.io.IOContext, com.fasterxml.jackson.core.json.async.NonBlockingJsonParser, io.vertx.core.Handler, .VertxException, io.vertx.core.buffer.Buffer, io.vertx.core.impl.Arguments, io.vertx.core.json.DecodeException, .JsonArray, .JsonObject, io.vertx.core.json.jackson.JacksonCodec, io.vertx.core.parsetools.JsonEvent, .JsonEventType, .JsonParser, io.vertx.core.streams.ReadStream, java.io.IOException, java.util.*

Author
Julien Viet

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private static class
JsonParserImpl.TokenParser

A parser implementation that feeds from a list of tokens instead of bytes.

Field Summary

Modifier and TypeField and Description
private boolean
private List<IOException>
private String
private long
private boolean
private boolean
private Handler<Void>
private Handler<JsonEvent>
private Handler<Throwable>
private boolean
private final NonBlockingJsonParser
private final Deque<JsonEventImpl>
private final ReadStream<Buffer>
private Handler<JsonEventImpl>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public JsonParser
arrayEventMode()

Implements io.vertx.core.parsetools.JsonParser.arrayEventMode.

Flip the parser to emit a stream of events for each new json array.

public JsonParser
arrayValueMode()

Implements io.vertx.core.parsetools.JsonParser.arrayValueMode.

Flip the parser to emit a single value event for each new json array.

private void
private void
private void
public void
end()

Implements io.vertx.core.parsetools.JsonParser.end.

End the stream, this must be called after all the json stream has been processed.

public JsonParser
public JsonParser
public JsonParser
fetch(long amount)

Implements io.vertx.core.parsetools.JsonParser.fetch.

Fetch the specified amount of elements.

private void
handle(IOException
the event to handle
ioe
)

Implements io.vertx.core.Handler.handle.

Something has happened, so handle it.

public void
handle(Buffer
the event to handle
data
)

Implements io.vertx.core.Handler.handle.

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

Something has happened, so handle it.

private void
public JsonParser
public JsonParser
objectEventMode()

Implements io.vertx.core.parsetools.JsonParser.objectEventMode.

Flip the parser to emit a stream of events for each new json object.

public JsonParser
objectValueMode()

Implements io.vertx.core.parsetools.JsonParser.objectValueMode.

Flip the parser to emit a single value event for each new json object.

public JsonParser
pause()

Implements io.vertx.core.parsetools.JsonParser.pause.

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

public JsonParser
resume()

Implements io.vertx.core.parsetools.JsonParser.resume.

Resume reading, and sets the buffer in flowing mode.

public JsonParser
write(Buffer buffer)

Implements io.vertx.core.parsetools.JsonParser.write.

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

Handle a Buffer, pretty much like calling handle(Object).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

arrayValueModeback to summary
private boolean arrayValueMode
collectedExceptionsback to summary
private List<IOException> collectedExceptions
currentFieldback to summary
private String currentField
demandback to summary
private long demand
emittingback to summary
private boolean emitting
endedback to summary
private boolean ended
endHandlerback to summary
private Handler<Void> endHandler
eventHandlerback to summary
private Handler<JsonEvent> eventHandler
exceptionHandlerback to summary
private Handler<Throwable> exceptionHandler
objectValueModeback to summary
private boolean objectValueMode
parserback to summary
private final NonBlockingJsonParser parser
pendingback to summary
private final Deque<JsonEventImpl> pending
streamback to summary
private final ReadStream<Buffer> stream
tokenHandlerback to summary
private Handler<JsonEventImpl> tokenHandler

Constructor Detail

JsonParserImplback to summary
public JsonParserImpl(ReadStream<Buffer> stream)

Method Detail

arrayEventModeback to summary
public JsonParser arrayEventMode()

Implements io.vertx.core.parsetools.JsonParser.arrayEventMode.

Doc from io.vertx.core.parsetools.JsonParser.arrayEventMode.

Flip the parser to emit a stream of events for each new json array.

Returns:JsonParser

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

Annotations
@Override
arrayValueModeback to summary
public JsonParser arrayValueMode()

Implements io.vertx.core.parsetools.JsonParser.arrayValueMode.

Doc from io.vertx.core.parsetools.JsonParser.arrayValueMode.

Flip the parser to emit a single value event for each new json array.

Json array currently streamed won't be affected.
Returns:JsonParser

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

Annotations
@Override
checkExceptionsback to summary
private void checkExceptions()
checkPendingback to summary
private void checkPending()
checkTokensback to summary
private void checkTokens()
endback to summary
public void end()

Implements io.vertx.core.parsetools.JsonParser.end.

Doc from io.vertx.core.parsetools.JsonParser.end.

End the stream, this must be called after all the json stream has been processed.

Annotations
@Override
endHandlerback to summary
public JsonParser endHandler(Handler<Void> handler)

Implements io.vertx.core.parsetools.JsonParser.endHandler.

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

Implements io.vertx.core.parsetools.JsonParser.exceptionHandler.

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

Implements io.vertx.core.parsetools.JsonParser.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:JsonParser

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

Annotations
@Override
handleback to summary
private void handle(IOException ioe)

Implements io.vertx.core.Handler.handle.

Doc from io.vertx.core.Handler.handle.

Something has happened, so handle it.

Parameters
ioe:IOException

the event to handle

handleback to summary
public void handle(Buffer data)

Implements io.vertx.core.Handler.handle.

Doc from io.vertx.core.Handler.handle.

References Deprecated

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

See corresponding docs for further information.

Something has happened, so handle it.

Parameters
data:Buffer

the event to handle

Annotations
@Override
handleEventback to summary
private void handleEvent(JsonEventImpl event)
handlerback to summary
public JsonParser handler(Handler<JsonEvent> handler)

Implements io.vertx.core.parsetools.JsonParser.handler.

Annotations
@Override
objectEventModeback to summary
public JsonParser objectEventMode()

Implements io.vertx.core.parsetools.JsonParser.objectEventMode.

Doc from io.vertx.core.parsetools.JsonParser.objectEventMode.

Flip the parser to emit a stream of events for each new json object.

Returns:JsonParser

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

Annotations
@Override
objectValueModeback to summary
public JsonParser objectValueMode()

Implements io.vertx.core.parsetools.JsonParser.objectValueMode.

Doc from io.vertx.core.parsetools.JsonParser.objectValueMode.

Flip the parser to emit a single value event for each new json object.

Json object currently streamed won't be affected.
Returns:JsonParser

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

Annotations
@Override
pauseback to summary
public JsonParser pause()

Implements io.vertx.core.parsetools.JsonParser.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:JsonParser

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

Annotations
@Override
resumeback to summary
public JsonParser resume()

Implements io.vertx.core.parsetools.JsonParser.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:JsonParser

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

Annotations
@Override
writeback to summary
public JsonParser write(Buffer buffer)

Implements io.vertx.core.parsetools.JsonParser.write.

Doc from io.vertx.core.parsetools.JsonParser.write.

References Deprecated

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

See corresponding docs for further information.

Handle a Buffer, pretty much like calling handle(Object).

Returns:JsonParser

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

Annotations
@Override
io.vertx.core.parsetools.impl back to summary

private Class JsonParserImpl.BufferingHandler

extends Object
implements Handler<JsonEventImpl>
Class Inheritance
  • java.lang.Object
  • io.vertx.core.parsetools.impl.JsonParserImpl.BufferingHandler
All Implemented Interfaces
io.vertx.core.Handler

Field Summary

Modifier and TypeField and Description
pack-priv JsonParserImpl.TokenParser
pack-priv int
pack-priv Handler<Void>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv <T> T
convert(Class<T> type)

public void
handle(JsonEventImpl
the event to handle
event
)

Implements io.vertx.core.Handler.handle.

Something has happened, so handle it.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufferback to summary
pack-priv JsonParserImpl.TokenParser buffer
depthback to summary
pack-priv int depth
handlerback to summary
pack-priv Handler<Void> handler

Constructor Detail

BufferingHandlerback to summary
private BufferingHandler()

Method Detail

convertback to summary
pack-priv <T> T convert(Class<T> type)
handleback to summary
public void handle(JsonEventImpl event)

Implements io.vertx.core.Handler.handle.

Doc from io.vertx.core.Handler.handle.

Something has happened, so handle it.

Parameters
event:JsonEventImpl

the event to handle

Annotations
@Override
io.vertx.core.parsetools.impl back to summary

private Class JsonParserImpl.TokenParser

extends ParserBase
Class Inheritance

A parser implementation that feeds from a list of tokens instead of bytes.

Field Summary

Modifier and TypeField and Description
private String
private ArrayDeque<Object>
Inherited from com.fasterxml.jackson.core.base.ParserBase:
_binaryValue_byteArrayBuilder_closed_currInputProcessed_currInputRow_currInputRowStart_expLength_fractLength_inputEnd_inputPtr_intLength_ioContext_nameCopied_nameCopyBuffer_nextToken_numberBigDecimal_numberBigInt_numberDouble_numberFloat_numberInt_numberLong_numberNegative_numberString_numTypesValid_parsingContext_streamReadConstraints_textBuffer_tokenInputCol_tokenInputRow_tokenInputTotalJSON_READ_CAPABILITIES

Constructor Summary

AccessConstructor and Description
private
TokenParser(IOContext ctxt, int features)

Method Summary

Modifier and TypeMethod and Description
protected void
public ObjectCodec
getCodec()

Implements abstract com.fasterxml.jackson.core.JsonParser.getCodec.

Accessor for ObjectCodec associated with this parser, if any.

public String
getText()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.getText.

Method for accessing textual representation of the current token; if no current token (before first call to nextToken, or after encountering end-of-input), returns null.

public char[]
getTextCharacters()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.getTextCharacters.

Method similar to getText, but that will return underlying (unmodifiable) character array that contains textual value, instead of constructing a String object to contain this information.

public int
getTextLength()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.getTextLength.

Accessor used with getTextCharacters, to know length of String stored in returned buffer.

public int
getTextOffset()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.getTextOffset.

Accessor used with getTextCharacters, to know offset of the first text content character within buffer.

public JsonToken
nextToken()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.nextToken.

Main iteration method, which will advance stream enough to determine type of the next token, if any.

public void
setCodec(ObjectCodec
Codec to assign, if any; null if none
c
)

Implements abstract com.fasterxml.jackson.core.JsonParser.setCodec.

Setter that allows defining ObjectCodec associated with this parser, if any.

Inherited from com.fasterxml.jackson.core.base.ParserBase:
_checkStdFeatureChanges_contentReference_contentReferenceRedacted_convertBigDecimalToBigInteger_decodeBase64Escape_decodeBase64Escape_decodeEscaped_eofAsNextChar_finishString_getBigDecimal_getBigInteger_getByteArrayBuilder_getNumberDouble_getNumberFloat_getSourceReference_growNameDecodeBuffer_handleBase64MissingPadding_handleEOF_handleUnrecognizedCharacterEscape_parseIntValue_parseNumericValue_releaseBuffers_reportMismatchedEndMarker_reportTooLongIntegral_throwUnquotedSpace_validJsonTokenList_validJsonValueListcloseconvertNumberToBigDecimalconvertNumberToBigIntegerconvertNumberToDoubleconvertNumberToFloatconvertNumberToIntconvertNumberToLongcreateChildArrayContextcreateChildObjectContextdisableenablegetBigIntegerValuegetBinaryValuegetCurrentLocationgetCurrentNamegetCurrentValuegetDecimalValuegetDoubleValuegetFloatValuegetIntValuegetLongValuegetNumberTypegetNumberValuegetNumberValueDeferredgetNumberValueExactgetParsingContextgetTokenCharacterOffsetgetTokenColumnNrgetTokenLineNrgetTokenLocationgrowArrayByhasTextCharactersisClosedisNaNloadMoreloadMoreGuaranteedoverrideCurrentNameoverrideStdFeaturesreportInvalidBase64CharreportInvalidBase64CharresetresetAsNaNresetFloatresetIntsetCurrentValuesetFeatureMaskstreamReadConstraintsversion

Field Detail

textback to summary
private String text
tokensback to summary
private ArrayDeque<Object> tokens

Constructor Detail

TokenParserback to summary
private TokenParser(IOContext ctxt, int features)

Method Detail

_closeInputback to summary
protected void _closeInput()

Implements abstract com.fasterxml.jackson.core.base.ParserBase._closeInput.

Annotations
@Override
getCodecback to summary
public ObjectCodec getCodec()

Implements abstract com.fasterxml.jackson.core.JsonParser.getCodec.

Doc from com.fasterxml.jackson.core.JsonParser.getCodec.

Accessor for ObjectCodec associated with this parser, if any. Codec is used by readValueAs(Class) method (and its variants).

Returns:ObjectCodec

Codec assigned to this parser, if any; null if none

Annotations
@Override
getTextback to summary
public String getText()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.getText.

Doc from com.fasterxml.jackson.core.JsonParser.getText.

Method for accessing textual representation of the current token; if no current token (before first call to nextToken, or after encountering end-of-input), returns null. Method can be called for any token type.

Returns:String

Textual value associated with the current token (one returned by nextToken() or other iteration methods)

Annotations
@Override
getTextCharactersback to summary
public char[] getTextCharacters()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.getTextCharacters.

Doc from com.fasterxml.jackson.core.JsonParser.getTextCharacters.

Method similar to getText, but that will return underlying (unmodifiable) character array that contains textual value, instead of constructing a String object to contain this information. Note, however, that:

  • Textual contents are not guaranteed to start at index 0 (rather, call getTextOffset) to know the actual offset
  • Length of textual contents may be less than the length of returned buffer: call getTextLength for actual length of returned content.

Note that caller MUST NOT modify the returned character array in any way -- doing so may corrupt current parser state and render parser instance useless.

The only reason to call this method (over getText) is to avoid construction of a String object (which will make a copy of contents).

Returns:char[]

Buffer that contains the current textual value (but not necessarily at offset 0, and not necessarily until the end of buffer)

Annotations
@Override
getTextLengthback to summary
public int getTextLength()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.getTextLength.

Doc from com.fasterxml.jackson.core.JsonParser.getTextLength.

Accessor used with getTextCharacters, to know length of String stored in returned buffer.

Returns:int

Number of characters within buffer returned by getTextCharacters that are part of textual content of the current token.

Annotations
@Override
getTextOffsetback to summary
public int getTextOffset()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.getTextOffset.

Doc from com.fasterxml.jackson.core.JsonParser.getTextOffset.

Accessor used with getTextCharacters, to know offset of the first text content character within buffer.

Returns:int

Offset of the first character within buffer returned by getTextCharacters that is part of textual content of the current token.

Annotations
@Override
nextTokenback to summary
public JsonToken nextToken() throws IOException

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.nextToken.

Doc from com.fasterxml.jackson.core.JsonParser.nextToken.

Main iteration method, which will advance stream enough to determine type of the next token, if any. If none remaining (stream has no content other than possible white space before ending), null will be returned.

Returns:JsonToken

Next token from the stream, if any found, or null to indicate end-of-input

Annotations
@Override
Exceptions
IOException:
for low-level read issues, or JsonParseException for decoding problems
setCodecback to summary
public void setCodec(ObjectCodec c)

Implements abstract com.fasterxml.jackson.core.JsonParser.setCodec.

Doc from com.fasterxml.jackson.core.JsonParser.setCodec.

Setter that allows defining ObjectCodec associated with this parser, if any. Codec is used by readValueAs(Class) method (and its variants).

Parameters
c:ObjectCodec

Codec to assign, if any; null if none

Annotations
@Override