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

    Fields
    Modifier and Type
    Field
    Description
    protected byte[]
    We will hold on to decoded binary data, for duration of current event, so that multiple calls to getBinaryValue(tools.jackson.core.Base64Variant) will not need to decode data more than once.
    protected tools.jackson.core.util.ByteArrayBuilder
    ByteArrayBuilder is needed if 'getBinaryValue' is called.
    protected final String
    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.
    protected String
     
    protected final int
    Bit flag composed of bits that indicate which XmlReadFeatures are enabled.
    protected boolean
    We need special handling to keep track of whether a value may be exposed as simple leaf value.
    protected boolean
    Additional flag that is strictly needed when exposing "mixed" leading String value as "anonymous" property/string pair.
    protected tools.jackson.core.JsonToken
     
    protected BigInteger
     
    protected int
     
    protected long
     
    protected int
    Bit field that indicates which numeric representations have been calculated for the current type
    protected XmlReadContext
    Information about parser context, context in which the next token is to be parsed (root, array, object).
    protected final XmlTokenStream
     
    static final String
    The 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_DEFAULTS

    Fields inherited from class tools.jackson.core.JsonParser

    DEFAULT_READ_CAPABILITIES
  • Constructor Summary

    Constructors
    Constructor
    Description
    FromXmlParser(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 Type
    Method
    Description
    protected final void
    _checkNumericValue(int expType)
     
    protected void
     
    protected BigDecimal
     
    protected void
     
    protected double
     
    protected float
     
    protected void
     
    protected void
     
    protected byte[]
    _decodeBase64(tools.jackson.core.Base64Variant b64variant)
     
    protected tools.jackson.core.util.ByteArrayBuilder
     
    protected void
    Method called when an EOF is encountered between tokens.
    protected final int
     
    protected int
     
    protected void
     
    protected void
     
    void
    addVirtualWrapping(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.
    void
     
    boolean
     
    boolean
     
    tools.jackson.core.TokenStreamLocation
    Method that returns location of the last processed character; usually for error reporting purposes
    Method that can be called to get the name associated with the current event.
    tools.jackson.core.TokenStreamLocation
    Method 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)
     
     
    double
     
     
    float
     
    int
     
    long
     
    tools.jackson.core.JsonParser.NumberType
     
     
    Method that allows application direct access to underlying Stax XMLStreamWriter.
     
    int
    getString(Writer writer)
     
    char[]
     
    int
     
    int
     
    boolean
    XML input actually would offer access to character arrays; but since we must coalesce things it cannot really be exposed.
    final boolean
     
    boolean
    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.
    boolean
    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'.
    boolean
     
    Method overridden to support more reliable deserialization of String collections.
    tools.jackson.core.JsonToken
     
    tools.jackson.core.util.JacksonFeatureSet<tools.jackson.core.StreamReadCapability>
     
    tools.jackson.core.TokenStreamContext
     
    org.codehaus.stax2.XMLStreamReader2
     
    tools.jackson.core.Version
     

    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, _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, streamReadFeatures

    Methods 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_UNNAMED_TEXT_PROPERTY

      public static final String 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_CAPABILITIES
      XML format has some peculiarities, indicated via capability system.
    • _cfgNameForTextElement

      protected final String _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 _formatFeatures
      Bit flag composed of bits that indicate which XmlReadFeatures are enabled.
    • _streamReadContext

      protected XmlReadContext _streamReadContext
      Information about parser context, context in which the next token is to be parsed (root, array, object).
    • _xmlTokens

      protected final XmlTokenStream _xmlTokens
    • _mayBeLeaf

      protected boolean _mayBeLeaf
      We 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

      protected String _currText
    • _nextIsLeadingMixed

      protected boolean _nextIsLeadingMixed
      Additional flag that is strictly needed when exposing "mixed" leading String value as "anonymous" property/string pair. If so, code returns START_OBJECT first, sets _nextToken to be FIELD_NAME and sets this flag to indicate use of "anonymous" marker.
    • _byteArrayBuilder

      protected tools.jackson.core.util.ByteArrayBuilder _byteArrayBuilder
      ByteArrayBuilder is needed if 'getBinaryValue' is called. If so, we better reuse it for remainder of content.
    • _binaryValue

      protected byte[] _binaryValue
      We will hold on to decoded binary data, for duration of current event, so that multiple calls to getBinaryValue(tools.jackson.core.Base64Variant) will not need to decode data more than once.
    • _numTypesValid

      protected int _numTypesValid
      Bit field that indicates which numeric representations have been calculated for the current type
    • _numberInt

      protected int _numberInt
    • _numberLong

      protected long _numberLong
    • _numberBigInt

      protected BigInteger _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:
      version in interface tools.jackson.core.Versioned
      Specified by:
      version in class tools.jackson.core.JsonParser
    • streamReadInputSource

      public org.codehaus.stax2.XMLStreamReader2 streamReadInputSource()
      Specified by:
      streamReadInputSource in class tools.jackson.core.JsonParser
    • canReadObjectId

      public boolean canReadObjectId()
      Overrides:
      canReadObjectId in class tools.jackson.core.JsonParser
    • canReadTypeId

      public boolean canReadTypeId()
      Overrides:
      canReadTypeId in class tools.jackson.core.JsonParser
    • streamReadCapabilities

      public tools.jackson.core.util.JacksonFeatureSet<tools.jackson.core.StreamReadCapability> streamReadCapabilities()
      Overrides:
      streamReadCapabilities in class tools.jackson.core.base.ParserMinimalBase
    • getStaxReader

      public XMLStreamReader getStaxReader()
      Method that allows application direct access to underlying Stax XMLStreamWriter. 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

      public void addVirtualWrapping(Set<String> namesToWrap0, boolean caseInsensitive)
      Description copied from interface: ElementWrappable
      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. This is needed for supporting handling of so-called "unwrapped" array types, something XML mappings like JAXB often use.
      Specified by:
      addVirtualWrapping in interface ElementWrappable
    • isEnabled

      public final boolean isEnabled(XmlReadFeature f)
    • currentName

      public String currentName()
      Method that can be called to get the name associated with the current event.
      Specified by:
      currentName in class tools.jackson.core.JsonParser
    • _closeInput

      protected void _closeInput() throws IOException
      Specified by:
      _closeInput in class tools.jackson.core.base.ParserMinimalBase
      Throws:
      IOException
    • _releaseBuffers

      protected void _releaseBuffers()
      Specified by:
      _releaseBuffers in class tools.jackson.core.base.ParserMinimalBase
    • streamReadContext

      public tools.jackson.core.TokenStreamContext streamReadContext()
      Specified by:
      streamReadContext in class tools.jackson.core.JsonParser
    • assignCurrentValue

      public void assignCurrentValue(Object v)
      Specified by:
      assignCurrentValue in class tools.jackson.core.JsonParser
    • currentValue

      public Object currentValue()
      Specified by:
      currentValue in class tools.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:
      currentTokenLocation in class tools.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:
      currentLocation in class tools.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:
      isExpectedStartArrayToken in class tools.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:
      isExpectedNumberIntToken in class tools.jackson.core.base.ParserMinimalBase
    • nextToken

      public tools.jackson.core.JsonToken nextToken() throws tools.jackson.core.JacksonException
      Specified by:
      nextToken in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • nextStringValue

      public String nextStringValue() throws tools.jackson.core.JacksonException
      Method overridden to support more reliable deserialization of String collections.
      Overrides:
      nextStringValue in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • getString

      public String getString() throws tools.jackson.core.JacksonException
      Specified by:
      getString in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • getStringCharacters

      public char[] getStringCharacters() throws tools.jackson.core.JacksonException
      Specified by:
      getStringCharacters in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • getStringLength

      public int getStringLength() throws tools.jackson.core.JacksonException
      Specified by:
      getStringLength in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • getStringOffset

      public int getStringOffset() throws tools.jackson.core.JacksonException
      Specified by:
      getStringOffset in class tools.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:
      hasStringCharacters in class tools.jackson.core.JsonParser
    • getString

      public int getString(Writer writer) throws tools.jackson.core.JacksonException
      Overrides:
      getString in class tools.jackson.core.base.ParserMinimalBase
      Throws:
      tools.jackson.core.JacksonException
    • getEmbeddedObject

      public Object getEmbeddedObject() throws tools.jackson.core.JacksonException
      Overrides:
      getEmbeddedObject in class tools.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:
      getBinaryValue in class tools.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:
      isNaN in class tools.jackson.core.JsonParser
    • getNumberType

      public tools.jackson.core.JsonParser.NumberType getNumberType()
      Specified by:
      getNumberType in class tools.jackson.core.JsonParser
    • getNumberValue

      public Number getNumberValue() throws tools.jackson.core.JacksonException
      Specified by:
      getNumberValue in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • getIntValue

      public int getIntValue() throws tools.jackson.core.JacksonException
      Specified by:
      getIntValue in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • getLongValue

      public long getLongValue() throws tools.jackson.core.JacksonException
      Specified by:
      getLongValue in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • getBigIntegerValue

      public BigInteger getBigIntegerValue() throws tools.jackson.core.JacksonException
      Specified by:
      getBigIntegerValue in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • getFloatValue

      public float getFloatValue() throws tools.jackson.core.JacksonException
      Specified by:
      getFloatValue in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • getDoubleValue

      public double getDoubleValue() throws tools.jackson.core.JacksonException
      Specified by:
      getDoubleValue in class tools.jackson.core.JsonParser
      Throws:
      tools.jackson.core.JacksonException
    • getDecimalValue

      public BigDecimal getDecimalValue() throws tools.jackson.core.JacksonException
      Specified by:
      getDecimalValue in class tools.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

      protected final int _isIntNumber(String text)
    • _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

      protected BigDecimal _convertNumberToBigDecimal() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _handleEOF

      protected void _handleEOF() throws tools.jackson.core.exc.StreamReadException
      Method 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:
      _handleEOF in class tools.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