public class JsonParserSequence extends JsonParserDelegate
JsonParser
s to create a single logical sequence of
tokens, as a single JsonParser
.
Fairly simple use of JsonParserDelegate
: only need
to override nextToken()
to handle transition
JsonParser.Feature, JsonParser.NumberType
Modifier and Type | Field and Description |
---|---|
protected boolean |
_checkForExistingToken
Configuration that determines whether state of parsers is first verified
to see if parser already points to a token (that is,
JsonParser.hasCurrentToken() returns true ), and if so
that token is first return before JsonParser.nextToken() is called. |
protected boolean |
_hasToken
Flag used to indicate that `JsonParser.nextToken()` should not be called,
due to parser already pointing to a token.
|
protected int |
_nextParserIndex
Index of the next parser in
_parsers . |
protected JsonParser[] |
_parsers
Parsers other than the first one (which is initially assigned
as delegate)
|
delegate
_features, _requestPayload
Modifier | Constructor and Description |
---|---|
protected |
JsonParserSequence(boolean checkForExistingToken,
JsonParser[] parsers) |
protected |
JsonParserSequence(JsonParser[] parsers)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addFlattenedActiveParsers(List<JsonParser> listToAddIn) |
void |
close()
Closes the parser so that no further iteration or data access
can be made; will also close the underlying input source
if parser either owns the input source, or feature
JsonParser.Feature.AUTO_CLOSE_SOURCE is enabled. |
int |
containedParsersCount()
Method that is most useful for debugging or testing;
returns actual number of underlying parsers sequence
was constructed with (nor just ones remaining active)
|
static JsonParserSequence |
createFlattened(boolean checkForExistingToken,
JsonParser first,
JsonParser second)
Method that will construct a parser (possibly a sequence) that
contains all given sub-parsers.
|
static JsonParserSequence |
createFlattened(JsonParser first,
JsonParser second)
Deprecated.
Since 2.8 use
createFlattened(boolean, JsonParser, JsonParser)
instead |
JsonToken |
nextToken()
Main iteration method, which will advance stream enough
to determine type of the next token, if any.
|
JsonParser |
skipChildren()
Need to override, re-implement similar to how method defined in
ParserMinimalBase , to keep
state correct here. |
protected JsonToken |
switchAndReturnNext() |
protected boolean |
switchToNext()
Method that will switch active delegate parser from the current one
to the next parser in sequence, if there is another parser left:
if so, the next parser will become the active delegate parser.
|
canReadObjectId, canReadTypeId, canUseSchema, clearCurrentToken, currentToken, currentTokenId, disable, enable, finishToken, getBigIntegerValue, getBinaryValue, getBooleanValue, getByteValue, getCodec, getCurrentLocation, getCurrentName, getCurrentToken, getCurrentTokenId, getCurrentValue, getDecimalValue, getDoubleValue, getEmbeddedObject, getFeatureMask, getFloatValue, getInputSource, getIntValue, getLastClearedToken, getLongValue, getNumberType, getNumberValue, getObjectId, getParsingContext, getSchema, getShortValue, getText, getText, getTextCharacters, getTextLength, getTextOffset, getTokenLocation, getTypeId, getValueAsBoolean, getValueAsBoolean, getValueAsDouble, getValueAsDouble, getValueAsInt, getValueAsInt, getValueAsLong, getValueAsLong, getValueAsString, getValueAsString, hasCurrentToken, hasTextCharacters, hasToken, hasTokenId, isClosed, isEnabled, isExpectedStartArrayToken, isExpectedStartObjectToken, isNaN, nextValue, overrideCurrentName, overrideFormatFeatures, overrideStdFeatures, readBinaryValue, requiresCustomCodec, setCodec, setCurrentValue, setFeatureMask, setSchema, version
_codec, _constructError, _reportUnsupportedOperation, canParseAsync, configure, currentName, getBinaryValue, getFormatFeatures, getNonBlockingInputFeeder, nextBooleanValue, nextFieldName, nextFieldName, nextIntValue, nextLongValue, nextTextValue, readBinaryValue, readValueAs, readValueAs, readValueAsTree, readValuesAs, readValuesAs, releaseBuffered, releaseBuffered, setRequestPayloadOnError, setRequestPayloadOnError, setRequestPayloadOnError
protected final JsonParser[] _parsers
protected final boolean _checkForExistingToken
JsonParser.hasCurrentToken()
returns true
), and if so
that token is first return before JsonParser.nextToken()
is called.
If enabled, this check is made; if disabled, no check is made and
JsonParser.nextToken()
is always called for all parsers.
Default setting is false
(for backwards-compatibility)
so that possible existing token is not considered for parsers.
protected int _nextParserIndex
_parsers
.protected boolean _hasToken
@Deprecated protected JsonParserSequence(JsonParser[] parsers)
protected JsonParserSequence(boolean checkForExistingToken, JsonParser[] parsers)
public static JsonParserSequence createFlattened(boolean checkForExistingToken, JsonParser first, JsonParser second)
@Deprecated public static JsonParserSequence createFlattened(JsonParser first, JsonParser second)
createFlattened(boolean, JsonParser, JsonParser)
insteadprotected void addFlattenedActiveParsers(List<JsonParser> listToAddIn)
public void close() throws IOException
JsonParser
JsonParser.Feature.AUTO_CLOSE_SOURCE
is enabled.
Whether parser owns the input source depends on factory
method that was used to construct instance (so check
JsonFactory
for details,
but the general
idea is that if caller passes in closable resource (such
as InputStream
or Reader
) parser does NOT
own the source; but if it passes a reference (such as
File
or URL
and creates
stream or reader it does own them.close
in interface Closeable
close
in interface AutoCloseable
close
in class JsonParserDelegate
IOException
public JsonToken nextToken() throws IOException
JsonParser
nextToken
in class JsonParserDelegate
IOException
public JsonParser skipChildren() throws IOException
ParserMinimalBase
, to keep
state correct here.skipChildren
in class JsonParserDelegate
IOException
public int containedParsersCount()
protected boolean switchToNext()
protected JsonToken switchAndReturnNext() throws IOException
IOException
Copyright © 2019 JBoss by Red Hat. All rights reserved.