Class YAMLParser
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
- All Implemented Interfaces:
com.fasterxml.jackson.core.Versioned,Closeable,AutoCloseable
public class YAMLParser
extends com.fasterxml.jackson.core.base.ParserBase
JsonParser implementation used to expose YAML documents
in form that allows other Jackson functionality to process YAML content,
such as binding POJOs to and from it, and building tree representations.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration that defines all togglable features for YAML parsers.Nested classes/interfaces inherited from class com.fasterxml.jackson.core.JsonParser
com.fasterxml.jackson.core.JsonParser.NumberType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringFor some tokens (specifically, numbers), we'll have cleaned up version, mostly free of underscoresprotected StringAnchor for the value that parser currently points to: in case of structured types, value whose first token current token is.protected StringLet's also have a local copy of the current field nameprotected booleanFlag that is set when current token was derived from an Alias (reference to another value's anchor)protected intprotected org.yaml.snakeyaml.events.EventKeep track of the last event read, to get access to Location infoprotected com.fasterxml.jackson.core.ObjectCodecCodec used for data binding when (if) requested.protected final ReaderNeed to keep track of underlyingReaderto be able to auto-close it (if required to)protected StringWe need to keep track of text values.protected final org.yaml.snakeyaml.parser.ParserImplprotected final org.yaml.snakeyaml.resolver.Resolverprivate static final PatternWe will use pattern that is bit stricter than YAML definition, but we will still allow things like extra '_' in there.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, _numberInt, _numberLong, _numberNegative, _numTypesValid, _parsingContext, _textBuffer, _tokenInputCol, _tokenInputRow, _tokenInputTotalFields inherited from class com.fasterxml.jackson.core.base.ParserMinimalBase
_currToken, _lastClearedToken, 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_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 -
Constructor Summary
ConstructorsConstructorDescriptionYAMLParser(com.fasterxml.jackson.core.io.IOContext ctxt, com.fasterxml.jackson.core.util.BufferRecycler br, int parserFeatures, int formatFeatures, com.fasterxml.jackson.core.ObjectCodec codec, Reader reader) -
Method Summary
Modifier and TypeMethodDescriptionprivate com.fasterxml.jackson.core.JsonToken_cleanYamlFloat(String str) private com.fasterxml.jackson.core.JsonToken_cleanYamlInt(String str) Helper method used to clean up YAML floating-point value so it can be parsed using standard JDK classes.protected voidprotected com.fasterxml.jackson.core.JsonToken_decodeIntWithUnderscores(String value, int len) protected com.fasterxml.jackson.core.JsonToken_decodeNumberScalar(String value, int len) protected com.fasterxml.jackson.core.JsonToken_decodeScalar(org.yaml.snakeyaml.events.ScalarEvent scalar) protected com.fasterxml.jackson.core.JsonLocation_locationFor(org.yaml.snakeyaml.error.Mark m) protected Boolean_matchYAMLBoolean(String value, int len) protected intprotected void_parseNumericValue(int expType) booleanbooleancom.fasterxml.jackson.core.JsonParserconfigure(YAMLParser.Feature f, boolean state) Method for enabling or disabling specified CSV feature (checkYAMLParser.Featurefor list of features)com.fasterxml.jackson.core.JsonParserMethod for disabling specified CSV feature (checkYAMLParser.Featurefor list of features)com.fasterxml.jackson.core.JsonParserMethod for enabling specified CSV feature (checkYAMLParser.Featurefor list of features)com.fasterxml.jackson.core.ObjectCodecgetCodec()Deprecated.com.fasterxml.jackson.core.JsonLocationintgetText()intchar[]intintcom.fasterxml.jackson.core.JsonLocationbooleanbooleanMethod that can be used to check whether current token was created from YAML Alias token (reference to an anchor).booleanMethod for checking whether specified CSVYAMLParser.Featureis enabled.com.fasterxml.jackson.core.JsonTokencom.fasterxml.jackson.core.JsonParseroverrideFormatFeatures(int values, int mask) intreadBinaryValue(com.fasterxml.jackson.core.Base64Variant b64variant, OutputStream out) voidsetCodec(com.fasterxml.jackson.core.ObjectCodec c) com.fasterxml.jackson.core.Versionversion()Methods inherited from class com.fasterxml.jackson.core.base.ParserBase
_checkStdFeatureChanges, _decodeBase64Escape, _decodeBase64Escape, _decodeEscaped, _eofAsNextChar, _finishString, _getByteArrayBuilder, _getSourceReference, _handleBase64MissingPadding, _handleEOF, _handleUnrecognizedCharacterEscape, _releaseBuffers, _reportMismatchedEndMarker, _reportTooLongIntegral, _throwUnquotedSpace, _validJsonTokenList, _validJsonValueList, close, convertNumberToBigDecimal, convertNumberToBigInteger, convertNumberToDouble, convertNumberToInt, convertNumberToLong, disable, enable, getBigIntegerValue, getBinaryValue, getCurrentValue, getDecimalValue, getDoubleValue, getFloatValue, getIntValue, getLongValue, getNumberType, getNumberValue, getParsingContext, getTokenCharacterOffset, getTokenColumnNr, getTokenLineNr, growArrayBy, isClosed, isNaN, loadMore, loadMoreGuaranteed, overrideCurrentName, overrideStdFeatures, reportInvalidBase64Char, reportInvalidBase64Char, reset, resetAsNaN, resetFloat, resetInt, setCurrentValue, setFeatureMaskMethods inherited from class com.fasterxml.jackson.core.base.ParserMinimalBase
_ascii, _asciiBytes, _constructError, _decodeBase64, _getCharDesc, _hasTextualNull, _longIntegerDesc, _longNumberDesc, _reportError, _reportError, _reportError, _reportInputCoercion, _reportInvalidEOF, _reportInvalidEOF, _reportInvalidEOF, _reportInvalidEOFInValue, _reportInvalidEOFInValue, _reportMissingRootWS, _reportUnexpectedChar, _throwInternal, _throwInvalidSpace, _wrapError, clearCurrentToken, currentToken, currentTokenId, getCurrentToken, getCurrentTokenId, getLastClearedToken, getValueAsBoolean, getValueAsDouble, getValueAsInt, getValueAsInt, getValueAsLong, getValueAsLong, getValueAsString, getValueAsString, hasCurrentToken, hasToken, hasTokenId, isExpectedStartArrayToken, isExpectedStartObjectToken, nextValue, reportInvalidNumber, reportOverflowInt, reportOverflowInt, reportOverflowInt, reportOverflowLong, reportOverflowLong, reportOverflowLong, reportUnexpectedNumberChar, skipChildrenMethods inherited from class com.fasterxml.jackson.core.JsonParser
_codec, _constructError, _reportUnsupportedOperation, canParseAsync, canUseSchema, configure, currentName, finishToken, getBinaryValue, getBooleanValue, getByteValue, getFeatureMask, getInputSource, getNonBlockingInputFeeder, getSchema, getShortValue, getValueAsBoolean, getValueAsDouble, isEnabled, isEnabled, nextBooleanValue, nextFieldName, nextFieldName, nextIntValue, nextLongValue, nextTextValue, readBinaryValue, readValueAs, readValueAs, readValueAsTree, readValuesAs, readValuesAs, releaseBuffered, releaseBuffered, requiresCustomCodec, setRequestPayloadOnError, setRequestPayloadOnError, setRequestPayloadOnError, setSchema
-
Field Details
-
PATTERN_FLOAT
We will use pattern that is bit stricter than YAML definition, but we will still allow things like extra '_' in there. -
_objectCodec
protected com.fasterxml.jackson.core.ObjectCodec _objectCodecCodec used for data binding when (if) requested. -
_formatFeatures
protected int _formatFeatures -
_reader
Need to keep track of underlyingReaderto be able to auto-close it (if required to) -
_yamlParser
protected final org.yaml.snakeyaml.parser.ParserImpl _yamlParser -
_yamlResolver
protected final org.yaml.snakeyaml.resolver.Resolver _yamlResolver -
_lastEvent
protected org.yaml.snakeyaml.events.Event _lastEventKeep track of the last event read, to get access to Location info -
_textValue
We need to keep track of text values. -
_cleanedTextValue
For some tokens (specifically, numbers), we'll have cleaned up version, mostly free of underscores -
_currentFieldName
Let's also have a local copy of the current field name -
_currentIsAlias
protected boolean _currentIsAliasFlag that is set when current token was derived from an Alias (reference to another value's anchor)- Since:
- 2.1
-
_currentAnchor
Anchor for the value that parser currently points to: in case of structured types, value whose first token current token is.
-
-
Constructor Details
-
YAMLParser
public YAMLParser(com.fasterxml.jackson.core.io.IOContext ctxt, com.fasterxml.jackson.core.util.BufferRecycler br, int parserFeatures, int formatFeatures, com.fasterxml.jackson.core.ObjectCodec codec, Reader reader)
-
-
Method Details
-
getCodec
public com.fasterxml.jackson.core.ObjectCodec getCodec()- Specified by:
getCodecin classcom.fasterxml.jackson.core.JsonParser
-
setCodec
public void setCodec(com.fasterxml.jackson.core.ObjectCodec c) - Specified by:
setCodecin classcom.fasterxml.jackson.core.JsonParser
-
isCurrentAlias
public boolean isCurrentAlias()Method that can be used to check whether current token was created from YAML Alias token (reference to an anchor).- Since:
- 2.1
-
getCurrentAnchor
Deprecated.Since 2.3 (was added in 2.1) -- usegetObjectId()insteadMethod that can be used to check if the current token has an associated anchor (id to reference via Alias) -
version
public com.fasterxml.jackson.core.Version version()- Specified by:
versionin interfacecom.fasterxml.jackson.core.Versioned- Overrides:
versionin classcom.fasterxml.jackson.core.base.ParserBase
-
_closeInput
- Specified by:
_closeInputin classcom.fasterxml.jackson.core.base.ParserBase- Throws:
IOException
-
getFormatFeatures
public int getFormatFeatures()- Overrides:
getFormatFeaturesin classcom.fasterxml.jackson.core.JsonParser
-
overrideFormatFeatures
public com.fasterxml.jackson.core.JsonParser overrideFormatFeatures(int values, int mask) - Overrides:
overrideFormatFeaturesin classcom.fasterxml.jackson.core.JsonParser
-
enable
Method for enabling specified CSV feature (checkYAMLParser.Featurefor list of features) -
disable
Method for disabling specified CSV feature (checkYAMLParser.Featurefor list of features) -
configure
Method for enabling or disabling specified CSV feature (checkYAMLParser.Featurefor list of features) -
isEnabled
Method for checking whether specified CSVYAMLParser.Featureis enabled. -
getTokenLocation
public com.fasterxml.jackson.core.JsonLocation getTokenLocation()- Overrides:
getTokenLocationin classcom.fasterxml.jackson.core.base.ParserBase
-
getCurrentLocation
public com.fasterxml.jackson.core.JsonLocation getCurrentLocation()- Overrides:
getCurrentLocationin classcom.fasterxml.jackson.core.base.ParserBase
-
_locationFor
protected com.fasterxml.jackson.core.JsonLocation _locationFor(org.yaml.snakeyaml.error.Mark m) -
nextToken
- Specified by:
nextTokenin classcom.fasterxml.jackson.core.base.ParserMinimalBase- Throws:
IOException
-
_decodeScalar
protected com.fasterxml.jackson.core.JsonToken _decodeScalar(org.yaml.snakeyaml.events.ScalarEvent scalar) throws IOException - Throws:
IOException
-
_matchYAMLBoolean
-
_decodeNumberScalar
-
_decodeIntWithUnderscores
-
hasTextCharacters
public boolean hasTextCharacters()- Overrides:
hasTextCharactersin classcom.fasterxml.jackson.core.base.ParserBase
-
getText
- Specified by:
getTextin classcom.fasterxml.jackson.core.base.ParserMinimalBase- Throws:
IOException
-
getCurrentName
- Overrides:
getCurrentNamein classcom.fasterxml.jackson.core.base.ParserBase- Throws:
IOException
-
getTextCharacters
- Specified by:
getTextCharactersin classcom.fasterxml.jackson.core.base.ParserMinimalBase- Throws:
IOException
-
getTextLength
- Specified by:
getTextLengthin classcom.fasterxml.jackson.core.base.ParserMinimalBase- Throws:
IOException
-
getTextOffset
- Specified by:
getTextOffsetin classcom.fasterxml.jackson.core.base.ParserMinimalBase- Throws:
IOException
-
getText
- Overrides:
getTextin classcom.fasterxml.jackson.core.JsonParser- Throws:
IOException
-
getEmbeddedObject
- Overrides:
getEmbeddedObjectin classcom.fasterxml.jackson.core.JsonParser- Throws:
IOException
-
readBinaryValue
public int readBinaryValue(com.fasterxml.jackson.core.Base64Variant b64variant, OutputStream out) throws IOException - Overrides:
readBinaryValuein classcom.fasterxml.jackson.core.JsonParser- Throws:
IOException
-
_parseNumericValue
- Overrides:
_parseNumericValuein classcom.fasterxml.jackson.core.base.ParserBase- Throws:
IOException
-
_parseIntValue
- Overrides:
_parseIntValuein classcom.fasterxml.jackson.core.base.ParserBase- Throws:
IOException
-
canReadObjectId
public boolean canReadObjectId()- Overrides:
canReadObjectIdin classcom.fasterxml.jackson.core.JsonParser
-
canReadTypeId
public boolean canReadTypeId()- Overrides:
canReadTypeIdin classcom.fasterxml.jackson.core.JsonParser
-
getObjectId
- Overrides:
getObjectIdin classcom.fasterxml.jackson.core.JsonParser- Throws:
IOExceptioncom.fasterxml.jackson.core.JsonGenerationException
-
getTypeId
- Overrides:
getTypeIdin classcom.fasterxml.jackson.core.JsonParser- Throws:
IOExceptioncom.fasterxml.jackson.core.JsonGenerationException
-
_cleanYamlInt
Helper method used to clean up YAML floating-point value so it can be parsed using standard JDK classes. Currently this just means stripping out optional underscores. -
_cleanYamlFloat
-
getObjectId()instead