Class YAMLAnchorReplayingParser
java.lang.Object
com.fasterxml.jackson.core.JsonParser
com.fasterxml.jackson.core.base.ParserMinimalBase
com.fasterxml.jackson.core.base.ParserBase
com.fasterxml.jackson.dataformat.yaml.YAMLParser
com.fasterxml.jackson.dataformat.yaml.YAMLAnchorReplayingParser
- All Implemented Interfaces:
com.fasterxml.jackson.core.Versioned,Closeable,AutoCloseable
A parser that remembers the events of anchored parts in yaml and repeats them
to inline these parts when an alias if found instead of only returning an alias.
Note: this overwrites the getEvent() since the base `super.nextToken()` manages to much state and it seems to be much simpler to re-emit the events.
- Since:
- 2.19
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.fasterxml.jackson.dataformat.yaml.YAMLParser
YAMLParser.FeatureNested classes/interfaces inherited from class com.fasterxml.jackson.core.JsonParser
com.fasterxml.jackson.core.JsonParser.NumberType, com.fasterxml.jackson.core.JsonParser.NumberTypeFP -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intkeeps track of the global depth of nested collectionsstatic final intthe maximum limit of anchors to rememberstatic final intthe maximum number of events that can be replayedstatic final intthe maximum limit of merges to followstatic final intthe maximum limit of references to rememberprivate final ArrayDeque<Integer>Remembers when a merge has been started in order to skip the corresponding sequence end which needs to be excludedKeeps track of the last sequentially found definition of each anchorprivate final ArrayDeque<org.yaml.snakeyaml.events.Event>Keeps track of events that have been insert when processing aliasprivate final ArrayDeque<YAMLAnchorReplayingParser.AnchorContext>Collects nested anchor definitionsFields inherited from class com.fasterxml.jackson.dataformat.yaml.YAMLParser
_cfgEmptyStringsToNull, _cleanedTextValue, _currentAnchor, _currentFieldName, _currentIsAlias, _formatFeatures, _lastEvent, _lastTagEvent, _objectCodec, _reader, _textValue, _yamlParser, _yamlResolverFields inherited from class 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, _numberIsNaN, _numberLong, _numberNegative, _numberString, _numTypesValid, _parsingContext, _textBuffer, _tokenInputCol, _tokenInputRow, _tokenInputTotal, JSON_READ_CAPABILITIESFields inherited from class com.fasterxml.jackson.core.base.ParserMinimalBase
_currToken, _lastClearedToken, _streamReadConstraints, _tokenCount, _trackMaxTokenCount, BD_MAX_INT, BD_MAX_LONG, BD_MIN_INT, BD_MIN_LONG, BI_MAX_INT, BI_MAX_LONG, BI_MIN_INT, BI_MIN_LONG, CHAR_NULL, INT_0, INT_9, INT_APOS, INT_ASTERISK, INT_BACKSLASH, INT_COLON, INT_COMMA, INT_CR, INT_e, INT_E, INT_HASH, INT_LBRACKET, INT_LCURLY, INT_LF, INT_MINUS, INT_PERIOD, INT_PLUS, INT_QUOTE, INT_RBRACKET, INT_RCURLY, INT_RS, INT_SLASH, INT_SPACE, INT_TAB, MAX_ERROR_TOKEN_LENGTH, MAX_INT_D, MAX_INT_L, MAX_LONG_D, MIN_INT_D, MIN_INT_L, MIN_LONG_D, NO_BYTES, NO_INTS, NR_BIGDECIMAL, NR_BIGINT, NR_DOUBLE, NR_FLOAT, NR_INT, NR_LONG, NR_UNKNOWNFields inherited from class com.fasterxml.jackson.core.JsonParser
_features, _requestPayload, DEFAULT_READ_CAPABILITIES -
Constructor Summary
ConstructorsConstructorDescriptionYAMLAnchorReplayingParser(com.fasterxml.jackson.core.io.IOContext ctxt, int parserFeatures, int formatFeatures, org.yaml.snakeyaml.LoaderOptions loaderOptions, com.fasterxml.jackson.core.ObjectCodec codec, Reader reader) -
Method Summary
Modifier and TypeMethodDescriptionprotected org.yaml.snakeyaml.events.EventfilterEvent(org.yaml.snakeyaml.events.Event event) private voidprotected org.yaml.snakeyaml.events.EventgetEvent()Since the parserImpl cannot be replaced allow subclasses to at least be able to influence the events being consumed.protected org.yaml.snakeyaml.events.EventtrackDepth(org.yaml.snakeyaml.events.Event event) Methods inherited from class com.fasterxml.jackson.dataformat.yaml.YAMLParser
_closeInput, _decodeNumberIntBinary, _decodeNumberIntHex, _decodeNumberIntOctal, _decodeNumberScalar, _decodeScalar, _locationFor, _matchYAMLBoolean, _parseIntValue, _parseNumericValue, canReadObjectId, canReadTypeId, configure, currentLocation, currentName, currentTokenLocation, disable, enable, getCodec, getCurrentAnchor, getCurrentLocation, getCurrentName, getEmbeddedObject, getFormatFeatures, getNumberTypeFP, getNumberValueDeferred, getObjectId, getReadCapabilities, getText, getText, getTextCharacters, getTextLength, getTextOffset, getTokenLocation, getTypeId, hasTextCharacters, isCurrentAlias, isEnabled, nextToken, overrideFormatFeatures, readBinaryValue, requiresCustomCodec, setCodec, versionMethods inherited from class 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, _releaseBuffers, _reportExtraEndMarker, _reportMismatchedEndMarker, _reportTooLongIntegral, _throwUnquotedSpace, _validJsonTokenList, _validJsonValueList, assignCurrentValue, close, convertNumberToBigDecimal, convertNumberToBigInteger, convertNumberToDouble, convertNumberToFloat, convertNumberToInt, convertNumberToLong, createChildArrayContext, createChildObjectContext, currentValue, disable, enable, getBigIntegerValue, getBinaryValue, getDecimalValue, getDoubleValue, getFloatValue, getIntValue, getLongValue, getNumberType, getNumberValue, getNumberValueExact, getParsingContext, getTokenCharacterOffset, getTokenColumnNr, getTokenLineNr, growArrayBy, isClosed, isNaN, loadMore, loadMoreGuaranteed, overrideCurrentName, overrideStdFeatures, reportInvalidBase64Char, reportInvalidBase64Char, reset, resetAsNaN, resetFloat, resetInt, setFeatureMaskMethods inherited from class com.fasterxml.jackson.core.base.ParserMinimalBase
_ascii, _asciiBytes, _constructError, _currentLocationMinusOne, _decodeBase64, _getCharDesc, _hasTextualNull, _longIntegerDesc, _longNumberDesc, _nullSafeUpdateToken, _reportError, _reportError, _reportError, _reportInputCoercion, _reportInvalidEOF, _reportInvalidEOF, _reportInvalidEOFInValue, _reportMissingRootWS, _reportUnexpectedChar, _reportUnexpectedNumberChar, _throwInternal, _throwInternalReturnAny, _throwInvalidSpace, _updateToken, _updateTokenToNA, _updateTokenToNull, _wrapError, clearCurrentToken, currentToken, currentTokenCount, currentTokenId, getCurrentToken, getCurrentTokenId, getLastClearedToken, getValueAsBoolean, getValueAsDouble, getValueAsInt, getValueAsInt, getValueAsLong, getValueAsLong, getValueAsString, getValueAsString, hasCurrentToken, hasToken, hasTokenId, isExpectedNumberIntToken, isExpectedStartArrayToken, isExpectedStartObjectToken, nextValue, reportInvalidNumber, reportOverflowInt, reportOverflowInt, reportOverflowInt, reportOverflowLong, reportOverflowLong, reportOverflowLong, reportUnexpectedNumberChar, skipChildren, streamReadConstraintsMethods inherited from class com.fasterxml.jackson.core.JsonParser
_codec, _constructError, _constructReadException, _constructReadException, _constructReadException, _constructReadException, _constructReadException, _constructReadException, _reportUnsupportedOperation, canParseAsync, canUseSchema, configure, finishToken, getBinaryValue, getBooleanValue, getByteValue, getCurrentValue, getFeatureMask, getInputSource, getNonBlockingInputFeeder, getSchema, getShortValue, getValueAsBoolean, getValueAsDouble, isEnabled, isEnabled, nextBooleanValue, nextFieldName, nextFieldName, nextIntValue, nextLongValue, nextTextValue, readBinaryValue, readValueAs, readValueAs, readValueAsTree, readValuesAs, readValuesAs, releaseBuffered, releaseBuffered, setCurrentValue, setRequestPayloadOnError, setRequestPayloadOnError, setRequestPayloadOnError, setSchema
-
Field Details
-
MAX_EVENTS
public static final int MAX_EVENTSthe maximum number of events that can be replayed- See Also:
-
MAX_ANCHORS
public static final int MAX_ANCHORSthe maximum limit of anchors to remember- See Also:
-
MAX_MERGES
public static final int MAX_MERGESthe maximum limit of merges to follow- See Also:
-
MAX_REFS
public static final int MAX_REFSthe maximum limit of references to remember- See Also:
-
mergeStack
Remembers when a merge has been started in order to skip the corresponding sequence end which needs to be excluded -
tokenStack
Collects nested anchor definitions -
referencedObjects
Keeps track of the last sequentially found definition of each anchor -
refEvents
Keeps track of events that have been insert when processing alias -
globalDepth
private int globalDepthkeeps track of the global depth of nested collections
-
-
Constructor Details
-
YAMLAnchorReplayingParser
public YAMLAnchorReplayingParser(com.fasterxml.jackson.core.io.IOContext ctxt, int parserFeatures, int formatFeatures, org.yaml.snakeyaml.LoaderOptions loaderOptions, com.fasterxml.jackson.core.ObjectCodec codec, Reader reader)
-
-
Method Details
-
finishContext
private void finishContext(YAMLAnchorReplayingParser.AnchorContext context) throws com.fasterxml.jackson.core.exc.StreamConstraintsException - Throws:
com.fasterxml.jackson.core.exc.StreamConstraintsException
-
trackDepth
protected org.yaml.snakeyaml.events.Event trackDepth(org.yaml.snakeyaml.events.Event event) -
filterEvent
protected org.yaml.snakeyaml.events.Event filterEvent(org.yaml.snakeyaml.events.Event event) -
getEvent
Description copied from class:YAMLParserSince the parserImpl cannot be replaced allow subclasses to at least be able to influence the events being consumed.A particular use case is working around the lack of anchor and alias support to emit additional events.
NOTE: since 2.18, declared to throw
IOExceptionto allow sub-classes to do so.- Overrides:
getEventin classYAMLParser- Throws:
IOException
-