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,java.io.Closeable,java.lang.AutoCloseable
public class YAMLAnchorReplayingParser extends YAMLParser
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 Classes Modifier and Type Class Description private static classYAMLAnchorReplayingParser.AnchorContext-
Nested classes/interfaces inherited from class com.fasterxml.jackson.dataformat.yaml.YAMLParser
YAMLParser.Feature
-
-
Field Summary
Fields Modifier and Type Field Description private intglobalDepthkeeps track of the global depth of nested collectionsstatic intMAX_ANCHORSthe maximum limit of anchors to rememberstatic intMAX_EVENTSthe maximum number of events that can be replayedstatic intMAX_MERGESthe maximum limit of merges to followstatic intMAX_REFSthe maximum limit of references to rememberprivate java.util.ArrayDeque<java.lang.Integer>mergeStackRemembers when a merge has been started in order to skip the corresponding sequence end which needs to be excludedprivate java.util.Map<java.lang.String,java.util.List<org.yaml.snakeyaml.events.Event>>referencedObjectsKeeps track of the last sequentially found definition of each anchorprivate java.util.ArrayDeque<org.yaml.snakeyaml.events.Event>refEventsKeeps track of events that have been insert when processing aliasprivate java.util.ArrayDeque<YAMLAnchorReplayingParser.AnchorContext>tokenStackCollects nested anchor definitions-
Fields inherited from class com.fasterxml.jackson.dataformat.yaml.YAMLParser
_cfgEmptyStringsToNull, _cleanedTextValue, _currentAnchor, _currentFieldName, _currentIsAlias, _formatFeatures, _lastEvent, _lastTagEvent, _objectCodec, _reader, _textValue, _yamlParser, _yamlResolver
-
Fields 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_CAPABILITIES
-
Fields 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_UNKNOWN
-
-
Constructor Summary
Constructors Constructor Description YAMLAnchorReplayingParser(com.fasterxml.jackson.core.io.IOContext ctxt, int parserFeatures, int formatFeatures, org.yaml.snakeyaml.LoaderOptions loaderOptions, com.fasterxml.jackson.core.ObjectCodec codec, java.io.Reader reader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.yaml.snakeyaml.events.EventfilterEvent(org.yaml.snakeyaml.events.Event event)private voidfinishContext(YAMLAnchorReplayingParser.AnchorContext context)protected 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, version
-
Methods 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, setFeatureMask
-
Methods 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, streamReadConstraints
-
Methods 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 Detail
-
MAX_EVENTS
public static final int MAX_EVENTS
the maximum number of events that can be replayed- See Also:
- Constant Field Values
-
MAX_ANCHORS
public static final int MAX_ANCHORS
the maximum limit of anchors to remember- See Also:
- Constant Field Values
-
MAX_MERGES
public static final int MAX_MERGES
the maximum limit of merges to follow- See Also:
- Constant Field Values
-
MAX_REFS
public static final int MAX_REFS
the maximum limit of references to remember- See Also:
- Constant Field Values
-
mergeStack
private final java.util.ArrayDeque<java.lang.Integer> mergeStack
Remembers when a merge has been started in order to skip the corresponding sequence end which needs to be excluded
-
tokenStack
private final java.util.ArrayDeque<YAMLAnchorReplayingParser.AnchorContext> tokenStack
Collects nested anchor definitions
-
referencedObjects
private final java.util.Map<java.lang.String,java.util.List<org.yaml.snakeyaml.events.Event>> referencedObjects
Keeps track of the last sequentially found definition of each anchor
-
refEvents
private final java.util.ArrayDeque<org.yaml.snakeyaml.events.Event> refEvents
Keeps track of events that have been insert when processing alias
-
globalDepth
private int globalDepth
keeps track of the global depth of nested collections
-
-
Method Detail
-
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
protected org.yaml.snakeyaml.events.Event getEvent() throws java.io.IOExceptionDescription 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:
java.io.IOException
-
-