java.lang.Object
tools.jackson.core.JsonParser
tools.jackson.core.base.ParserMinimalBase
tools.jackson.dataformat.xml.deser.FromXmlParser
- All Implemented Interfaces:
Closeable,AutoCloseable,tools.jackson.core.Versioned,ElementWrappable
public class FromXmlParser
extends tools.jackson.core.base.ParserMinimalBase
implements ElementWrappable
JsonParser implementation that exposes XML structure as
set of JSON events that can be used for data binding.-
Nested Class Summary
Nested classes/interfaces inherited from class tools.jackson.core.JsonParser
tools.jackson.core.JsonParser.NumberType, tools.jackson.core.JsonParser.NumberTypeFP -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]We will hold on to decoded binary data, for duration of current event, so that multiple calls togetBinaryValue(tools.jackson.core.Base64Variant)will not need to decode data more than once.protected tools.jackson.core.util.ByteArrayBuilderByteArrayBuilder is needed if 'getBinaryValue' is called.protected final StringIn cases where a start element has both attributes and non-empty textual value, we have to create a bogus property; we will use this as the property name.protected Stringprotected final intBit flag composed of bits that indicate whichXmlReadFeatures are enabled.protected booleanWe need special handling to keep track of whether a value may be exposed as simple leaf value.protected booleanAdditional flag that is strictly needed when exposing "mixed" leading String value as "anonymous" property/string pair.protected tools.jackson.core.JsonTokenprotected BigIntegerprotected intprotected longprotected intBit field that indicates which numeric representations have been calculated for the current typeprotected XmlReadContextInformation about parser context, context in which the next token is to be parsed (root, array, object).protected final XmlTokenStreamstatic final StringThe default name placeholder for XML text segments is empty String ("").protected static final tools.jackson.core.util.JacksonFeatureSet<tools.jackson.core.StreamReadCapability>XML format has some peculiarities, indicated via capability system.Fields inherited from class tools.jackson.core.base.ParserMinimalBase
_closed, _currToken, _ioContext, _lastClearedToken, _objectReadContext, _streamReadConstraints, _streamReadFeatures, _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_BYTE_I, MAX_INT_D, MAX_INT_L, MAX_LONG_D, MAX_SHORT_I, MIN_BYTE_I, MIN_INT_D, MIN_INT_L, MIN_LONG_D, MIN_SHORT_I, NO_BYTES, NO_INTS, NR_BIGDECIMAL, NR_BIGINT, NR_DOUBLE, NR_FLOAT, NR_INT, NR_LONG, NR_UNKNOWN, STREAM_READ_FEATURE_DEFAULTSFields inherited from class tools.jackson.core.JsonParser
DEFAULT_READ_CAPABILITIES -
Constructor Summary
ConstructorsConstructorDescriptionFromXmlParser(tools.jackson.core.ObjectReadContext readCtxt, tools.jackson.core.io.IOContext ioCtxt, int parserFeatures, int xmlFeatures, XMLStreamReader xmlReader, XmlTokenStream tokenStream, XmlNameProcessor nameProcessor, String nameForTextElement) FromXmlParser(tools.jackson.core.ObjectReadContext readCtxt, tools.jackson.core.io.IOContext ioCtxt, int parserFeatures, int xmlFeatures, XMLStreamReader xmlReader, XmlNameProcessor nameProcessor, String nameForTextElement) -
Method Summary
Modifier and TypeMethodDescriptionprotected final void_checkNumericValue(int expType) protected voidprotected BigDecimalprotected voidprotected doubleprotected floatprotected voidprotected voidprotected byte[]_decodeBase64(tools.jackson.core.Base64Variant b64variant) protected tools.jackson.core.util.ByteArrayBuilderprotected voidMethod called when an EOF is encountered between tokens.protected final int_isIntNumber(String text) protected intprotected voidprotected voidvoidaddVirtualWrapping(Set<String> namesToWrap0, boolean caseInsensitive) Method that may be called to indicate that specified names (only local parts retained currently: this may be changed in future) should be considered "auto-wrapping", meaning that they will be doubled to contain two opening elements, two matching closing elements.voidbooleanbooleantools.jackson.core.TokenStreamLocationMethod that returns location of the last processed character; usually for error reporting purposesMethod that can be called to get the name associated with the current event.tools.jackson.core.TokenStreamLocationMethod that return the starting location of the current token; that is, position of the first character from input that starts the current token.byte[]getBinaryValue(tools.jackson.core.Base64Variant b64variant) doublefloatintlongtools.jackson.core.JsonParser.NumberTypeMethod that allows application direct access to underlying StaxXMLStreamWriter.intchar[]intintbooleanXML input actually would offer access to character arrays; but since we must coalesce things it cannot really be exposed.final booleanbooleanSince xml representation cannot really distinguish between different scalar types (numbers, booleans) -- they are all just Character Data, without schema -- we can try to infer type from intent here.booleanSince xml representation cannot really distinguish between array and object starts (both are represented with elements), this method is overridden and taken to mean that expectation is that the current start element is to mean 'start array', instead of default of 'start object'.booleanisNaN()Method overridden to support more reliable deserialization of String collections.tools.jackson.core.JsonTokentools.jackson.core.util.JacksonFeatureSet<tools.jackson.core.StreamReadCapability>tools.jackson.core.TokenStreamContextorg.codehaus.stax2.XMLStreamReader2tools.jackson.core.Versionversion()Methods inherited from class tools.jackson.core.base.ParserMinimalBase
_constructInputCoercion, _constructNotNumericType, _currentLocationMinusOne, _decodeBase64, _getCharDesc, _hasTextualNull, _longIntegerDesc, _longNumberDesc, _nullSafeUpdateToken, _reportBadInputStream, _reportBadReader, _reportError, _reportError, _reportError, _reportError, _reportInvalidEOF, _reportInvalidEOF, _reportInvalidEOFInValue, _reportInvalidNumber, _reportInvalidSpace, _reportInvalidUTF8Surrogate, _reportMissingRootWS, _reportOverflowByte, _reportOverflowInt, _reportOverflowInt, _reportOverflowInt, _reportOverflowLong, _reportOverflowLong, _reportOverflowLong, _reportOverflowShort, _reportUnexpectedChar, _reportUnexpectedNumberChar, _throwInternal, _updateToken, _updateTokenToNA, _updateTokenToNull, _wrapIOFailure, clearCurrentToken, close, currentNameMatch, currentToken, currentTokenCount, currentTokenId, finishToken, getBooleanValue, getByteValue, getLastClearedToken, getNumberTypeFP, getNumberValueDeferred, getNumberValueExact, getShortValue, getValueAsBoolean, getValueAsDouble, getValueAsInt, getValueAsInt, getValueAsLong, getValueAsLong, getValueAsString, getValueAsString, hasCurrentToken, hasToken, hasTokenId, isClosed, isEnabled, isExpectedStartObjectToken, nextName, nextName, nextNameMatch, nextValue, objectReadContext, readValueAs, readValueAs, readValueAs, readValueAsTree, skipChildren, streamReadConstraints, streamReadFeaturesMethods inherited from class tools.jackson.core.JsonParser
_constructReadException, _constructReadException, _constructReadException, _constructReadException, _constructReadException, _constructReadException, _reportUnsupportedOperation, canParseAsync, getBinaryValue, getObjectId, getSchema, getText, getTextCharacters, getTextLength, getTextOffset, getTypeId, getValueAsBoolean, getValueAsDouble, nextBooleanValue, nextIntValue, nextLongValue, nonBlockingInputFeeder, readBinaryValue, readBinaryValue, releaseBuffered, releaseBuffered
-
Field Details
-
DEFAULT_UNNAMED_TEXT_PROPERTY
The default name placeholder for XML text segments is empty String ("").- See Also:
-
XML_READ_CAPABILITIES
protected static final tools.jackson.core.util.JacksonFeatureSet<tools.jackson.core.StreamReadCapability> XML_READ_CAPABILITIESXML format has some peculiarities, indicated via capability system. -
_cfgNameForTextElement
In cases where a start element has both attributes and non-empty textual value, we have to create a bogus property; we will use this as the property name.Name used for pseudo-property used for returning XML Text value (which does not have actual element name to use). Defaults to empty String, but may be changed for inter-operability reasons: JAXB, for example, uses "value" as name.
-
_formatFeatures
protected final int _formatFeaturesBit flag composed of bits that indicate whichXmlReadFeatures are enabled. -
_streamReadContext
Information about parser context, context in which the next token is to be parsed (root, array, object). -
_xmlTokens
-
_mayBeLeaf
protected boolean _mayBeLeafWe need special handling to keep track of whether a value may be exposed as simple leaf value. -
_nextToken
protected tools.jackson.core.JsonToken _nextToken -
_currText
-
_nextIsLeadingMixed
protected boolean _nextIsLeadingMixedAdditional flag that is strictly needed when exposing "mixed" leading String value as "anonymous" property/string pair. If so, code returns START_OBJECT first, sets_nextTokento beFIELD_NAMEand sets this flag to indicate use of "anonymous" marker. -
_byteArrayBuilder
protected tools.jackson.core.util.ByteArrayBuilder _byteArrayBuilderByteArrayBuilder is needed if 'getBinaryValue' is called. If so, we better reuse it for remainder of content. -
_binaryValue
protected byte[] _binaryValueWe will hold on to decoded binary data, for duration of current event, so that multiple calls togetBinaryValue(tools.jackson.core.Base64Variant)will not need to decode data more than once. -
_numTypesValid
protected int _numTypesValidBit field that indicates which numeric representations have been calculated for the current type -
_numberInt
protected int _numberInt -
_numberLong
protected long _numberLong -
_numberBigInt
-
-
Constructor Details
-
FromXmlParser
public FromXmlParser(tools.jackson.core.ObjectReadContext readCtxt, tools.jackson.core.io.IOContext ioCtxt, int parserFeatures, int xmlFeatures, XMLStreamReader xmlReader, XmlNameProcessor nameProcessor, String nameForTextElement) -
FromXmlParser
public FromXmlParser(tools.jackson.core.ObjectReadContext readCtxt, tools.jackson.core.io.IOContext ioCtxt, int parserFeatures, int xmlFeatures, XMLStreamReader xmlReader, XmlTokenStream tokenStream, XmlNameProcessor nameProcessor, String nameForTextElement)
-
-
Method Details
-
version
public tools.jackson.core.Version version()- Specified by:
versionin interfacetools.jackson.core.Versioned- Specified by:
versionin classtools.jackson.core.JsonParser
-
streamReadInputSource
public org.codehaus.stax2.XMLStreamReader2 streamReadInputSource()- Specified by:
streamReadInputSourcein classtools.jackson.core.JsonParser
-
canReadObjectId
public boolean canReadObjectId()- Overrides:
canReadObjectIdin classtools.jackson.core.JsonParser
-
canReadTypeId
public boolean canReadTypeId()- Overrides:
canReadTypeIdin classtools.jackson.core.JsonParser
-
streamReadCapabilities
public tools.jackson.core.util.JacksonFeatureSet<tools.jackson.core.StreamReadCapability> streamReadCapabilities()- Overrides:
streamReadCapabilitiesin classtools.jackson.core.base.ParserMinimalBase
-
getStaxReader
Method that allows application direct access to underlying StaxXMLStreamWriter. Note that use of writer is discouraged, and may interfere with processing of this writer; however, occasionally it may be necessary.Note: writer instance will always be of type
XMLStreamWriter2(including Typed Access API) so upcasts are safe. -
addVirtualWrapping
Description copied from interface:ElementWrappableMethod that may be called to indicate that specified names (only local parts retained currently: this may be changed in future) should be considered "auto-wrapping", meaning that they will be doubled to contain two opening elements, two matching closing elements. This is needed for supporting handling of so-called "unwrapped" array types, something XML mappings like JAXB often use.- Specified by:
addVirtualWrappingin interfaceElementWrappable
-
isEnabled
-
currentName
Method that can be called to get the name associated with the current event.- Specified by:
currentNamein classtools.jackson.core.JsonParser
-
_closeInput
- Specified by:
_closeInputin classtools.jackson.core.base.ParserMinimalBase- Throws:
IOException
-
_releaseBuffers
protected void _releaseBuffers()- Specified by:
_releaseBuffersin classtools.jackson.core.base.ParserMinimalBase
-
streamReadContext
public tools.jackson.core.TokenStreamContext streamReadContext()- Specified by:
streamReadContextin classtools.jackson.core.JsonParser
-
assignCurrentValue
- Specified by:
assignCurrentValuein classtools.jackson.core.JsonParser
-
currentValue
- Specified by:
currentValuein classtools.jackson.core.JsonParser
-
currentTokenLocation
public tools.jackson.core.TokenStreamLocation currentTokenLocation()Method that return the starting location of the current token; that is, position of the first character from input that starts the current token.- Specified by:
currentTokenLocationin classtools.jackson.core.JsonParser
-
currentLocation
public tools.jackson.core.TokenStreamLocation currentLocation()Method that returns location of the last processed character; usually for error reporting purposes- Specified by:
currentLocationin classtools.jackson.core.JsonParser
-
isExpectedStartArrayToken
public boolean isExpectedStartArrayToken()Since xml representation cannot really distinguish between array and object starts (both are represented with elements), this method is overridden and taken to mean that expectation is that the current start element is to mean 'start array', instead of default of 'start object'.- Overrides:
isExpectedStartArrayTokenin classtools.jackson.core.base.ParserMinimalBase
-
isExpectedNumberIntToken
public boolean isExpectedNumberIntToken()Since xml representation cannot really distinguish between different scalar types (numbers, booleans) -- they are all just Character Data, without schema -- we can try to infer type from intent here. The main benefit is avoiding checks for coercion.- Overrides:
isExpectedNumberIntTokenin classtools.jackson.core.base.ParserMinimalBase
-
nextToken
public tools.jackson.core.JsonToken nextToken() throws tools.jackson.core.JacksonException- Specified by:
nextTokenin classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
nextStringValue
Method overridden to support more reliable deserialization of String collections.- Overrides:
nextStringValuein classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getString
- Specified by:
getStringin classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getStringCharacters
public char[] getStringCharacters() throws tools.jackson.core.JacksonException- Specified by:
getStringCharactersin classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getStringLength
public int getStringLength() throws tools.jackson.core.JacksonException- Specified by:
getStringLengthin classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getStringOffset
public int getStringOffset() throws tools.jackson.core.JacksonException- Specified by:
getStringOffsetin classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
hasStringCharacters
public boolean hasStringCharacters()XML input actually would offer access to character arrays; but since we must coalesce things it cannot really be exposed.- Specified by:
hasStringCharactersin classtools.jackson.core.JsonParser
-
getString
- Overrides:
getStringin classtools.jackson.core.base.ParserMinimalBase- Throws:
tools.jackson.core.JacksonException
-
getEmbeddedObject
- Overrides:
getEmbeddedObjectin classtools.jackson.core.base.ParserMinimalBase- Throws:
tools.jackson.core.JacksonException
-
getBinaryValue
public byte[] getBinaryValue(tools.jackson.core.Base64Variant b64variant) throws tools.jackson.core.JacksonException - Specified by:
getBinaryValuein classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
_decodeBase64
protected byte[] _decodeBase64(tools.jackson.core.Base64Variant b64variant) throws tools.jackson.core.JacksonException - Throws:
tools.jackson.core.JacksonException
-
isNaN
public boolean isNaN()- Specified by:
isNaNin classtools.jackson.core.JsonParser
-
getNumberType
public tools.jackson.core.JsonParser.NumberType getNumberType()- Specified by:
getNumberTypein classtools.jackson.core.JsonParser
-
getNumberValue
- Specified by:
getNumberValuein classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getIntValue
public int getIntValue() throws tools.jackson.core.JacksonException- Specified by:
getIntValuein classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getLongValue
public long getLongValue() throws tools.jackson.core.JacksonException- Specified by:
getLongValuein classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getBigIntegerValue
- Specified by:
getBigIntegerValuein classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getFloatValue
public float getFloatValue() throws tools.jackson.core.JacksonException- Specified by:
getFloatValuein classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getDoubleValue
public double getDoubleValue() throws tools.jackson.core.JacksonException- Specified by:
getDoubleValuein classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getDecimalValue
- Specified by:
getDecimalValuein classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
_checkNumericValue
protected final void _checkNumericValue(int expType) throws tools.jackson.core.JacksonException - Throws:
tools.jackson.core.JacksonException
-
_isIntNumber
-
_convertNumberToInt
protected void _convertNumberToInt() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
_convertNumberToLong
protected void _convertNumberToLong() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
_convertNumberToBigInteger
protected void _convertNumberToBigInteger() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
_convertNumberToFloat
protected float _convertNumberToFloat() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
_convertNumberToDouble
protected double _convertNumberToDouble() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
_convertNumberToBigDecimal
- Throws:
tools.jackson.core.JacksonException
-
_handleEOF
protected void _handleEOF() throws tools.jackson.core.exc.StreamReadExceptionMethod called when an EOF is encountered between tokens. If so, it may be a legitimate EOF, but only iff there is no open non-root context.- Specified by:
_handleEOFin classtools.jackson.core.base.ParserMinimalBase- Throws:
tools.jackson.core.exc.StreamReadException
-
_getByteArrayBuilder
protected tools.jackson.core.util.ByteArrayBuilder _getByteArrayBuilder() -
_nextToken
protected int _nextToken() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
_skipEndElement
protected void _skipEndElement() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-