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 Classes Modifier and Type Class Description static class
YAMLParser.Feature
Enumeration that defines all togglable features for YAML parsers.
-
Field Summary
Fields Modifier and Type Field Description protected String
_currentAnchor
Anchor for the value that parser currently points to: in case of structured types, value whose first token current token is.protected String
_currentFieldName
Let's also have a local copy of the current field nameprotected boolean
_currentIsAlias
Flag that is set when current token was derived from an Alias (reference to another value's anchor)protected int
_formatFeatures
protected org.yaml.snakeyaml.events.Event
_lastEvent
Keep track of the last event read, to get access to Location infoprotected com.fasterxml.jackson.core.ObjectCodec
_objectCodec
Codec used for data binding when (if) requested.protected Reader
_reader
Need to keep track of underlyingReader
to be able to auto-close it (if required to)protected String
_textValue
We need to keep track of text values.protected org.yaml.snakeyaml.parser.ParserImpl
_yamlParser
protected org.yaml.snakeyaml.resolver.Resolver
_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, _numberInt, _numberLong, _numberNegative, _numTypesValid, _parsingContext, _textBuffer, _tokenInputCol, _tokenInputRow, _tokenInputTotal
-
Fields 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_UNKNOWN
-
-
Constructor Summary
Constructors Constructor Description 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 Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
_closeInput()
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 int
_parseIntValue()
protected void
_parseNumericValue(int expType)
boolean
canReadObjectId()
boolean
canReadTypeId()
com.fasterxml.jackson.core.JsonParser
configure(YAMLParser.Feature f, boolean state)
Method for enabling or disabling specified CSV feature (checkYAMLParser.Feature
for list of features)com.fasterxml.jackson.core.JsonParser
disable(YAMLParser.Feature f)
Method for disabling specified CSV feature (checkYAMLParser.Feature
for list of features)com.fasterxml.jackson.core.JsonParser
enable(YAMLParser.Feature f)
Method for enabling specified CSV feature (checkYAMLParser.Feature
for list of features)byte[]
getBinaryValue(com.fasterxml.jackson.core.Base64Variant variant)
com.fasterxml.jackson.core.ObjectCodec
getCodec()
String
getCurrentAnchor()
Deprecated.Since 2.3 (was added in 2.1) -- usegetObjectId()
insteadcom.fasterxml.jackson.core.JsonLocation
getCurrentLocation()
String
getCurrentName()
Object
getEmbeddedObject()
int
getFormatFeatures()
String
getObjectId()
String
getText()
int
getText(Writer writer)
char[]
getTextCharacters()
int
getTextLength()
int
getTextOffset()
com.fasterxml.jackson.core.JsonLocation
getTokenLocation()
String
getTypeId()
boolean
hasTextCharacters()
boolean
isCurrentAlias()
Method that can be used to check whether current token was created from YAML Alias token (reference to an anchor).boolean
isEnabled(YAMLParser.Feature f)
Method for checking whether specified CSVYAMLParser.Feature
is enabled.com.fasterxml.jackson.core.JsonToken
nextToken()
com.fasterxml.jackson.core.JsonParser
overrideFormatFeatures(int values, int mask)
void
setCodec(com.fasterxml.jackson.core.ObjectCodec c)
com.fasterxml.jackson.core.Version
version()
-
Methods inherited from class com.fasterxml.jackson.core.base.ParserBase
_checkStdFeatureChanges, _decodeBase64Escape, _decodeBase64Escape, _decodeEscaped, _eofAsNextChar, _finishString, _getByteArrayBuilder, _getSourceReference, _handleBase64MissingPadding, _handleEOF, _releaseBuffers, _reportMismatchedEndMarker, _reportTooLongInt, close, convertNumberToBigDecimal, convertNumberToBigInteger, convertNumberToDouble, convertNumberToInt, convertNumberToLong, disable, enable, getBigIntegerValue, 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, setFeatureMask
-
Methods inherited from class com.fasterxml.jackson.core.base.ParserMinimalBase
_ascii, _asciiBytes, _constructError, _decodeBase64, _getCharDesc, _handleUnrecognizedCharacterEscape, _hasTextualNull, _longIntegerDesc, _longNumberDesc, _reportError, _reportError, _reportError, _reportInvalidEOF, _reportInvalidEOF, _reportInvalidEOF, _reportInvalidEOFInValue, _reportInvalidEOFInValue, _reportMissingRootWS, _reportUnexpectedChar, _throwInternal, _throwInvalidSpace, _throwUnquotedSpace, _wrapError, clearCurrentToken, currentToken, currentTokenId, getCurrentToken, getCurrentTokenId, getLastClearedToken, getValueAsBoolean, getValueAsDouble, getValueAsInt, getValueAsInt, getValueAsLong, getValueAsLong, getValueAsString, getValueAsString, hasCurrentToken, hasToken, hasTokenId, isExpectedStartArrayToken, isExpectedStartObjectToken, nextValue, reportInvalidNumber, reportOverflowInt, reportOverflowLong, reportUnexpectedNumberChar, skipChildren
-
Methods 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, nextBooleanValue, nextFieldName, nextFieldName, nextIntValue, nextLongValue, nextTextValue, readBinaryValue, readBinaryValue, readValueAs, readValueAs, readValueAsTree, readValuesAs, readValuesAs, releaseBuffered, releaseBuffered, requiresCustomCodec, setRequestPayloadOnError, setRequestPayloadOnError, setRequestPayloadOnError, setSchema
-
-
-
-
Field Detail
-
_objectCodec
protected com.fasterxml.jackson.core.ObjectCodec _objectCodec
Codec used for data binding when (if) requested.
-
_formatFeatures
protected int _formatFeatures
-
_reader
protected final Reader _reader
Need to keep track of underlyingReader
to 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 _lastEvent
Keep track of the last event read, to get access to Location info
-
_textValue
protected String _textValue
We need to keep track of text values.
-
_currentFieldName
protected String _currentFieldName
Let's also have a local copy of the current field name
-
_currentIsAlias
protected boolean _currentIsAlias
Flag that is set when current token was derived from an Alias (reference to another value's anchor)- Since:
- 2.1
-
_currentAnchor
protected String _currentAnchor
Anchor for the value that parser currently points to: in case of structured types, value whose first token current token is.
-
-
Constructor Detail
-
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 Detail
-
getCodec
public com.fasterxml.jackson.core.ObjectCodec getCodec()
- Specified by:
getCodec
in classcom.fasterxml.jackson.core.JsonParser
-
setCodec
public void setCodec(com.fasterxml.jackson.core.ObjectCodec c)
- Specified by:
setCodec
in 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 public String 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:
version
in interfacecom.fasterxml.jackson.core.Versioned
- Overrides:
version
in classcom.fasterxml.jackson.core.base.ParserBase
-
_closeInput
protected void _closeInput() throws IOException
- Specified by:
_closeInput
in classcom.fasterxml.jackson.core.base.ParserBase
- Throws:
IOException
-
getFormatFeatures
public int getFormatFeatures()
- Overrides:
getFormatFeatures
in classcom.fasterxml.jackson.core.JsonParser
-
overrideFormatFeatures
public com.fasterxml.jackson.core.JsonParser overrideFormatFeatures(int values, int mask)
- Overrides:
overrideFormatFeatures
in classcom.fasterxml.jackson.core.JsonParser
-
enable
public com.fasterxml.jackson.core.JsonParser enable(YAMLParser.Feature f)
Method for enabling specified CSV feature (checkYAMLParser.Feature
for list of features)
-
disable
public com.fasterxml.jackson.core.JsonParser disable(YAMLParser.Feature f)
Method for disabling specified CSV feature (checkYAMLParser.Feature
for list of features)
-
configure
public com.fasterxml.jackson.core.JsonParser configure(YAMLParser.Feature f, boolean state)
Method for enabling or disabling specified CSV feature (checkYAMLParser.Feature
for list of features)
-
isEnabled
public boolean isEnabled(YAMLParser.Feature f)
Method for checking whether specified CSVYAMLParser.Feature
is enabled.
-
getTokenLocation
public com.fasterxml.jackson.core.JsonLocation getTokenLocation()
- Overrides:
getTokenLocation
in classcom.fasterxml.jackson.core.base.ParserBase
-
getCurrentLocation
public com.fasterxml.jackson.core.JsonLocation getCurrentLocation()
- Overrides:
getCurrentLocation
in classcom.fasterxml.jackson.core.base.ParserBase
-
_locationFor
protected com.fasterxml.jackson.core.JsonLocation _locationFor(org.yaml.snakeyaml.error.Mark m)
-
nextToken
public com.fasterxml.jackson.core.JsonToken nextToken() throws IOException
- Specified by:
nextToken
in classcom.fasterxml.jackson.core.base.ParserMinimalBase
- Throws:
IOException
-
_decodeScalar
protected com.fasterxml.jackson.core.JsonToken _decodeScalar(org.yaml.snakeyaml.events.ScalarEvent scalar)
-
_decodeNumberScalar
protected com.fasterxml.jackson.core.JsonToken _decodeNumberScalar(String value, int len)
-
hasTextCharacters
public boolean hasTextCharacters()
- Overrides:
hasTextCharacters
in classcom.fasterxml.jackson.core.base.ParserBase
-
getText
public String getText() throws IOException
- Specified by:
getText
in classcom.fasterxml.jackson.core.base.ParserMinimalBase
- Throws:
IOException
-
getCurrentName
public String getCurrentName() throws IOException
- Overrides:
getCurrentName
in classcom.fasterxml.jackson.core.base.ParserBase
- Throws:
IOException
-
getTextCharacters
public char[] getTextCharacters() throws IOException
- Specified by:
getTextCharacters
in classcom.fasterxml.jackson.core.base.ParserMinimalBase
- Throws:
IOException
-
getTextLength
public int getTextLength() throws IOException
- Specified by:
getTextLength
in classcom.fasterxml.jackson.core.base.ParserMinimalBase
- Throws:
IOException
-
getTextOffset
public int getTextOffset() throws IOException
- Specified by:
getTextOffset
in classcom.fasterxml.jackson.core.base.ParserMinimalBase
- Throws:
IOException
-
getText
public int getText(Writer writer) throws IOException
- Overrides:
getText
in classcom.fasterxml.jackson.core.JsonParser
- Throws:
IOException
-
getEmbeddedObject
public Object getEmbeddedObject() throws IOException
- Overrides:
getEmbeddedObject
in classcom.fasterxml.jackson.core.JsonParser
- Throws:
IOException
-
getBinaryValue
public byte[] getBinaryValue(com.fasterxml.jackson.core.Base64Variant variant) throws IOException
- Overrides:
getBinaryValue
in classcom.fasterxml.jackson.core.base.ParserBase
- Throws:
IOException
-
_parseNumericValue
protected void _parseNumericValue(int expType) throws IOException
- Overrides:
_parseNumericValue
in classcom.fasterxml.jackson.core.base.ParserBase
- Throws:
IOException
-
_parseIntValue
protected int _parseIntValue() throws IOException
- Overrides:
_parseIntValue
in classcom.fasterxml.jackson.core.base.ParserBase
- Throws:
IOException
-
canReadObjectId
public boolean canReadObjectId()
- Overrides:
canReadObjectId
in classcom.fasterxml.jackson.core.JsonParser
-
canReadTypeId
public boolean canReadTypeId()
- Overrides:
canReadTypeId
in classcom.fasterxml.jackson.core.JsonParser
-
getObjectId
public String getObjectId() throws IOException, com.fasterxml.jackson.core.JsonGenerationException
- Overrides:
getObjectId
in classcom.fasterxml.jackson.core.JsonParser
- Throws:
IOException
com.fasterxml.jackson.core.JsonGenerationException
-
getTypeId
public String getTypeId() throws IOException, com.fasterxml.jackson.core.JsonGenerationException
- Overrides:
getTypeId
in classcom.fasterxml.jackson.core.JsonParser
- Throws:
IOException
com.fasterxml.jackson.core.JsonGenerationException
-
-