Top Description Inners Fields Constructors Methods
com.fasterxml.jackson.dataformat.yaml

public Class YAMLParser

extends ParserBase
Class Inheritance
Imports
java.io.*, java.math.BigInteger, com.fasterxml.jackson.core.io.NumberInput, .IOContext, org.yaml.snakeyaml.LoaderOptions, org.yaml.snakeyaml.error.Mark, org.yaml.snakeyaml.events.*, org.yaml.snakeyaml.nodes.NodeId, .Tag, org.yaml.snakeyaml.parser.ParserImpl, org.yaml.snakeyaml.reader.StreamReader, org.yaml.snakeyaml.resolver.Resolver, com.fasterxml.jackson.core.*, com.fasterxml.jackson.core.base.ParserBase, com.fasterxml.jackson.core.util.BufferRecycler, .JacksonFeatureSet

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 and Inner Type Summary

Modifier and TypeClass and Description
public static enum
YAMLParser.Feature

Enumeration that defines all togglable features for YAML parsers.

Field Summary

Modifier and TypeField and Description
protected boolean
protected String
_cleanedTextValue

For some tokens (specifically, numbers), we'll have cleaned up version, mostly free of underscores

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 name

protected boolean
_currentIsAlias

Flag that is set when current token was derived from an Alias (reference to another value's anchor)

protected int
protected Event
_lastEvent

Keep track of the last event read, to get access to Location info

protected Event
_lastTagEvent

To keep track of tags ("type ids"), need to either get tags for all events, or, keep tag of relevant event that might have it: this is different from _lastEvent in some cases.

protected ObjectCodec
_objectCodec

Codec used for data binding when (if) requested.

protected final Reader
_reader

Need to keep track of underlying Reader to be able to auto-close it (if required to)

protected String
_textValue

We need to keep track of text values.

protected final ParserImpl
protected final Resolver
Inherited from 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_numberLong_numberNegative_numberString_numTypesValid_parsingContext_streamReadConstraints_textBuffer_tokenInputCol_tokenInputRow_tokenInputTotalJSON_READ_CAPABILITIES

Constructor Summary

AccessConstructor and Description
public
YAMLParser(IOContext ctxt, BufferRecycler br, int parserFeatures, int formatFeatures, ObjectCodec codec, Reader reader)
Deprecated since 2.14, use other constructor

public
YAMLParser(IOContext ctxt, int parserFeatures, int formatFeatures, LoaderOptions loaderOptions, ObjectCodec codec, Reader reader)

protected
YAMLParser(IOContext ctxt, int parserFeatures, int formatFeatures, ObjectCodec codec, Reader reader, ParserImpl yamlParser)

Constructor to overload by custom parser sub-classes that want to replace ParserImpl passed.

Method Summary

Modifier and TypeMethod and Description
private String
_cleanUnderscores(String str, int i, final int len)

private JsonToken
private JsonToken
_cleanYamlInt(String str)

Helper method used to clean up YAML integer value so it can be parsed using standard JDK classes.

protected void
private BigInteger
_decodeBigInt(String numStr, int base)

private JsonToken
_decodeFromBigInteger(BigInteger unsignedValue, boolean negative)

private JsonToken
_decodeFromLong(long unsignedValue, boolean negative, boolean checkIfInt)

private int
_decodeInt(String str, int base)

private long
_decodeLong(String str, int base)

protected JsonToken
_decodeNumberIntBinary(final String value, int i, final int origLen, boolean negative)

protected JsonToken
_decodeNumberIntHex(final String value, int i, final int origLen, boolean negative)

protected JsonToken
_decodeNumberIntOctal(final String value, int i, final int origLen, boolean negative)

protected JsonToken
_decodeNumberScalar(String value, final int len)

protected JsonToken
protected JsonLocation
protected Boolean
_matchYAMLBoolean(String value, int len)

protected int
protected void
_parseNumericValue(int
Numeric type that we will immediately need, if any; mostly necessary to optimize handling of floating point numbers
expType
)

Overrides com.fasterxml.jackson.core.base.ParserBase._parseNumericValue.

Method that will parse actual numeric value out of a syntactically valid number value.

private <T> T
public boolean
canReadObjectId()

Overrides com.fasterxml.jackson.core.JsonParser.canReadObjectId.

Introspection method that may be called to see if the underlying data format supports some kind of Object Ids natively (many do not; for example, JSON doesn't).

public boolean
canReadTypeId()

Overrides com.fasterxml.jackson.core.JsonParser.canReadTypeId.

Introspection method that may be called to see if the underlying data format supports some kind of Type Ids natively (many do not; for example, JSON doesn't).

public JsonParser
configure(YAMLParser.Feature f, boolean state)

Method for enabling or disabling specified CSV feature (check Feature for list of features)

public JsonLocation
currentLocation()

Overrides com.fasterxml.jackson.core.JsonParser.currentLocation.

Method that returns location of the last processed input unit (character or byte) from the input; usually for error reporting purposes.

public String
currentName()

Overrides com.fasterxml.jackson.core.JsonParser.currentName.

Method that can be called to get the name associated with the current token: for JsonToken#FIELD_NAMEs it will be the same as what getText returns; for field values it will be preceding field name; and for others (array values, root-level values) null.

public JsonLocation
currentTokenLocation()

Overrides com.fasterxml.jackson.core.JsonParser.currentTokenLocation.

Method that return the starting location of the current (most recently returned) token; that is, the position of the first input unit (character or byte) from input that starts the current token.

public JsonParser
disable(YAMLParser.Feature f)

Method for disabling specified CSV feature (check Feature for list of features)

public JsonParser
enable(YAMLParser.Feature f)

Method for enabling specified CSV feature (check Feature for list of features)

public ObjectCodec
getCodec()

Implements abstract com.fasterxml.jackson.core.JsonParser.getCodec.

Accessor for ObjectCodec associated with this parser, if any.

public String
getCurrentAnchor()
Deprecated Since 2.3 (was added in 2.1) -- use getObjectId instead

Method that can be used to check if the current token has an associated anchor (id to reference via Alias)

public JsonLocation
getCurrentLocation()

Overrides com.fasterxml.jackson.core.base.ParserBase.getCurrentLocation.

Deprecated

Method that returns location of the last processed character; usually for error reporting purposes

public String
getCurrentName()

Overrides com.fasterxml.jackson.core.base.ParserBase.getCurrentName.

Deprecated

Method that can be called to get the name associated with the current event.

public Object
getEmbeddedObject()

Overrides com.fasterxml.jackson.core.JsonParser.getEmbeddedObject.

Accessor that can be called if (and only if) the current token is JsonToken#VALUE_EMBEDDED_OBJECT.

protected Event
getEvent()

Since the parserImpl cannot be replaced allow subclasses to at least be able to influence the events being consumed.

public int
getFormatFeatures()

Overrides com.fasterxml.jackson.core.JsonParser.getFormatFeatures.

Bulk access method for getting state of all FormatFeatures, format-specific on/off configuration settings.

public JsonParser.NumberTypeFP
getNumberTypeFP()

Overrides com.fasterxml.jackson.core.JsonParser.getNumberTypeFP.

If current token is of type JsonToken#VALUE_NUMBER_FLOAT, returns one of NumberTypeFP constants; otherwise returns NumberTypeFP#UNKNOWN.

public Object
getNumberValueDeferred()

Overrides com.fasterxml.jackson.core.base.ParserBase.getNumberValueDeferred.

Method similar to getNumberValue but that returns either same Number value as getNumberValue() (if already decoded), or String representation of as-of-yet undecoded number.

public String
getObjectId()

Overrides com.fasterxml.jackson.core.JsonParser.getObjectId.

Method that can be called to check whether current token (one that was just read) has an associated Object id, and if so, return it.

public JacksonFeatureSet<StreamReadCapability>
getReadCapabilities()

Overrides com.fasterxml.jackson.core.JsonParser.getReadCapabilities.

Accessor for getting metadata on capabilities of this parser, based on underlying data format being read (directly or indirectly).

public String
getText()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.getText.

Method for accessing textual representation of the current token; if no current token (before first call to nextToken, or after encountering end-of-input), returns null.

public int
getText(Writer
Writer to write textual content to
writer
)

Overrides com.fasterxml.jackson.core.JsonParser.getText.

Method to read the textual representation of the current token in chunks and pass it to the given Writer.

public char[]
getTextCharacters()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.getTextCharacters.

Method similar to getText, but that will return underlying (unmodifiable) character array that contains textual value, instead of constructing a String object to contain this information.

public int
getTextLength()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.getTextLength.

Accessor used with getTextCharacters, to know length of String stored in returned buffer.

public int
getTextOffset()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.getTextOffset.

Accessor used with getTextCharacters, to know offset of the first text content character within buffer.

public JsonLocation
getTokenLocation()

Overrides com.fasterxml.jackson.core.base.ParserBase.getTokenLocation.

Deprecated

Method that return the starting location of the current token; that is, position of the first character from input that starts the current token.

public String
getTypeId()

Overrides com.fasterxml.jackson.core.JsonParser.getTypeId.

Method that can be called to check whether current token (one that was just read) has an associated type id, and if so, return it.

public boolean
hasTextCharacters()

Overrides com.fasterxml.jackson.core.base.ParserBase.hasTextCharacters.

Method that can be used to determine whether calling of getTextCharacters would be the most efficient way to access textual content for the event parser currently points to.

public boolean
isCurrentAlias()

Method that can be used to check whether current token was created from YAML Alias token (reference to an anchor).

public boolean
isEnabled(YAMLParser.Feature f)

Method for checking whether specified CSV Feature is enabled.

public JsonToken
nextToken()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.nextToken.

Main iteration method, which will advance stream enough to determine type of the next token, if any.

public JsonParser
overrideFormatFeatures(int
Bit mask of set/clear state for features to change
values
,
int
Bit mask of features to change
mask
)

Overrides com.fasterxml.jackson.core.JsonParser.overrideFormatFeatures.

Bulk set method for (re)setting states of FormatFeatures, by specifying values (set / clear) along with a mask, to determine which features to change, if any.

public int
readBinaryValue(Base64Variant
base64 variant to use
b64variant
,
OutputStream
Output stream to use for passing decoded binary data
out
)

Overrides com.fasterxml.jackson.core.JsonParser.readBinaryValue.

Similar to readBinaryValue(OutputStream) but allows explicitly specifying base64 variant to use.

public boolean
requiresCustomCodec()

Overrides com.fasterxml.jackson.core.JsonParser.requiresCustomCodec.

Method that can be called to determine if a custom ObjectCodec is needed for binding data parsed using JsonParser constructed by this factory (which typically also implies the same for serialization with JsonGenerator).

public void
setCodec(ObjectCodec
Codec to assign, if any; null if none
c
)

Implements abstract com.fasterxml.jackson.core.JsonParser.setCodec.

Setter that allows defining ObjectCodec associated with this parser, if any.

public Version
version()

Overrides com.fasterxml.jackson.core.base.ParserBase.version.

Implements com.fasterxml.jackson.core.Versioned.version.

Accessor for getting version of the core package, given a parser instance.

Inherited from 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_reportMismatchedEndMarker_reportTooLongIntegral_throwUnquotedSpace_validJsonTokenList_validJsonValueListcloseconvertNumberToBigDecimalconvertNumberToBigIntegerconvertNumberToDoubleconvertNumberToFloatconvertNumberToIntconvertNumberToLongcreateChildArrayContextcreateChildObjectContextdisableenablegetBigIntegerValuegetBinaryValuegetCurrentValuegetDecimalValuegetDoubleValuegetFloatValuegetIntValuegetLongValuegetNumberTypegetNumberValuegetNumberValueExactgetParsingContextgetTokenCharacterOffsetgetTokenColumnNrgetTokenLineNrgrowArrayByisClosedisNaNloadMoreloadMoreGuaranteedoverrideCurrentNameoverrideStdFeaturesreportInvalidBase64CharreportInvalidBase64CharresetresetAsNaNresetFloatresetIntsetCurrentValuesetFeatureMaskstreamReadConstraints